diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | HACKING.md | 14 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | README.org | 97 | ||||
-rw-r--r-- | TODO.org | 34 | ||||
-rwxr-xr-x | bin/post-commit | 49 | ||||
-rw-r--r-- | bin/util.rb | 21 | ||||
-rw-r--r-- | nginx.conf.example | 14 | ||||
-rw-r--r-- | out/Andrew.html | 2 | ||||
-rw-r--r-- | out/DND/PsionicSchools.html | 2 | ||||
-rw-r--r-- | out/DND/Psionist.html | 2 | ||||
-rw-r--r-- | out/DND/SpellGauntlet.html | 2 | ||||
-rw-r--r-- | out/DND/Tastavi.html | 2 | ||||
-rw-r--r-- | out/DND/index.atom | 8 | ||||
-rw-r--r-- | out/index.atom | 10 | ||||
-rw-r--r-- | src/missing.txt | 12 |
17 files changed, 209 insertions, 73 deletions
@@ -2,5 +2,4 @@ /www/ .tmp* .var* - !/out/ diff --git a/HACKING.md b/HACKING.md deleted file mode 100644 index a21b577..0000000 --- a/HACKING.md +++ /dev/null @@ -1,14 +0,0 @@ -Here's the gist: - - /src/ : website content - /bin/ : programs and such for generating the website from /src/ - /out/ : where the generated output goes - Makefile : invoke /bin/ as appropriate - git-setup : set up git hooks (see below) - benchmark : see which files take longer to generate - -The web server should serve the union of /src/ and /out/. - -On `master`, /out/ is ignored. But `git-setup` will set up a git -post-commit hook to generate /out/, and commit it to the -`pre-generated` branch. @@ -52,9 +52,10 @@ out/index.atom : $(bin/index) bin/index.atom.erb .var.html.src $(html.src) bin/ 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: FORCE - @mkdir -p $@ - unionfs -o ro out:src www +serve: serve-8000 +serve-%: all + dir=$$(mktemp -d -t) && trap 'fusermount -u "$$dir"; rmdir "$$dir"' EXIT && unionfs -o ro out:src "$$dir" && (cd "$$dir" && python3 -m http.server $*) +.PHONY: serve serve-% .var.%: FORCE bin/write-ifchanged @printf '%s' $(call quote.shell,$($*)) | sed 's/^/#/' | bin/write-ifchanged $@ diff --git a/README.md b/README.md deleted file mode 100644 index d53fbc5..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Dependencies: - - GNU Make - - Ruby - - Pandoc 1.17+ - - scss diff --git a/README.org b/README.org new file mode 100644 index 0000000..d373438 --- /dev/null +++ b/README.org @@ -0,0 +1,97 @@ +* Directory layout + +Here's the gist: + + - ~/src/~ : website content + - ~/bin/~ : programs and such for generating the website from ~/src/~ + - ~/out/~ : where the generated output goes + - ~/Makefile~ : invoke ~/bin/~ as appropriate + - ~/git-setup~ : set up git hooks (see below) + - ~/benchmark~ : runs ~make~ and reports how long each part took + +The web server should serve the union of ~/src/~ and ~/out/~. + +On the ~master~ branch, ~/out/~ is ignored. But ~git-setup~ will set +up a git post-commit hook to generate ~/out/~ and commit it to the +~pre-generated~ branch. + +* Document metadata + +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). + +In Org-mode, this looks like + +#+BEGIN_SRC +#+KEY: value + +...rest of document... +#+END_SRC + +In Markdown, this looks like + +#+BEGIN_SRC +--- +key: value +key2: + - any YAML values +--- + +...rest of document... +#+END_SRC + +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. + +However, there are some of these that are used specially by the site +generator: + +| attribute | default | standard | format | +|-----------------+---------------------------------+--------------------+--------------------------------------------| +| title | the first line of the file | Pandoc | string | +| author | "Andrew Murrell" | Pandoc | string or list | +| license | "CC BY-SA-3.0" | no | string | +| pandoc_flags | "" | no | string ("--foo --bar") | +| pandoc_format | either "markdown" or "org" | no | string ("markdown+extnsn1+extnsns2") | +| html_head_extra | "" | Org-mode | string | +| tags | "" | LaTeX, kinda[fn:1] | string ("ES HB") or list (["ES", "HB"]) | +| published[fn:2] | most recent git commit for file | no | string (Ruby ~Date.parse()~) or date[fn:3] | +| updated[fn:2] | first git commit for file | no | string (Ruby ~Date.parse()~) or date[fn:3] | + +[fn:1] The ~tags~ attribute is normally a list, but because I don't +know how to do a list in Org-mode, I made it take a +whitespace-separated string as well. + +[fn:2] The "published"/"updated" terminology is borrowed from the Atom +specification (RFC 4287), and I intend them to have the same +semantics. The "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 +library that Pandoc uses, causing it to fail to parse dates, so I just +always put the date in quotes now, and let Ruby ~Date.parse()~ take +care of it. + +* Make targets + + - ~all~ (default) : generate all generated files + - ~serve~ : alias for ~serve-8000~ + - ~serve-PORTNUMBER~ : Run an HTTP server on PORTNUMBER. Search + won't work. + +* Make dependencies + + - ~all~ + - GNU Make + - Ruby + - Pandoc 1.17+ + - scss + - ~serve-%~ (in addition to what is needed for ~all~) + - unionfs + - python3 diff --git a/TODO.org b/TODO.org new file mode 100644 index 0000000..7e30423 --- /dev/null +++ b/TODO.org @@ -0,0 +1,34 @@ +* functionality +- search +- tag filtering +- changelog (blog) +- index.ext.txt +- categories (writing/programming/dnd) +* issues +- Andrew Murrel -> AndrewDM +* wish +- case insenstive URLs +* style +- org tables +- alignment (justify) +- external link (and wiki-style icon!) +- move breadcrumbs +- single-space footer (and possible box) +- tags on right +- no bullets on indexes +- make dates hover text +* docs +- document #+ headers +* missing +Writing/Programming "section"s + + addItem("Writing", + mkItem("http://365tomorrows.com/12/03/a-simple-lament/", + "365 Tomorrows: A Simple Lament", + [["FF", "Flash Fiction"]])); + + addItem("Programming", + mkItem("./DND/WaterdeepBazaar/WaterdeepBazaar.html", + "Waterdeep Bazaar: Marketplace Generator", + [["DM", "DMing Resource"], + ["WP", "WIP"]])); diff --git a/bin/post-commit b/bin/post-commit index 6b72bd2..489181f 100755 --- a/bin/post-commit +++ b/bin/post-commit @@ -1,25 +1,38 @@ #!/usr/bin/env bash +# Copyright 2016-2017 Luke Shumaker +set -e -branch=$(git name-rev --name-only HEAD) -if [[ $branch == master ]]; then +main() { + branch=$(git name-rev --name-only HEAD) + if [[ $branch == master ]]; then + gitdir="$(git rev-parse --git-dir)" + workdir="${gitdir}/pre-generated" + exec 8>"${workdir}.lock" + flock 8 - stash=false - if [[ -n "$(git status --porcelain)" ]]; then - stash=true - git add . - git stash - fi + rm -rf -- "$workdir" + git worktree prune + git branch -D pre-generated.tmp &>/dev/null || true + + git worktree add -b pre-generated.tmp "${gitdir}/pre-generated" master + ( + unset GIT_DIR GIT_WORK_TREE + cd "$workdir" + msg="$(git log -n1 master --pretty=format:%B)" - git checkout pre-generated - git merge master -m 'bogus' - rm -rf out - make --always-make -j12 - git add . - git commit --amend -m "make: $(git log -n1 master --pretty=format:%B)" - git checkout master + make -j1 + echo '!/out/' >> .gitignore - if $stash; then - git stash pop + git add . + git commit -m "make: $msg" + git merge --no-edit -s ours pre-generated + git checkout pre-generated + git merge pre-generated.tmp + git branch -d pre-generated.tmp + ) + rm -rf -- "$workdir" + git worktree prune fi +} -fi +main &>/dev/tty & diff --git a/bin/util.rb b/bin/util.rb index 7b4805f..6ea3967 100644 --- a/bin/util.rb +++ b/bin/util.rb @@ -148,12 +148,21 @@ class Page end def rights - 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" + + if published.nil? || updated.nil? + years = '' + else + first = published.year + last = updated.year + + years = `git log --date=format:'%Y' --format='%cd' -- .config/login.sh`.split('\n').map{|s|s.to_i} + years.unshift(first) + years.unshift(last) + + # Remove dups and git years outside of [first,last] + # TODO: simplify year spans + years = Set[*years.select{|i|i > first && i < last}].sort.join(', ') + end + @rights ||= "<p>The content of this page is Copyright © #{years} #{author.html}.</p>\n" + "<p>This page is licensed under the #{license.html} license.</p>" end diff --git a/nginx.conf.example b/nginx.conf.example new file mode 100644 index 0000000..71a6b27 --- /dev/null +++ b/nginx.conf.example @@ -0,0 +1,14 @@ +# -*- mode: nginx; nginx-indent-level: 8; intent-tabs-mode: t -*- + +server { + server_name www.andrewdm.me; + listen 443 ssl http2; + listen [::]:443 ssl http2; + + location / { + try_files /out$uri/index.html /out$uri /src$uri =404; + } + location /search.html { + return 302 https://duckduckgo.com/?q=site:$host+$arg_s; + } +} diff --git a/out/Andrew.html b/out/Andrew.html index 7a7f972..70e67d4 100644 --- a/out/Andrew.html +++ b/out/Andrew.html @@ -32,7 +32,7 @@ </article> <footer> - <p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p> <p>Page source: <a href="Andrew.md">Andrew.md</a></p> <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p> diff --git a/out/DND/PsionicSchools.html b/out/DND/PsionicSchools.html index 9b13bad..50dc51e 100644 --- a/out/DND/PsionicSchools.html +++ b/out/DND/PsionicSchools.html @@ -100,7 +100,7 @@ </article> <footer> - <p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p> <p>Page source: <a href="PsionicSchools.org">PsionicSchools.org</a></p> <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p> diff --git a/out/DND/Psionist.html b/out/DND/Psionist.html index 556928d..50ecc04 100644 --- a/out/DND/Psionist.html +++ b/out/DND/Psionist.html @@ -2520,7 +2520,7 @@ Footnotes: </article> <footer> - <p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p> <p>Page source: <a href="Psionist.md">Psionist.md</a></p> <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p> diff --git a/out/DND/SpellGauntlet.html b/out/DND/SpellGauntlet.html index 1279f62..fb1a067 100644 --- a/out/DND/SpellGauntlet.html +++ b/out/DND/SpellGauntlet.html @@ -203,7 +203,7 @@ </article> <footer> - <p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p> <p>Page source: <a href="SpellGauntlet.org">SpellGauntlet.org</a></p> <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p> diff --git a/out/DND/Tastavi.html b/out/DND/Tastavi.html index 688887b..f6f18bc 100644 --- a/out/DND/Tastavi.html +++ b/out/DND/Tastavi.html @@ -1390,7 +1390,7 @@ He lay upon the ground thinking it maybe better he have died quickly in the tunn </article> <footer> - <p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p> <p>Page source: <a href="Tastavi.md">Tastavi.md</a></p> <p>Website source: <a href="https://git.andrewdm.me/www.git">www.git</a></p> diff --git a/out/DND/index.atom b/out/DND/index.atom index c71b0b1..046d086 100644 --- a/out/DND/index.atom +++ b/out/DND/index.atom @@ -90,7 +90,7 @@ <p>I'm actually working on an entire Psionist class for eventual publication on the Dungeon Master's Guild (or as part of my &quot;MagnumOpis-MagicOfTheMultiverse&quot; which covers EVERYTHING magical as I understand it). Of course if somebody #wotcstaff wants to buy it and/or hire me, I'd be totally up for #theorycrafting for a living.</p> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -277,7 +277,7 @@ <p>Faust and the Fugue Plane -Andrew Murrell</p> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -1651,7 +1651,7 @@ He lay upon the ground thinking it maybe better he have died quickly in the tunn </div> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -4155,7 +4155,7 @@ Footnotes: </div> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> diff --git a/out/index.atom b/out/index.atom index f3c94c9..26acae9 100644 --- a/out/index.atom +++ b/out/index.atom @@ -90,7 +90,7 @@ <p>I'm actually working on an entire Psionist class for eventual publication on the Dungeon Master's Guild (or as part of my &quot;MagnumOpis-MagicOfTheMultiverse&quot; which covers EVERYTHING magical as I understand it). Of course if somebody #wotcstaff wants to buy it and/or hire me, I'd be totally up for #theorycrafting for a living.</p> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -277,7 +277,7 @@ <p>Faust and the Fugue Plane -Andrew Murrell</p> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -293,7 +293,7 @@ <p>Though I hold a degree in Physics, am currently working as a manager and editor at a small tech firm. I write, mostly to teach my players about the whatever they want to know about the Forgotten Realms, but also because I think stories make the world a better place. I can be contacted at ImFromNASA@gmail.com and would love to hear from you!</p> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -1667,7 +1667,7 @@ He lay upon the ground thinking it maybe better he have died quickly in the tunn </div> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> @@ -4171,7 +4171,7 @@ Footnotes: </div> </content> <author><name>Andrew Murrell</name><uri>https://andrewdm.me/</uri><email>ImFromNASA@gmail.com</email></author> - <rights type="html"><p>The content of this page is Copyright © 2016 <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> + <rights type="html"><p>The content of this page is Copyright © <a href="mailto:ImFromNASA@gmail.com">Andrew Murrell</a>.</p> <p>This page is licensed under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA-3.0</a> license.</p></rights> </entry> diff --git a/src/missing.txt b/src/missing.txt deleted file mode 100644 index 67de762..0000000 --- a/src/missing.txt +++ /dev/null @@ -1,12 +0,0 @@ -Writing/Programming "section"s - - addItem("Writing", - mkItem("http://365tomorrows.com/12/03/a-simple-lament/", - "365 Tomorrows: A Simple Lament", - [["FF", "Flash Fiction"]])); - - addItem("Programming", - mkItem("./DND/WaterdeepBazaar/WaterdeepBazaar.html", - "Waterdeep Bazaar: Marketplace Generator", - [["DM", "DMing Resource"], - ["WP", "WIP"]])); |