aboutsummaryrefslogtreecommitdiffstats
path: root/generate.php
diff options
context:
space:
mode:
authorFran├žois Kooman <fkooman@tuxed.net>2016-06-08 16:15:49 +0200
committerFran├žois Kooman <fkooman@tuxed.net>2016-06-08 16:15:49 +0200
commitfe886fbdffd77d3c6e7e8034b1693f91f20f6dec (patch)
tree31836a6a0d0ae3c0dda6ba558d2734e7800736eb /generate.php
parent1906abc79702c6acc55d482606a29e4f7e30d42f (diff)
downloadwww.tuxed.net-fe886fbdffd77d3c6e7e8034b1693f91f20f6dec.zip
www.tuxed.net-fe886fbdffd77d3c6e7e8034b1693f91f20f6dec.tar.gz
www.tuxed.net-fe886fbdffd77d3c6e7e8034b1693f91f20f6dec.tar.xz
add commented out feed generator, use images instead of text for author links
Diffstat (limited to 'generate.php')
-rw-r--r--generate.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/generate.php b/generate.php
index c7a7189..f01b9cb 100644
--- a/generate.php
+++ b/generate.php
@@ -4,6 +4,9 @@ require_once 'vendor/autoload.php';
use Michelf\MarkdownExtra;
use fkooman\Tpl\Twig\TwigTemplateManager;
+use Suin\RSSWriter\Channel;
+use Suin\RSSWriter\Feed;
+use Suin\RSSWriter\Item;
$postDir = sprintf('%s/posts', __DIR__);
$outputDir = sprintf('%s/output', __DIR__);
@@ -35,7 +38,7 @@ foreach (glob(sprintf('%s/*.md', $postDir)) as $postFile) {
$line = fgets($f);
} while (0 !== strpos($line, '---'));
- // read rest of the post
+ // read rest of the post
$buffer = '';
while (!feof($f)) {
$buffer .= fgets($f);
@@ -48,6 +51,7 @@ foreach (glob(sprintf('%s/*.md', $postDir)) as $postFile) {
$blogPost = [
'htmlContent' => $parser->transform($buffer),
+ 'description' => isset($postInfo['description']) ? $postInfo['description'] : $postInfo['title'],
'published' => $postInfo['published'],
'title' => $postInfo['title'],
'modified' => isset($postInfo['modified']) ? $postInfo['modified'] : null,
@@ -75,6 +79,18 @@ $indexPage = $tpl->render(
]
);
+#$feed = new Feed();
+#$channel = new Channel();
+#$channel
+# ->title($blogTitle)
+# ->description($blogDescription)
+# ->url($blogUrl)
+# ->language('en-US')
+# ->pubDate(time())
+# ->lastBuildDate(time())
+# ->ttl(60)
+# ->appendTo($feed);
+
foreach ($postsList as $post) {
$postPage = $tpl->render(
'post',
@@ -89,10 +105,30 @@ foreach ($postsList as $post) {
]
);
file_put_contents($outputDir.'/'.$post['fileName'], $postPage);
+
+# // add to feed/channel
+# $item = new Item();
+# $item
+# ->title($post['title'])
+# ->description($post['description'])
+# ->contentEncoded(htmlentities($post['htmlContent']))
+# ->url($blogUrl.$post['fileName'])
+# ->author($blogAuthor)
+# ->pubDate(strtotime($post['published']))
+# ->guid($blogUrl.$post['fileName'], true)
+# ->appendTo($channel);
}
file_put_contents($outputDir.'/index.html', $indexPage);
+// copy img
+@mkdir($outputDir.'/img');
+foreach (glob(__DIR__.'/img/*') as $imgFile) {
+ copy($imgFile, $outputDir.'/img/'.basename($imgFile));
+}
+
// copy css
@mkdir($outputDir.'/css');
copy(__DIR__.'/screen.css', $outputDir.'/css/screen.css');
+
+#file_put_contents($outputDir.'/feed.xml', $feed->render());