# coding: utf-8
load 'pandoc.rb'
require 'erb'
require 'date'
require 'set'
require 'uri'
$license_urls = {
"CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/',
'WTFPL-2' => "http://www.wtfpl.net/txt/copying/",
}
$person_uris = {
"Luke Shumaker" => "https://lukeshu.com/",
"Andrew Murrell" => "https://andrewdm.me/",
}
$person_emails = {
"Luke Shumaker" => "lukeshu@parabola.nu",
"Andrew Murrell" => "ImFromNASA@gmail.com",
}
$tag_names = {
"DM" => "DMing Resource",
"ES" => "Essay",
"FF" => "Flash Fiction",
"HB" => "Homebrew",
"SS" => "Short Story",
"WP" => "WIP",
}
$url = URI::parse('https://www.andrewdm.me')
class Tag
def initialize(abbr)
@abbr = abbr
end
def abbr
@abbr
end
def name
$tag_names[@abbr]
end
def html
return "#{name}"
end
end
class Person
def initialize(name)
@name = name
end
def name
@name
end
def uri
$person_uris[@name]
end
def email
$person_emails[@name]
end
def html
if not email.nil?
return "#{name}"
elsif not uri.nil?
return "#{name}"
else
return @name
end
end
def atom
ret = ""
ret += "
The content of this page is Copyright © #{years} #{author.html}.
\n" + "This page is licensed under the #{license.html} license.
" end def abssrcpath @srcpath ||= infile.sub(/^(src|out)\//, '/') end def absoutpath @outpath ||= abssrcpath.sub(/\.[^\/.]*$/, '.html').sub(/\/index[.]html$/, '') end def url @url ||= $url + absoutpath end def srcurl @srcurl ||= $url + abssrcpath end def breadcrumbs if @breadcrumbs.nil? bc = [] u = url.path u = "/" if u == "" while u != "/" bc.unshift("#{File.basename(u, File.extname(u))}") u = File.dirname(u) end bc.unshift("Andrew D. Murrell") @breadcrumbs = bc.join(' » ') end @breadcrumbs end end def html_escape(html) html .gsub('&', '&') .gsub('>', '>') .gsub('<', '<') end class ExternPage def initialize(metadata) @metadata = metadata end def title @metadata['title'] end def content nil end def tags if @tags.nil? raw = @metadata['tags'] || [] if raw.is_a?(String) raw = raw.split end @tags = raw.map{|tag|Tag.new(tag)} end return @tags end def url return $url + @metadata['url'] end def author Person.new(@metadata['author'] || "Andrew Murrell") end def published str = @metadata['published'] if str.nil? and ! @metadata['updated'].nil? str = @metadata['updated'] end return Date.parse(str) end def updated str = @metadata['updated'] if str.nil? and ! @metadata['published'].nil? str = @metadata['published'] end return Date.parse(str) end end