From b864379651d4bfe3d05f98350b720794ffa2806a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 31 Dec 2016 22:48:59 -0700 Subject: more --- .gitignore | 2 ++ Makefile | 40 +++++++++++++++++++++++++++++++++++----- bin/index | 4 +++- bin/index.atom.erb | 4 ++-- bin/index.md.erb | 19 ++++++------------- bin/page.html.erb | 8 +++++--- bin/util.rb | 39 +++++++++++++++++++++++++++++++++++++-- src/DND/DND.scss | 5 ----- src/DND/PsionicSchools.org | 1 + src/DND/Psionist.md | 3 ++- src/DND/SpellGauntlet.org | 3 ++- src/DND/Tastavi.md | 3 ++- src/main.scss | 12 +++++++++++- 13 files changed, 108 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index e4dbb38..6883828 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /out/ /www/ +.tmp* +.var* diff --git a/Makefile b/Makefile index 54f6d26..6c58b95 100644 --- a/Makefile +++ b/Makefile @@ -14,26 +14,56 @@ html.suffixes = md org # Find all source files with those suffixes html.src = $(shell find src -type f \( -false $(foreach s,$(html.suffixes), -o -name '*.$s' ) \)) # Translate the source filenames into output filenames -html.out = $(call patsubst-all,$(addprefix src/%.,$(html.suffixes)),out/%.html,$(html.src)) +html.out = $(call patsubst-all,$(addprefix src/%.,$(html.suffixes)),out/%.html,$(html.src)) +html.out += $(addsuffix index.html,$(sort $(dir $(patsubst src/%,out/%,$(html.src))))) + +mydir = $(patsubst %/,%,$(patsubst out/%,%,$(dir $@))) all: $(html.out) out/main.css out/DND/DND.css +.PHONY: all bin/page = bin/page bin/util.rb bin/pandoc.rb +bin/index = bin/index bin/util.rb bin/pandoc.rb out/%.html: src/%.md $(bin/page) bin/page.html.erb bin/write-atomic mkdir -p $(@D) bin/page html $< | bin/write-atomic $@ +out/%.html: out/%.md $(bin/page) bin/page.html.erb bin/write-atomic + bin/page html $< | bin/write-atomic $@ + out/%.html: src/%.org $(bin/page) bin/page.html.erb bin/write-atomic mkdir -p $(@D) bin/page html $< | bin/write-atomic $@ +out/%.html: out/%.org $(bin/page) bin/page.html.erb bin/write-atomic + bin/page html $< | bin/write-atomic $@ + out/%.css: src/%.scss mkdir -p $(@D) scss --stdin < $< > $@ +out/%.css: out/%.scss + scss --stdin < $< > $@ -#out/index.md : index index.md.erb .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic -# ./index md $(filter %.md,$^) | ./write-atomic $@ -#out/index.atom: index index.atom.erb .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic -# ./index atom $(filter %.md,$^) | ./write-atomic $@ +out/%/index.md : $(bin/index) bin/index.md.erb .var.html.src $(html.src) bin/write-atomic + bin/index md $(mydir) $(filter $(patsubst out/%,src/%,$(@D))/%,$^) | bin/write-atomic $@ +out/%/index.atom: $(bin/index) bin/index.atom.erb .var.html.src $(html.src) bin/write-atomic + bin/index atom $(mydir) $(filter $(patsubst out/%,src/%,$(@D))/%,$^) | bin/write-atomic $@ +www: + mkdir -p $@ + unionfs -o ro out:src www + +.var.%: FORCE bin/write-ifchanged + @printf '%s' $(call quote.shell,$($*)) | sed 's/^/#/' | bin/write-ifchanged $@ +-include $(wildcard .var.*) + +.PHONY: FORCE .DELETE_ON_ERROR: .SECONDARY: + +define nl + + +endef +# I put this as the last line in the file because it confuses Emacs syntax +# highlighting and makes the remainder of the file difficult to edit. +quote.shell = $(subst $(nl),'$$'\n'','$(subst ','\'',$1)') diff --git a/bin/index b/bin/index index 44cdc35..4f41c5d 100755 --- a/bin/index +++ b/bin/index @@ -2,13 +2,15 @@ # -*- coding: utf-8 -*- load 'util.rb' -template = "index.#{ARGV.shift}.erb" +template = "bin/index.#{ARGV.shift}.erb" +@path = ARGV.shift @pages = [] for filename in ARGV do @pages.push(Page.new(filename)) end + erb = ERB.new(File.read(template)); erb.filename = template erb.run() diff --git a/bin/index.atom.erb b/bin/index.atom.erb index a5e1586..7864e75 100644 --- a/bin/index.atom.erb +++ b/bin/index.atom.erb @@ -1,12 +1,12 @@ - Luke Shumaker's Web Log + AndrewDM.me <%= @path %> <%= @pages.map{|p|p.date}.sort.last.rfc3339 %> - <%= Person.new("Luke Shumaker").atom %> + <%= Person.new("Andrew Murrell").atom %> https://lukeshu.com/blog/ <% @pages.sort_by{|p| p.date}.reverse.each do |page| %> diff --git a/bin/index.md.erb b/bin/index.md.erb index 4da9a5d..392447e 100644 --- a/bin/index.md.erb +++ b/bin/index.md.erb @@ -1,13 +1,6 @@ -Web log entries -=============== - -<% @pages.sort_by{|p| p.date}.reverse.each do |a| %> - * - [<%= a.title %>](./<%= a.slug %>.html)<% end %> +--- +title: "<%= @path %>" +--- + +<% @pages.sort_by{|a|a.published}.each do |a| %> + * - [<%= a.title %>](./<%= a.slug %>.html) (last updated )<% end %> diff --git a/bin/page.html.erb b/bin/page.html.erb index a8e5154..694d11a 100644 --- a/bin/page.html.erb +++ b/bin/page.html.erb @@ -9,9 +9,8 @@
+

<%= @page.breadcrumbs %>

Andrew D. Murrell

-

<%= @page.breadcrumbs %> - (<%= File.extname(@page.src).upcase %>)

-

<%= @page.title %>

+ <% if @page.tags.count > 0 %>

Tags: <%= @page.tags.join(' ') %>

<% end %> + <% if @page.showtitle %>

<%= @page.title %>

<% end %> <%= @page.content %>
diff --git a/bin/util.rb b/bin/util.rb index d95ddba..ec604a3 100644 --- a/bin/util.rb +++ b/bin/util.rb @@ -2,6 +2,7 @@ load 'pandoc.rb' require 'erb' require 'date' +require 'set' $license_urls = { "CC BY-SA-3.0" => 'https://creativecommons.org/licenses/by-sa/3.0/', @@ -86,15 +87,49 @@ class Page end def title ; @title ||= pandoc['title'] || input.split("\n",2).first ; end + def showtitle ; @showtitle ||= ! pandoc['title'].nil? ; end + def author ; @author ||= Person.new( pandoc['author'] || "Andrew Murrell") ; end def license ; @license ||= License.new(pandoc['license'] || "CC BY-SA-3.0") ; end - def date ; @date ||= Date.parse(pandoc['date']) unless pandoc['date'].nil? ; end def slug ; @slug ||= infile.sub(/\..*$/,'').sub(/^.*\//,'') ; end def content ; @content ||= pandoc.to('html5 '+(pandoc['pandoc_flags']||'')) ; end def head ; @head ||= pandoc['html_head_extra'] ; end + def tags ; @tags ||= (pandoc['tags'] || '').split ; end + + def published + if @published.nil? + raw = pandoc['published'] + @published = Date.parse(raw) unless raw.nil? + end + if @published.nil? + raw = `git log -n1 --reverse --format='%cI' -- #{infile}` + @published = DateTime.iso8601(raw) unless raw.empty? + if !updated.nil? && updated < @published + @published = updated + end + end + @published + end + + def updated + if @updated.nil? + raw = pandoc['updated'] + @updated = Date.parse(raw) unless raw.nil? + end + if @updated.nil? + raw = `git log -n1 --format='%cI' -- #{infile}` + @updated = DateTime.iso8601(raw) unless raw.empty? + end + @updated + end def rights - @rights ||= "

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

\n" + + years = `git log --date=format:'%Y' --format='%cd' -- .config/login.sh`.split('\n').map{|s|s.to_i} + years.unshift(published.year) unless published.nil? + years.unshift(updated.year) unless updated.nil? + years = Set[*years] + # TODO: simplify year spans + @rights ||= "

The content of this page is Copyright © #{years.sort.join(', ')} #{author.html}.

\n" + "

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

" end diff --git a/src/DND/DND.scss b/src/DND/DND.scss index 1d4cc2a..fcb258c 100644 --- a/src/DND/DND.scss +++ b/src/DND/DND.scss @@ -48,11 +48,6 @@ textarea { overflow-x: auto; } } /* Andrew wrote the following */ -body > article { - padding: 0px 16%; - width: 68%; -} - body { background: url(Background.png) repeat-y; background-size: 100%; diff --git a/src/DND/PsionicSchools.org b/src/DND/PsionicSchools.org index 2ce8e7a..91f84a1 100644 --- a/src/DND/PsionicSchools.org +++ b/src/DND/PsionicSchools.org @@ -1,5 +1,6 @@ #+TITLE: Schools of Psionics #+HTML_HEAD_EXTRA: +#+TAGS: ES HB From what I've seen, the most recent few 5e Unearthed Arcana dealing with "Psionics and the Mystic" have been getting somewhat mixed diff --git a/src/DND/Psionist.md b/src/DND/Psionist.md index ea21a9f..1c7b9e5 100644 --- a/src/DND/Psionist.md +++ b/src/DND/Psionist.md @@ -1,7 +1,8 @@ --- title: "Psionist" -date: "2016-07-16T21:01-0400" +updated: "2016-07-16T21:01-0400" html_head_extra: "" +tags: ES HB ---
diff --git a/src/DND/SpellGauntlet.org b/src/DND/SpellGauntlet.org index c647c7d..cb97497 100644 --- a/src/DND/SpellGauntlet.org +++ b/src/DND/SpellGauntlet.org @@ -1,5 +1,6 @@ -#+TITLE: Spell Gauntlet +#+TITLE: Spell Gauntlet: Practical Spellcasting #+HTML_HEAD_EXTRA: +#+TAGS: FF SS WP * Teleport diff --git a/src/DND/Tastavi.md b/src/DND/Tastavi.md index 20f8520..0f7eb12 100644 --- a/src/DND/Tastavi.md +++ b/src/DND/Tastavi.md @@ -1,7 +1,8 @@ --- title: "Tastavi D'Maelnor of Llolethane" -date: "2016-08-30 Tue 23:56" +updated: "2016-08-30 Tue 23:56" html_head_extra: "" +tags: SS ---

diff --git a/src/main.scss b/src/main.scss index ab62e0a..53c5154 100644 --- a/src/main.scss +++ b/src/main.scss @@ -75,7 +75,10 @@ nav { } } -body > article { +article { + max-width: 6.5in; + margin: 0 auto; + #constructionBanner { height: 50px; background-color: #f89406; @@ -123,4 +126,11 @@ body > article { .HB { background: DimGray; } .DM { background: DarkSlateGray; } .WP { background: GhostWhite; color: black; } + + border-bottom: solid 1px #333333; +} + +footer { + margin: 0 2em; + font-size: smaller; } -- cgit v1.2.3