summaryrefslogtreecommitdiff
path: root/repo
diff options
context:
space:
mode:
Diffstat (limited to 'repo')
-rw-r--r--repo/www/Makefile15
-rw-r--r--repo/www/print-title.lua26
2 files changed, 36 insertions, 5 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile
index fb933c8..c236936 100644
--- a/repo/www/Makefile
+++ b/repo/www/Makefile
@@ -1,24 +1,27 @@
TOP_DIR = ../..
OUT_DIR = $(TOP_DIR)/public
TEXT_FILES = md org
-# make does not care about unpaired single quotes (nor double quotes
-# for that matter) but Emacs does. Shell out.
-TITLE = $(shell echo "peniblec's memleaks")
dirname = $(patsubst %/,%,$(dir $(1)))
dirnames = $(sort $(call dirname,$(1)))
text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)')
text_folders = $(call dirnames,$(shell git ls-files $(text_patterns)))
+top_readme = $(shell git ls-files $(addprefix $(TOP_DIR)/README.,$(TEXT_FILES)))
all: site
cache = .cache
+# Site title, parsed from the top-level README.
+title = $(cache)/title
# Maps folders to their contents (files and subfolders).
site_tree = $(cache)/site-tree.json
# Defines $(pages) and $(indices).
dependencies = $(cache)/deps.mk
+$(title): $(top_readme) | $(cache)
+ pandoc --lua-filter print-title.lua $< > $@
+
$(site_tree): $(text_folders) | $(cache)
./generate-tree.py -o $@ $(TEXT_FILES)
@@ -37,13 +40,15 @@ html_folders = $(call dirnames,$(pages) $(indices))
$(html_folders) $(cache):
mkdir -p $@
+$(pages) $(indices): $(title)
+
$(pages): $(OUT_DIR)/%.html:
- pandoc -s $< -o $@ -T "$(TITLE)" -M title="$*"
+ pandoc -s $< -o $@ -T "$$(cat $(title))" -M title="$*"
# ⚠ When tweaking this rule, check whether it still works for the
# top-level index.html.
$(indices): $(OUT_DIR)/%index.html:
- ./generate-index.py $(site_tree) "$(TITLE)" "$(patsubst %/,%,$*)" $@
+ ./generate-index.py $(site_tree) "$$(cat $(title))" "$(patsubst %/,%,$*)" $@
clean:
-rm $(dependencies)
diff --git a/repo/www/print-title.lua b/repo/www/print-title.lua
new file mode 100644
index 0000000..c2c90fb
--- /dev/null
+++ b/repo/www/print-title.lua
@@ -0,0 +1,26 @@
+title = ''
+
+titlefilter = {
+ Str = function (element)
+ title = title .. element.text
+ end,
+
+ Code = function (element)
+ title = title .. element.text
+ end,
+
+ Space = function (element)
+ title = title .. ' '
+ end,
+}
+
+function Pandoc(doc)
+ pandoc.List.map(
+ doc.meta.title,
+ function (inline)
+ pandoc.walk_inline(pandoc.Span(inline), titlefilter)
+ end
+ )
+ print(title)
+ os.exit(0)
+end