diff options
Diffstat (limited to 'repo/www')
| -rw-r--r-- | repo/www/Makefile | 7 | ||||
| -rwxr-xr-x | repo/www/generate-index.py | 12 | ||||
| -rwxr-xr-x | repo/www/generate-page.py | 5 |
3 files changed, 16 insertions, 8 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile index 9640fc4..d4392d1 100644 --- a/repo/www/Makefile +++ b/repo/www/Makefile @@ -53,7 +53,7 @@ $(pages) $(indices): $(html_template) $(pages): $(OUT_DIR)/%.html: $(call v,PAGE,$*) TEXT_FILES="$(TEXT_FILES)" \ ./generate-page.py --site-title="$$(cat $(title))" --title="$*" \ - $< $@ + --template=$(html_template) $< $@ top_index = $(OUT_DIR)/index.html subindices = $(filter-out $(top_index),$(indices)) @@ -64,8 +64,9 @@ $(subindices): index_options = --site-title="$$(cat $(title))" # ⚠ When tweaking this rule, check whether it still works for the # top-level index.html. $(indices): $(OUT_DIR)/%index.html: - $(call v,INDEX,$*) TEXT_FILES="$(TEXT_FILES)" \ - ./generate-index.py $(index_options) $(site_tree) "$(patsubst %/,%,$*)" $@ + $(call v,INDEX,$*) TEXT_FILES="$(TEXT_FILES)" \ + ./generate-index.py $(index_options) --template=$(html_template) \ + $(site_tree) "$(patsubst %/,%,$*)" $@ clean: -rm -r $(cache) diff --git a/repo/www/generate-index.py b/repo/www/generate-index.py index 5cd33a0..c51bf98 100755 --- a/repo/www/generate-index.py +++ b/repo/www/generate-index.py @@ -14,12 +14,15 @@ from helpers import deserialize_directories def parse_arguments(): parser = ArgumentParser() parser.add_argument( - 'site_tree', help='JSON file describing the page tree.' + '--template', help='Pandoc template for HTML output.' ) parser.add_argument( '--site-title', help='Prefix to add to <title>.' ) parser.add_argument( + 'site_tree', help='JSON file describing the page tree.' + ) + parser.add_argument( 'target', help='Subfolder to generate an index for.' ) parser.add_argument( @@ -96,10 +99,10 @@ def format_index(target, directories, files): return format_readme_index(intro, title, items) -def convert_page(content, output, site_title): +def convert_page(content, output, site_title, template): pandoc = ( 'pandoc', '-s', '--lua-filter', 'convert-internal-links.lua', - '--template', 'template.html', '-o', output + '--template', template, '-o', output ) if site_title is not None: pandoc += ('-T', site_title) @@ -110,7 +113,8 @@ def convert_page(content, output, site_title): def main(arguments): folders, files = list_files(arguments.site_tree, arguments.target) index_page = format_index(arguments.target, folders, files) - convert_page(index_page, arguments.output, arguments.site_title) + convert_page(index_page, arguments.output, arguments.site_title, + arguments.template) if __name__ == '__main__': diff --git a/repo/www/generate-page.py b/repo/www/generate-page.py index a8dd81d..9e0f57c 100755 --- a/repo/www/generate-page.py +++ b/repo/www/generate-page.py @@ -7,6 +7,9 @@ from subprocess import run def parse_arguments(): parser = ArgumentParser() parser.add_argument( + '--template', help='Pandoc template for HTML output.' + ) + parser.add_argument( '--site-title', help='Prefix to add to <title>.' ) parser.add_argument( @@ -25,7 +28,7 @@ def main(arguments): pandoc = ( 'pandoc', '-s', arguments.page, '-o', arguments.output, '--lua-filter', 'convert-internal-links.lua', - '--template', 'template.html', '-T', arguments.site_title, + '--template', arguments.template, '-T', arguments.site_title, '-M', f'title={arguments.title}' ) run(pandoc, check=True) |
