diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-14 00:41:06 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-14 00:41:06 +0100 |
| commit | 81573058cac79f366755ddce5bd7dcfb55828644 (patch) | |
| tree | f60f5399a463e186cd1bb58706d5605982922aab /repo | |
| parent | 7866bb3c174b464740132146f0aa7d46d28ae0a3 (diff) | |
| download | memory-leaks-81573058cac79f366755ddce5bd7dcfb55828644.tar.xz | |
Add rudimentary webizer scripts
Diffstat (limited to 'repo')
| -rw-r--r-- | repo/www/.gitignore | 1 | ||||
| -rw-r--r-- | repo/www/Makefile | 20 | ||||
| -rw-r--r-- | repo/www/TODO | 5 | ||||
| -rwxr-xr-x | repo/www/make-deps.py | 56 |
4 files changed, 82 insertions, 0 deletions
diff --git a/repo/www/.gitignore b/repo/www/.gitignore new file mode 100644 index 0000000..b921cf0 --- /dev/null +++ b/repo/www/.gitignore @@ -0,0 +1 @@ +deps.mk
\ No newline at end of file diff --git a/repo/www/Makefile b/repo/www/Makefile new file mode 100644 index 0000000..7ae0e5e --- /dev/null +++ b/repo/www/Makefile @@ -0,0 +1,20 @@ +TOP_DIR = ../.. +OUT_DIR = $(TOP_DIR)/public + +all: site + +include deps.mk + +deps.mk: make-deps.py + python3 $< $(TOP_DIR) $(OUT_DIR) + +site: $(pages) + +$(folders): + mkdir -p $@ + +%.html: + pandoc -s $< -o $@ + +clean: + -rm -r $(OUT_DIR) diff --git a/repo/www/TODO b/repo/www/TODO new file mode 100644 index 0000000..d8e68dc --- /dev/null +++ b/repo/www/TODO @@ -0,0 +1,5 @@ +- READMEs ⇒ index.html +- "leak count" on toplevel index +- autogenerated index.html's for subfolders lacking READMEs +- stylin' + - tufte css? at least sidenotes rather than footnotes diff --git a/repo/www/make-deps.py b/repo/www/make-deps.py new file mode 100755 index 0000000..d6720e5 --- /dev/null +++ b/repo/www/make-deps.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +from os import path +from subprocess import run +from sys import argv, exit + + +def parse_arguments(args): + if len(args) != 3: + exit(f'Usage: {argv[0]} TOP-DIR OUTPUT-DIR') + + return argv[1], argv[2] + + +def find_sources(top_dir): + p = run( + ('find', top_dir, '-name', '*.md', '-o', '-name', '*.org'), + capture_output=True, check=True, text=True + ) + + return p.stdout.splitlines() + + +def html_path(source_path, top_dir, out_dir): + _, ext = path.splitext(source_path) + return source_path.replace(top_dir, out_dir).replace(ext, '.html') + + +def write_dependencies(output, sources, top_dir, out_dir): + pages = [] + directories = set() + + for src in sources: + html = html_path(src, top_dir, out_dir) + html_dir = path.dirname(html) + + print(f'{html}: {src} | {html_dir}', file=output) + + pages.append(html) + directories.add(html_dir) + + print(file=output) + print(f'pages = {" ".join(pages)}', file=output) + print(f'folders = {" ".join(directories)}', file=output) + + +def main(argv): + top_dir, out_dir = parse_arguments(argv) + source_files = find_sources(top_dir) + + with open('deps.mk', 'w') as deps: + write_dependencies(deps, source_files, top_dir, out_dir) + + +if __name__ == '__main__': + main(argv) |
