read me
This commit is contained in:
parent
5ff36c1748
commit
b96f29bc49
2 changed files with 30 additions and 0 deletions
7
README.md
Normal file
7
README.md
Normal file
|
|
@ -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.
|
||||
|
|
@ -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 = <<<SQL
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue