A Static Web Site

Terms defined: interpolation, shortcode, static site generator, template (for static site generator), theme (for static site generator)

Site Elements

"""Ark configuration file."""

title = "Snail Percolation"
data_dir = "data"

theme = "snails"
src_dir = "src"
out_dir = "docs"
extension = "/"

markdown_settings = {
    "extensions": [
        "markdown.extensions.extra",
        "markdown.extensions.smarty",
        "pymdownx.superfences",
    ]
}
This is the home page.
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="@root/style.css">
    <title>{{ site.title }}{% if node.title %}: {{ node.title }}{% endif %}</title>
  </head>
  <body>
    <div class="row">
      <div class="col-11">
    <h1>{{ site.title }}{% if node.title %}: {{ node.title }}{% endif %}</h1>
    {{ inc.menu }}
      </div>
      <div class="col-1">
    <p>
      <img src="@root/snail.svg" alt="Snail logo" width="80%" />
    </p>
      </div>
    </div>
{{ node.html }}
  </body>
</html>
---
title: Credits
---

-   Snail logo by [anarres](https://openclipart.org/artist/anarres)

Customizing

---
title: Analysis Results
---

[%csv 3fd8cbb7.csv %]
@shortcodes.register('csv')
def display_csv(pargs, kwargs, node):
    """Handle [%csv filename %] table inclusion."""
    assert len(pargs) == 1 and (not kwargs), f"Bad 'csv' shortcode with {pargs} and {kwargs} in {node}"
    filepath = Path(ark.site.config['data_dir'], pargs[0])
    assert filepath.exists(), f'CSV file {filepath} not found'
    with open(filepath, 'r') as raw:
        rows = [[val if val else '…' for val in row] for row in csv.reader(raw)]
    tbl = PrettyTable(header=False)
    tbl.add_rows(rows)
    return tbl.get_html_string()
screenshot of generated page
Figure 11.1: Generated page.