2021-04-09 15:40:55 +02:00
|
|
|
#!/usr/bin/php7.4
|
|
|
|
<?php
|
|
|
|
|
|
|
|
chdir(__DIR__.'/../');
|
|
|
|
|
|
|
|
$posts = json_decode(file_get_contents('https://www.deblan.io/api/posts.json'), true);
|
|
|
|
|
|
|
|
if (!is_dir('blog')) {
|
|
|
|
mkdir('blog');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_dir('blog/posts')) {
|
|
|
|
mkdir('blog/posts');
|
|
|
|
}
|
|
|
|
|
|
|
|
$currentPosts = glob('blog/posts/*.gmi');
|
|
|
|
|
|
|
|
foreach ($currentPosts as $currentPost) {
|
|
|
|
unlink($currentPost);
|
|
|
|
}
|
|
|
|
|
|
|
|
$index = <<<EOF
|
|
|
|
# Simon Vieille
|
|
|
|
|
|
|
|
┌───┬───┬───┐
|
|
|
|
│ │ ● │ │
|
|
|
|
├───┼───┼───┤
|
|
|
|
│ │ │ ● │
|
|
|
|
├───┼───┼───┤
|
|
|
|
│ ● │ ● │ ● │
|
|
|
|
└───┴───┴───┘
|
|
|
|
|
|
|
|
## [FR] DevOp animé par la culture du libre et du hacking
|
|
|
|
## [EN] Devop driven by the culture of free and hacking
|
|
|
|
|
|
|
|
|
|
|
|
Derniers articles | Latest posts
|
|
|
|
────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
|
|
|
|
$files = [];
|
|
|
|
|
|
|
|
foreach ($posts as $post) {
|
|
|
|
$file = sprintf('posts/%d.gmi', $post['id']);
|
|
|
|
|
|
|
|
$index.= sprintf(
|
|
|
|
"=> %s [FR] %s (%s)\n",
|
|
|
|
$file,
|
|
|
|
$post['title'],
|
|
|
|
$post['date']
|
|
|
|
);
|
|
|
|
|
|
|
|
$outputMd = 'blog/'.$file.'.md';
|
|
|
|
$outputGmi = 'blog/'.$file;
|
|
|
|
|
|
|
|
$files[] = [$outputMd, $outputGmi];
|
|
|
|
|
|
|
|
$content = sprintf("# %s \n", $post['title']);
|
|
|
|
$content.= sprintf("* %s \n", $post['date']);
|
|
|
|
|
|
|
|
if (!empty($post['categories'])) {
|
|
|
|
$content.= sprintf("* %s \n", implode(', ', $post['categories']));
|
|
|
|
}
|
|
|
|
|
|
|
|
$content.= "\n";
|
|
|
|
$content.= $post['content'];
|
|
|
|
|
|
|
|
file_put_contents($outputMd, $content);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($files as $v) {
|
|
|
|
shell_exec(sprintf(
|
|
|
|
'md2gemini %1$s > %2$s && rm %1$s',
|
|
|
|
$v[0],
|
|
|
|
$v[1]
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
$index.= "\n";
|
|
|
|
$index.= "───────────────────────────────────────────────────\n";
|
|
|
|
$index.= "Je soutiens Tinternet & cie, les Chatons et l'April\n";
|
|
|
|
$index.= "Simon Vieille - Textes libres sauf indication(s) contraire(s)\n";
|
|
|
|
|
|
|
|
file_put_contents('blog/index.gmi', $index);
|
2021-04-12 22:15:29 +02:00
|
|
|
file_put_contents('blog/feed.xml', file_get_contents('https://www.deblan.io/RSS'));
|