Web Tools

Tools for developing and maintaining Web site content for So Many Aircraft (or any other static Web site).

Source code: gitlab.com/somanyaircraft/webtools

Site Generator

The static site generator sitegen.py uses Jinja2 templating engine to generate static content. The Web site project root directory has the following hierarchy of directories:

The general process is that all files from templates/ are copied to public/ (with the directory structure preserved), with HTML and CSS files treated as Jinja2 templates and processed accordingly. The templates can refer to shared templates in assets/: reference @foo.html becomes assets/foo.html. All other files are simply copied (images, etc.).

Run sitegen.py with project root as the working directory. It is simple to set up your CI process un a way that will then replicate the contents of public/ for a Web server.

Note that Markdown files (extension .md) are also allowed. Those are by default rendered to HTML without the Jinja2 templating engine (and filenames changed to have the .html extension). If the directory assets/ contains a file "markdown-wrapper.html", it is assumed to be a Jinja2 template that gets rendered after the Markdown-to-HTML conversion; the resulting HTML from the Markdown conversion is available to the template as the variable contents. This feature makes it easy to provide some common boilerplate for your Markdown-based Web site.

Markdown metadata can be used to specify an alternate "wrapper" template. For example, this Markdown file

---
wrapper: fancy-wrapper.html
---
# Fancy stuff
...

will use the file assets/fancy-wrapper.html instead of the default one. Text between the triple-dashes is YAML-formatted Markdown metadata.

The shell script sitegen will invoke sitegen.py correctly using the virtual environment defined for this project. Note that sitegen accepts the option --refresh which causes your active Chrome tab to be reloaded upon successful' generation of content.

You can also pass the parameter --file=file where file is any file in the project, and sitegen will determine the correct root directory.

Test Server

The simple HTTP server testserv.py can be used to serve generated content locally from whatever site you are editing. The shell script testserv will invoke testserv.py correctly. The command takes the following command line parameters:

Upon launch, testserv attempts to open http://localhost:8800 (or whatever port you specified) in Chrome.


© 2025 So Many Aircraft. All Rights Reserved. (Content last modified: 2025-09-28T11:57:12)