diff options
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | index.rb | 29 |
2 files changed, 25 insertions, 6 deletions
@@ -8,6 +8,6 @@ all: public/index.html $(addsuffix .html,$(articles)) public/%.html: public/%.md pagerender.rb template.erb Makefile ./pagerender.rb $< > $@ public/index.md: $(addsuffix .md,$(articles)) index.rb Makefile - ./index.rb $(sort $(filter-out Makefile index.rb public/index.md,$^)) > $@ + ./index.rb $(filter-out Makefile index.rb public/index.md,$^) > $@ clean: rm -f -- public/*.html public/index.md @@ -2,12 +2,31 @@ # -*- coding: utf-8 -*- load 'pandoc.rb' require 'erb' +require 'date' -markdown = "Web log entries\n=====\n\n" +puts "Web log entries\n=====\n" + +puts '<style> +li { + list-style-type: none; +} +time { + color: #AAAAAA; + font-family: monospace; +} +</style>' + +articles = [] for filename in ARGV do input = File.read(filename) - title = Pandoc::load('markdown',input)["title"] || input.split("\n",2).first - slug = filename.sub(/^public\//,'').sub(/\.md$/,'') - markdown += " * [`#{slug}`](./#{slug}.html) — #{title}\n" + doc = Pandoc::load('markdown',input) + articles.push({ + :title => doc["title"] || input.split("\n",2).first, + :date => Date.parse(doc['date']), + :slug => filename.sub(/^public\//,'').sub(/\.md$/,''), + }) +end + +articles.sort_by{|a| a[:date]}.reverse.each do |a| + puts " * <time>#{a[:date].strftime('%Y-%m-%d')}</time> - [#{a[:title]}](./#{a[:slug]}.html)" end -puts markdown |