From b96f29bc49bbdc97769ee41d9e697c01bcbb9446 Mon Sep 17 00:00:00 2001 From: MuitaPata Date: Wed, 7 Jan 2026 02:00:03 +0000 Subject: [PATCH] read me --- README.md | 7 +++++++ update_gmi_content.php | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e51679d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# writefreely to gemini + +This is a quickly hacked PHP script that will get the latests posts in your sqlite database and create .md and .gmi files to serves as a gemini protocol file. It uses gemgen command line for the markdown to gemtext translation. + +This was created for https://lacra.ia.br/ + +License is do what the fuck you want with this. diff --git a/update_gmi_content.php b/update_gmi_content.php index bc3e0be..2c3c7a5 100644 --- a/update_gmi_content.php +++ b/update_gmi_content.php @@ -9,6 +9,29 @@ $pdo = new PDO('sqlite:' . $dbFile, null, null, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); +//------------------------------- +// Check if any post was updated +//------------------------------- +$sql = "select MAX(updated) upd from posts"; +$stmt = $pdo->query($sql); +$row = $stmt->fetch(PDO::FETCH_ASSOC); +$upd = trim($row['upd']); + +$TIMEFILE = sys_get_temp_dir().DIRECTORY_SEPARATOR.'writefreely_to_gemini_stamp'; + +echo "Using timestamp file:$TIMEFILE\n\n"; +$prev = trim(file_get_contents($TIMEFILE)); +if ($upd==$prev) + die("No updated needed, Latest stamp is equal to : [ $upd ] \n\n"); + +echo "Last updated in database: [ $upd ] NOT EQUAL to disk stamp [ $prev ] in - WILL UPDATE \n\n"; +file_put_contents($TIMEFILE,$upd); + + + +//------------------------------- +// Process all posts each time +//------------------------------- $sql = <<