memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

commit 8692dba921531783b9204a9323db2aba640fe978
parent 3a18562cad4b0fb144b637037ee676bafaaa3632
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Mon, 20 Apr 2020 00:03:16 +0200

Parse site title from top-level README

Maybe not the best idea, since the dependency chain will trigger a
site-wide rebuild everytime the README is edited.  Ah well.

Diffstat:
Mrepo/www/Makefile | 15++++++++++-----
Arepo/www/print-title.lua | 26++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 5 deletions(-)

diff --git 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 @@ -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