From 9e1666f4b6f924e9826f796b423a21958e749e77 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 13:17:41 -0500 Subject: ChangeLog: don't show a diffstat --- bin/auto-changelog | 2 +- src/changelog.md | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/bin/auto-changelog b/bin/auto-changelog index d672b5f..b374fda 100755 --- a/bin/auto-changelog +++ b/bin/auto-changelog @@ -14,7 +14,7 @@ should-insert() { } generate-entry() { - git log -n1 --stat --date='format:%Y-%m-%d' --format=$'## %ad %an <%ae>\n\n%B' | cat -s + git log -n1 --date='format:%Y-%m-%d' --format=$'## %ad %an <%ae>\n\n%B' | cat -s } html_escape() { diff --git a/src/changelog.md b/src/changelog.md index 87940b8..d4e1036 100644 --- a/src/changelog.md +++ b/src/changelog.md @@ -5,33 +5,18 @@ ChangeLog remove unfinished sources - src/dnd/psionist-class.md | 1504 ------------------------------- - src/dnd/{psionist2.org => psionist.org} | 0 - src/dnd/spell-gauntlet.org | 683 -------------- - 3 files changed, 2187 deletions(-) - ## 2017-01-14 Andrew Murrell <merl@neo.andrewdm.me> updated Psionist Title page - bin/pre-generate | 2 ++ - src/dnd/{Psionist2.org => psionist2.org} | 4 ++++ - 2 files changed, 6 insertions(+) - ## 2017-01-14 Andrew Murrell <merl@neo.andrewdm.me> Added an updated Psionist class with more complete domains, but no mind powers yet. - src/dnd/Psionist2.org | 566 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 566 insertions(+) - ## 2017-01-04 Luke Shumaker <lukeshu@lukeshu.com> Change the title of "Psionist" -> "Psionist Class [5e]" - src/dnd/Psionist.md | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ## 31 August 2016 Decided that the 1/5th of 'Magic is Magic' that was 'finished' was -- cgit v1.1-4-g5e80 From e8197dabd76b55f2c21e92c07fc7080d2db8d7df Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 13:20:32 -0500 Subject: index pages: sort by "most recently updated" instead of "publication order" --- lib/page_index.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/page_index.rb b/lib/page_index.rb index 585fd57..42c9e21 100644 --- a/lib/page_index.rb +++ b/lib/page_index.rb @@ -59,7 +59,7 @@ class IndexPage < LocalPage unless depth <= 1 ret += "
[#{atom_title}](#{cururl.route_to(url)})\n\n" end - for page in index_pages.select{|page|not page.is_a?(IndexPage)}.sort_by{|page|page.atom_published} + for page in index_pages.select{|page|not page.is_a?(IndexPage)}.sort_by{|page|page.atom_updated}.reverse ret += page.index_link(cururl, depth+1) end ret += "\n" -- cgit v1.1-4-g5e80 From 2214b9fa0cc8468b6a8c1e55b3642ede87862409 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 13:25:55 -0500 Subject: README: fix obvious mixup between "published" and "updated" --- README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 1b9491e..81ea619 100644 --- a/README.org +++ b/README.org @@ -98,8 +98,8 @@ generator: | html_head_extra | "" | Org-mode | string | | class | "" | no | string (CSS class to apply to ~~) | | categories[fn:2] | "" | no | string ("ES HB") or list (["ES", "HB"]) | -| published[fn:2] | most recent git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | -| updated[fn:2] | first git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | +| published[fn:2] | first git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | +| updated[fn:2] | most recent git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | [fn:1] We don't support lists of authors, though the Pandoc "standard" does. -- cgit v1.1-4-g5e80 From d5cf54c2a5650e70577ebdd9b07ae2bdb91bf104 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 13:26:35 -0500 Subject: README: reword sentence about not using Pandoc's "date" --- README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 81ea619..8870768 100644 --- a/README.org +++ b/README.org @@ -106,8 +106,8 @@ does. [fn:2] The "published"/"updated"/"categories" terminology is borrowed from the Atom specification (RFC 4287), and I intend them to have the -same semantics. For "published"/"updated", there is a "standard" -variable name is "date", but I thought that was dreadfully ambiguous +same semantics. For "published"/"updated", the Pandoc "standard" +variable name is "date"; but I thought that was dreadfully ambiguous and confusing when the site generator deals with two distinct dates. [fn:3] At various times there have been bugs in the YAML parser -- cgit v1.1-4-g5e80 From 3ca1e438fe602f3f03609ea6869b1de7a4091acc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 15:51:23 -0500 Subject: lib/sitegen: remove extra parens --- lib/sitegen.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sitegen.rb b/lib/sitegen.rb index 78222a3..4a3dd48 100644 --- a/lib/sitegen.rb +++ b/lib/sitegen.rb @@ -40,7 +40,7 @@ module Sitegen end @deps end - def self.Makefile() + def self.Makefile str = '' dependencies.each do |target, deps| str += "#{target.to_s}: #{deps.sort.join(' ')}\n" -- cgit v1.1-4-g5e80 From 4c3f03c1a7c622c3e92081664b42c96831b43dca Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 15:02:32 -0500 Subject: Let LocalPage::load decide how to handle different file types --- config.yaml | 1 - lib/page_index.rb | 6 ++++-- lib/page_local.rb | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 072ba80..05a31d2 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,4 @@ url: "https://www.andrewdm.me/" -html_suffixes: ["md", "org"] # Licenses default_license: "CC BY-SA-3.0" diff --git a/lib/page_index.rb b/lib/page_index.rb index 42c9e21..31d4682 100644 --- a/lib/page_index.rb +++ b/lib/page_index.rb @@ -28,13 +28,15 @@ class IndexPage < LocalPage @ls ||= Dir::entries(local_infile) .select{|fname|not fname.start_with?(".")} .map{|fname|"#{local_infile}/#{fname}"} - .select{|path|Dir::exist?(path) or Config::get.html_suffixes.include?(File::extname(path).gsub(/^[.]/, ''))} end def index_pages if @pages.nil? @pages = Set[] for path in _ls - @pages.add( Dir::exist?(path) ? IndexPage::new(path) : LocalPage::new(path) ) + page = LocalPage::load(path) + unless page.nil? + @pages.add(page) + end end for data in (_metadata['external'] || []) @pages.add(RemotePage::new(data)) diff --git a/lib/page_local.rb b/lib/page_local.rb index e13fa33..e956f6a 100644 --- a/lib/page_local.rb +++ b/lib/page_local.rb @@ -9,6 +9,18 @@ require 'pandoc' require 'person' class LocalPage < Page + def self.load(inpath) + case + when Dir::exist?(inpath) + require 'page_index' + return IndexPage::new(inpath) + when [".md", ".org"].include?(File::extname(inpath)) + return LocalPage::new(inpath) + else + return nil + end + end + def initialize(infile) @infile = infile super() -- cgit v1.1-4-g5e80 From 7c62b0a53c35f2cfce07469fb771ef0aa8f2302d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 21:31:25 -0500 Subject: README: revise the structure of the "Authoring pages" section. --- README.org | 52 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/README.org b/README.org index 8870768..e8a3542 100644 --- a/README.org +++ b/README.org @@ -54,20 +54,28 @@ Those dependencies are: * Authoring pages -Currently supported are Markdown (~.md~) and Org-mode (~.org~) files. -Each of these format supports embedding metadata in the document -(well, Markdown doesn't really, but the Pandoc syntax extension -~yaml_metadata_block~ adds it). +If you drop a file in the ~src/~ folder, the site generator will try +to turn it into usable HTML. The big caveat is that files *MUST* to +be in all lower case (this is to efficiently handle the requirement +that URLs be case-insensitive)! -In Org-mode, this looks like +Currently supported formats are: -#+BEGIN_SRC -#+KEY: value + - Markdown (~.md~) : converted with Pandoc + - Org-mode (~.org~) : converted with Pandoc -...rest of document... -#+END_SRC +I don't need to tell you how to make these types of files. -In Markdown, this looks like +In addition to the raw content of the files, you'll want/need to set +metadata about the page. Each of these format supports embedding +metadata in the document. + +** Setting metadata: Markdown + +Metadata for Markdown files can be set by adding a block of YAML at +the beginning of the document, terminated with "---". This isn't +"standard" markdown, but is a common syntax extension (Pandoc calls it +~yaml_metadata_block~). #+BEGIN_SRC --- @@ -79,16 +87,32 @@ key2: ...rest of document... #+END_SRC +Pandoc may make use of some of these metadata attributes internally +when converting to HTML. See the Pandoc documentation. + +** Setting metadata: Org-mode + +Metadata for Org-mode files can be set by adding ~#+KEY: value~ lines +at the beginning of the document. + +#+BEGIN_SRC +#+KEY: value + +...rest of document... +#+END_SRC + +Pandoc may make use of some of these metadata attributes internally +when converting to HTML. See the Org-mode and Pandoc documentation. + AFAIK, unfortunately Org-mode only has values as strings, no structured data. -Pandoc may make use of some of these values internally when converting -to HTML. See the Org-mode and Pandoc documentation. +** Metadata attributes that are handles specially -However, there are some of these that are used specially by the site +There are some metadata attributes that are used specially by the site generator: -| attribute | default | standard | format | +| attribute | default value | standard | format | |------------------+---------------------------------+----------+-------------------------------------------------| | title | the first line of the file | Pandoc | string | | author | ~config.yaml:default_author~ | Pandoc | string +or list+ [fn:1] | -- cgit v1.1-4-g5e80 From efbd3731c986a8555869c184cda69ff9b910ce9f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 15:52:22 -0500 Subject: pdf support --- Makefile | 12 +++++++++-- README.org | 16 ++++++++++++++ lib/page_local.rb | 3 +++ lib/page_pdf.rb | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.scss | 26 +++++++++++++++++++++++ tmpl/pdf.md.erb | 5 +++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 lib/page_pdf.rb create mode 100644 tmpl/pdf.md.erb diff --git a/Makefile b/Makefile index 96e0fdf..f61c4c3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ MAKEFLAGS += -j1 +pdfjs = https://github.com/mozilla/pdf.js/releases/download/v1.9.426/pdfjs-1.9.426-dist.zip + # Default target -all: out/index.html out/main.css +all: out/index.html out/main.css out/pdfjs phony += all # Boilerplate @@ -25,7 +27,13 @@ out/%.css: src/%.scss @mkdir -p $(@D) scss --stdin < $< > $@ -targets = $(phony) %.css +out/$(notdir $(pdfjs)): + wget -c --no-use-server-timestamp -O $@ $(pdfjs) +out/pdfjs: out/$(notdir $(pdfjs)) + rm -rf -- $@ + mkdir -- $@ && bsdtar -xf $(abspath $<) -C $@ --exclude '*.pdf' || { rm -rf -- $@; false; } + +targets = $(phony) %.css out/pdfjs% $(sort $(filter-out $(targets),out/index.html $(MAKECMDGOALS))): FORCE ./bin/sitegen diff --git a/README.org b/README.org index e8a3542..e95aff5 100644 --- a/README.org +++ b/README.org @@ -63,6 +63,7 @@ Currently supported formats are: - Markdown (~.md~) : converted with Pandoc - Org-mode (~.org~) : converted with Pandoc + - PDF (~.pdf~) : embedded with PDF.js I don't need to tell you how to make these types of files. @@ -107,6 +108,21 @@ when converting to HTML. See the Org-mode and Pandoc documentation. AFAIK, unfortunately Org-mode only has values as strings, no structured data. +** Setting metadata: PDF + +PDF files natively support embedding certain bits of metadata. The +bits that we use are: + + - title + - author + - creation date + - modification date + +If you need to set any other metadata attributes, or want to override +the values in the PDF (since setting them can be difficult), create +YAML file with the same name as the PDF file, but with the ~.yaml~ +file extension instead of ~.pdf~. + ** Metadata attributes that are handles specially There are some metadata attributes that are used specially by the site diff --git a/lib/page_local.rb b/lib/page_local.rb index e956f6a..6c70ac3 100644 --- a/lib/page_local.rb +++ b/lib/page_local.rb @@ -16,6 +16,9 @@ class LocalPage < Page return IndexPage::new(inpath) when [".md", ".org"].include?(File::extname(inpath)) return LocalPage::new(inpath) + when ".pdf" == File::extname(inpath) + require 'page_pdf' + return PdfPage::new(inpath) else return nil end diff --git a/lib/page_pdf.rb b/lib/page_pdf.rb new file mode 100644 index 0000000..e70c887 --- /dev/null +++ b/lib/page_pdf.rb @@ -0,0 +1,62 @@ +# coding: utf-8 +require 'erb' +require 'open3' +require 'yaml' + +require 'page_local' + +class PdfPage < LocalPage + def initialize(filename) + super(filename) + end + + def pdf_metadata + if @metadata.nil? + stdout, stderr, status = Open3::capture3("pdfinfo", "--", local_infile) + unless stderr.empty? + raise stderr + end + unless status.success? + raise status + end + raw_metadata = stdout.split("\n").map{|l|l.split(":", 2).map{|c|c.strip}}.to_h + + # Transform the PDF property names to match our metadata names + key_map = { + "Title" => "title", + "Author" => "author", + "CreationDate" => "published", + "ModDate" => "updated", + # "Keywords" => "categories", + } + @metadata = raw_metadata.map{|k,v|[key_map[k]||k,v]}.to_h + + yamlfile = local_infile.sub(/\.pdf$/, '.yaml') + if File::exist?(yamlfile) + @metadata = @metadata.merge(YAML::load(File::read(yamlfile))) + end + end + @metadata + end + def pdf_js_url + @@pdjfs ||= Config::get.url + 'pdfjs/web/viewer.html' + end + def pdf_viewer_url + @viewer_url ||= pdf_js_url + ('?file=' + URI::encode_www_form_component(pdf_js_url.route_to(local_srcurl))) + end + + def local_intype + return 'markdown' + end + def local_depends + if @depends.nil? + yamlfile = local_infile.sub(/\.pdf$/, '.yaml') + metafile = File::exist?(yamlfile) ? yamlfile : File::dirname(yamlfile) + tmplfile = "tmpl/pdf.md.erb" + @depends = super.map{|k,v|[k,v.merge([metafile, tmplfile])]}.to_h + end + @depends + end +end + +ERB::new(File::read("tmpl/pdf.md.erb")).def_method(PdfPage, 'local_input()', "tmpl/pdf.md.erb") diff --git a/src/main.scss b/src/main.scss index be00d49..cdbc200 100644 --- a/src/main.scss +++ b/src/main.scss @@ -287,3 +287,29 @@ body.dnd { font-weight:bold; } } } + +/* D&D-style pages ************************************************************/ + +body.pdf { + position: absolute; + width: 100%; + height: 100%; + bottom: 0; + + display: flex; + flex-direction: column; + + article { + flex-grow: 2; + padding: 0; + + h1 { + text-align: center; + margin: 0.25em 0; + } + iframe { + width: 100%; + height: 100%; + } + } +} diff --git a/tmpl/pdf.md.erb b/tmpl/pdf.md.erb new file mode 100644 index 0000000..2ce7327 --- /dev/null +++ b/tmpl/pdf.md.erb @@ -0,0 +1,5 @@ +<%= pdf_metadata.to_yaml %> +class: pdf +--- + + -- cgit v1.1-4-g5e80 From 29e0894d837d41697463ea4b1627469f072536a4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 15:52:30 -0500 Subject: Add Drew's Rules PDF --- src/dnd/drews_rules.pdf | Bin 0 -> 715540 bytes src/dnd/drews_rules.yaml | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 src/dnd/drews_rules.pdf create mode 100644 src/dnd/drews_rules.yaml diff --git a/src/dnd/drews_rules.pdf b/src/dnd/drews_rules.pdf new file mode 100644 index 0000000..65ffb89 Binary files /dev/null and b/src/dnd/drews_rules.pdf differ diff --git a/src/dnd/drews_rules.yaml b/src/dnd/drews_rules.yaml new file mode 100644 index 0000000..70a57e6 --- /dev/null +++ b/src/dnd/drews_rules.yaml @@ -0,0 +1,4 @@ +--- +author: "Andrew Murrell" +title: "Drew's Rules" +categories: "HB" -- cgit v1.1-4-g5e80 From bdb62265c5e0f8cbaa647479e10549f324e0712c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 21:40:58 -0500 Subject: CSS: Improve display of tags on PDF pages --- src/main.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.scss b/src/main.scss index cdbc200..fadd75b 100644 --- a/src/main.scss +++ b/src/main.scss @@ -303,6 +303,10 @@ body.pdf { flex-grow: 2; padding: 0; + p { + float: left; + margin: 0.25em -100% 0.25em 0.25em; + } h1 { text-align: center; margin: 0.25em 0; -- cgit v1.1-4-g5e80