From 6a42c8de66e3b2dc7293ddeadaa3ee396db2624d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 12 Oct 2013 13:47:42 -0400 Subject: initial commit --- pagerender.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 pagerender.rb (limited to 'pagerender.rb') diff --git a/pagerender.rb b/pagerender.rb new file mode 100755 index 0000000..4e6f887 --- /dev/null +++ b/pagerender.rb @@ -0,0 +1,37 @@ +#!/usr/bin/env ruby +require 'rdiscount' +require 'erb' + +license_urls = { + "CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/', + 'WTFPL-2' => "http://www.wtfpl.net/txt/copying/", +} + +template = 'template.erb' +input = ARGV.first + +lines = File.read(input).split("\n") + +markdown = '' +tags = {} +for line in lines do + if (line =~ /^:/) + (key, val) = line.sub(/^:/, '').split(/\s+/, 2) + tags[key] = val + else + markdown += "\n"+line + end +end + +@title = tags['title'] || lines.first +@copyright = tags['copyright'] || "Luke Shumaker" +@license = tags['license'] || "CC BY-SA-3.0" +unless license_urls[@license].nil? + @license="#{@license}" +end + +@content = RDiscount.new(markdown).to_html + +erb = ERB.new(File.read(template)); +erb.filename = template +erb.run() -- cgit v1.2.3