summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-12-31 22:48:59 -0700
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-12-31 22:48:59 -0700
commitb864379651d4bfe3d05f98350b720794ffa2806a (patch)
treec4bc81a8371694d661b10118b4932480aaa37d0b
parent7445ea9d56071cfca247689e22c6fded65c3f968 (diff)
more
-rw-r--r--.gitignore2
-rw-r--r--Makefile40
-rwxr-xr-xbin/index4
-rw-r--r--bin/index.atom.erb4
-rw-r--r--bin/index.md.erb19
-rw-r--r--bin/page.html.erb8
-rw-r--r--bin/util.rb39
-rw-r--r--src/DND/DND.scss5
-rw-r--r--src/DND/PsionicSchools.org1
-rw-r--r--src/DND/Psionist.md3
-rw-r--r--src/DND/SpellGauntlet.org3
-rw-r--r--src/DND/Tastavi.md3
-rw-r--r--src/main.scss12
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 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
- <title>Luke Shumaker's Web Log</title>
+ <title>AndrewDM.me <%= @path %></title>
<link rel="self" type="application/atom+xml" href="./index.atom"/>
<link rel="alternate" type="text/html" href="./"/>
<link rel="alternate" type="text/markdown" href="./index.md"/>
<updated><%= @pages.map{|p|p.date}.sort.last.rfc3339 %></updated>
- <author><%= Person.new("Luke Shumaker").atom %></author>
+ <author><%= Person.new("Andrew Murrell").atom %></author>
<id>https://lukeshu.com/blog/</id>
<% @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
-===============
-<style>
-li {
- list-style-type: none;
-}
-time {
- color: #AAAAAA;
- font-family: monospace;
-}
-</style>
-<% @pages.sort_by{|p| p.date}.reverse.each do |a| %>
- * <time><%= a.date.strftime('%Y-%m-%d') %></time> - [<%= a.title %>](./<%= a.slug %>.html)<% end %>
+---
+title: "<%= @path %>"
+---
+
+<% @pages.sort_by{|a|a.published}.each do |a| %>
+ * <time><%= a.published.strftime('%Y-%m-%d') %></time> - [<%= a.title %>](./<%= a.slug %>.html) (last updated <time><%= a.updated.strftime('%Y-%m-%d') %></time>)<% 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 @@
</head>
<body>
<header>
+ <p><%= @page.breadcrumbs %></p>
<h1>Andrew D. Murrell</h1>
- <p><%= @page.breadcrumbs %>
- (<a href="<%= File.basename(@page.src) %>"><%= File.extname(@page.src).upcase %></a>)</p>
<nav>
<ul>
<li><a href="/">Projects</a>
@@ -25,11 +24,14 @@
</nav>
</header>
<article>
- <h1 class=title><%= @page.title %></h1>
+ <% if @page.tags.count > 0 %><p>Tags: <%= @page.tags.join(' ') %></p><% end %>
+ <% if @page.showtitle %><h1 class=title><%= @page.title %></h1><% end %>
<%= @page.content %>
</article>
<footer>
<%= @page.rights %>
+ <p>Page source: <a href="<%= File.basename(@page.src) %>"><%= File.basename(@page.src) %></a></p>
+ <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p>
</footer>
</body>
</html>
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 ||= "<p>The content of this page is Copyright © #{date.year unless date.nil?} #{author.html}.</p>\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 ||= "<p>The content of this page is Copyright © #{years.sort.join(', ')} #{author.html}.</p>\n" +
"<p>This page is licensed under the #{license.html} license.</p>"
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: <link rel="stylesheet" href="DND.css">
+#+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: "<link rel=stylesheet href=DND.css>"
+tags: ES HB
---
<div id="table-of-contents">
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: <link rel="stylesheet" href="DND.css">
+#+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: "<link rel=stylesheet href=DND.css>"
+tags: SS
---
<p>
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;
}