#!/usr/bin/env ruby # -*- coding: utf-8 -*- load 'pandoc.rb' require 'erb' require 'date' license_urls = { "CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/', 'WTFPL-2' => "http://www.wtfpl.net/txt/copying/", } author_urls = { "Luke Shumaker" => "mailto:lukeshu@sbcglobal.net", } template = 'template.erb' infile = ARGV.first Pandoc::prog='pandoc' input = File.read(infile) doc = Pandoc::load('markdown', input) if doc['markdown_options'] doc = Pandoc::load('markdown'+doc['markdown_options'], input) end @title = doc['title'] || input.split("\n",2).first @author = doc['author'] || "Luke Shumaker" @date = Date.parse(doc['date']) unless doc['date'].nil? @license = doc['license'] || "CC BY-SA-3.0" unless license_urls[@license].nil? @license="#{@license}" end unless author_urls[@author].nil? @author="#{@author}" end @breadcrumbs = 'Luke Shumaker » ' if (infile =~ /.*\/index(\..*)?/) @breadcrumbs += "blog" else @breadcrumbs += 'blog » ' + infile.sub(/\..*$/,'').sub(/^.*\//,'') end @content = doc.to('html5') erb = ERB.new(File.read(template)); erb.filename = template erb.run()