aboutsummaryrefslogtreecommitdiffstats
path: root/generate.php
diff options
context:
space:
mode:
authorFran├žois Kooman <fkooman@tuxed.net>2017-01-05 15:09:22 +0100
committerFran├žois Kooman <fkooman@tuxed.net>2017-01-05 15:09:22 +0100
commite8c53a9efd4699d628b379a715a96beb9a016de3 (patch)
tree157c96bc94596cf16f9eb3041a032ac4451568ea /generate.php
parent5ec45f9e048a866dfa7167cb311f712cd35f4c6b (diff)
downloadwww.tuxed.net-e8c53a9efd4699d628b379a715a96beb9a016de3.zip
www.tuxed.net-e8c53a9efd4699d628b379a715a96beb9a016de3.tar.gz
www.tuxed.net-e8c53a9efd4699d628b379a715a96beb9a016de3.tar.xz
cleanup dependencies, directly use Twig now
Diffstat (limited to 'generate.php')
-rw-r--r--generate.php45
1 files changed, 9 insertions, 36 deletions
diff --git a/generate.php b/generate.php
index beb4f96..ce903ba 100644
--- a/generate.php
+++ b/generate.php
@@ -3,10 +3,6 @@
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__);
@@ -20,6 +16,10 @@ $blogAuthorTwitter = 'fkooman';
$blogAuthorGitHub = 'fkooman';
$blogAuthorMail = 'fkooman@tuxed.net';
+
+$loader = new Twig_Loader_Filesystem($templateDir);
+$twig = new Twig_Environment($loader);
+
$blogPosts = [];
foreach (glob(sprintf('%s/*.md', $postDir)) as $postFile) {
@@ -38,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);
@@ -65,9 +65,8 @@ usort($postsList, function ($a, $b) {
return strtotime($a['published']) < strtotime($b['published']);
});
-$tpl = new TwigTemplateManager([$templateDir]);
-$indexPage = $tpl->render(
- 'index',
+$indexPage = $twig->render(
+ 'index.twig',
[
'postsList' => $postsList,
'pageTitle' => 'Index',
@@ -80,21 +79,9 @@ $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',
+ $postPage = $twig->render(
+ 'post.twig',
[
'blogTitle' => $blogTitle,
'pageTitle' => $post['title'],
@@ -107,18 +94,6 @@ 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);
@@ -132,5 +107,3 @@ foreach (glob(__DIR__.'/img/*') as $imgFile) {
// copy css
@mkdir($outputDir.'/css');
copy(__DIR__.'/screen.css', $outputDir.'/css/screen.css');
-
-#file_put_contents($outputDir.'/feed.xml', $feed->render());