diff --git a/mews/quickstart.py b/mews/quickstart.py index 504ade4..0b1f488 100644 --- a/mews/quickstart.py +++ b/mews/quickstart.py @@ -41,13 +41,16 @@ DEFAULT_LANG = "en" THEME = "theme" # The plugin reads the allowed elements and attributes from the Mews DTD and -# brings every page inside that subset. It only touches files ending .xhtml, -# so everything has to be written out under that suffix. +# brings every page inside that subset. PLUGINS = ["pelican.plugins.mews"] -ARTICLE_URL = ARTICLE_SAVE_AS = "{{slug}}.xhtml" -PAGE_URL = PAGE_SAVE_AS = "{{slug}}.xhtml" -INDEX_SAVE_AS = "index.xhtml" +# This whole site is Mews, so its pages are plain .html: a server sends those +# as text/html, which section 7.1 asks for so a small markup error still shows +# as a page, and index.html is the directory index everywhere. The plugin +# defaults to .xhtml instead, for sites that are only partly Mews. +MEWS_SUFFIX = ".html" +ARTICLE_URL = ARTICLE_SAVE_AS = "{{slug}}.html" +PAGE_URL = PAGE_SAVE_AS = "{{slug}}.html" # Markdown has to produce XML for the plugin to parse. Tables and definition # lists are both in the Mews subset but need their extensions turned on. @@ -59,7 +62,11 @@ MARKDOWN = {{ }}, }} -# Mews pages carry no author styling, so there is nothing for these to show. +# Every page written under MEWS_SUFFIX goes through the plugin, and Pelican +# falls back to its own HTML templates for these when the theme has none. They +# have nothing to show on a site like this, so they stay off; give them +# templates in theme/templates/ if you want them. +DIRECT_TEMPLATES = ["index"] AUTHOR_SAVE_AS = CATEGORY_SAVE_AS = TAG_SAVE_AS = "" AUTHORS_SAVE_AS = CATEGORIES_SAVE_AS = TAGS_SAVE_AS = ARCHIVES_SAVE_AS = "" # Pelican writes several feeds by default and they are all broken until @@ -115,7 +122,7 @@ ARTICLE = """\ {% block content %}

{{ article.title }}

{{ article.content }} -

All posts

+

All posts

{% endblock %} """ @@ -125,7 +132,7 @@ PAGE = """\ {% block content %}

{{ page.title }}

{{ page.content }} -

All posts

+

All posts

{% endblock %} """ @@ -157,7 +164,8 @@ A Mews site. The pages follow [Mews Profile 0.1](https://mews.page/spec/0.1). uv run pelican content ``` -The finished pages land in `output/`. To work on it with a reload on save: +The finished pages land in `output/`, as plain `.html` that any web server +serves correctly with no configuration. To work on it with a reload on save: ```shell uv run pelican --autoreload --listen content @@ -165,12 +173,7 @@ uv run pelican --autoreload --listen content ## Publish it -Copy `output/` to any web server. Two things are worth setting: - -- Serve `.xhtml` files as `text/html`. Section 7.1 of the spec asks for that, - so a browser still shows a page carrying a small markup error. -- Make `index.xhtml` the directory index, since the plugin only processes - files under that suffix. In Caddy: `file_server {{ index index.xhtml }}`. +Copy `output/` to any web server. Nothing to configure. ## Subscribe to it diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index bebd20b..25c2446 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -35,9 +35,15 @@ def test_the_settings_are_valid_python(tmp_path): ) assert settings["SITENAME"] == "Signal Bars" assert settings["PLUGINS"] == ["pelican.plugins.mews"] - # The plugin only touches this suffix, so everything has to be saved under it. - assert settings["ARTICLE_SAVE_AS"].endswith(".xhtml") - assert settings["INDEX_SAVE_AS"].endswith(".xhtml") + # A site that is Mews throughout writes plain .html: servers send that as + # text/html (section 7.1) and index.html is the directory index everywhere. + # The suffix the plugin acts on has to agree with where pages are saved. + assert settings["MEWS_SUFFIX"] == ".html" + assert settings["ARTICLE_SAVE_AS"].endswith(".html") + assert settings["PAGE_SAVE_AS"].endswith(".html") + # Pelican falls back to its own HTML for any direct template the theme + # lacks, and with .html the plugin would choke on it. + assert settings["DIRECT_TEMPLATES"] == ["index"] assert settings["MARKDOWN"]["output_format"] == "xhtml" @@ -62,11 +68,11 @@ def test_the_scaffolded_site_builds_conforming_pages(tmp_path): check=False, ) assert built.returncode == 0, built.stderr - pages = sorted((site / "output").glob("*.xhtml")) - assert [p.name for p in pages] == ["first-post.xhtml", "index.xhtml"] + pages = sorted((site / "output").glob("*.html")) + assert [p.name for p in pages] == ["first-post.html", "index.html"] for page in pages: report = validate_file(str(page)) assert report.conforms, "\n".join(str(f) for f in report.failures) # Section 6.1: the index has to be subscribable. - index = (site / "output" / "index.xhtml").read_text() - assert '
  • ' in index + index = (site / "output" / "index.html").read_text() + assert '
  • ' in index