summaryrefslogtreecommitdiff
path: root/index.rb
blob: 61450d5d3af832b474adae121b1f9bea66318894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
load 'pandoc.rb'
require 'erb'
require 'date'

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)
	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