From b373a3a6e1702e7514bb405122a2311d16d85fcd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 27 Aug 2016 17:36:46 -0400 Subject: Teach it to make atom:entry files --- pagerender.rb | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'pagerender.rb') diff --git a/pagerender.rb b/pagerender.rb index 67c5aab..3c122bc 100755 --- a/pagerender.rb +++ b/pagerender.rb @@ -1,21 +1,23 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- load 'pandoc.rb' +load 'util.rb' require 'erb' require 'date' -license_urls = { +$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", +$person_uris = { + "Luke Shumaker" => "https://lukeshu.com/", +} +$person_emails = { + "Luke Shumaker" => "lukeshu@sbcglobal.net", } -template = 'template.erb' -infile = ARGV.first - -Pandoc::prog='pandoc' +template = "template.#{ARGV[0]}.erb" +infile = ARGV[1] input = File.read(infile) doc = Pandoc::load('markdown', input) @@ -24,26 +26,25 @@ if doc['markdown_options'] doc = Pandoc::load('markdown'+doc['markdown_options'], input) end +gitdate = `git log -n1 --format='%cI' -- #{infile}` + @title = doc['title'] || input.split("\n",2).first -@author = doc['author'] || "Luke Shumaker" +@author = Person.new(doc['author'] || "Luke Shumaker") +@gitdate = DateTime.iso8601(gitdate) unless gitdate.empty? @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 +@license = License.new(doc['license'] || "CC BY-SA-3.0") +@slug = infile.sub(/\..*$/,'').sub(/^.*\//,'') +@content = doc.to('html5') +@rights = "

The content of this page is Copyright © #{@date.year unless @date.nil?} #{@author.html}.

\n" + + "

This page is licensed under the #{@license.html} license.

" @breadcrumbs = 'Luke Shumaker » ' -if (infile =~ /.*\/index(\..*)?/) +if (@slug == 'index') @breadcrumbs += "blog" else - @breadcrumbs += 'blog » ' + infile.sub(/\..*$/,'').sub(/^.*\//,'') + @breadcrumbs += 'blog » ' + @slug end -@content = doc.to('html5') - erb = ERB.new(File.read(template)); erb.filename = template erb.run() -- cgit v1.2.3