diff --git a/incorporealcms/pages.py b/incorporealcms/pages.py index 1d956b4..aae3364 100644 --- a/incorporealcms/pages.py +++ b/incorporealcms/pages.py @@ -58,7 +58,9 @@ def display_page(path): page_title = f'{page_name} - {app.config["TITLE_SUFFIX"]}' if page_name else app.config['TITLE_SUFFIX'] logger.debug("title (potentially derived): %s", page_title) - return render('base.html', title=page_title, description=get_meta_str(md, 'description'), + template = get_meta_str(md, 'template') if md.Meta.get('template') else 'base.html' + + return render(template, title=page_title, description=get_meta_str(md, 'description'), image=get_meta_str(md, 'image'), base_url=request.base_url, content=content, navs=parent_navs, mtime=mtime.strftime('%Y-%m-%d %H:%M:%S %Z')) else: diff --git a/incorporealcms/static/css/base.css b/incorporealcms/static/css/base.css index bbf425a..08998ad 100644 --- a/incorporealcms/static/css/base.css +++ b/incorporealcms/static/css/base.css @@ -19,6 +19,14 @@ body { margin-right: auto; } +.site-wrap-wide { + max-width: 95pc; + min-height: 100vh; + margin: 0; + margin-left: auto; + margin-right: auto; +} + h1 { font-size: 2em; } diff --git a/incorporealcms/templates/base-wide.html b/incorporealcms/templates/base-wide.html new file mode 100644 index 0000000..3e08b7b --- /dev/null +++ b/incorporealcms/templates/base-wide.html @@ -0,0 +1,38 @@ + + +{{ title }} +{% if title %}{% endif %} +{% if description %}{% endif %} +{% if image %}{% endif %} + + + + + + +
+ {% block header %} +
+ + +
+ {% endblock %} + {% block body %} +
+ {{ content }} +
+ + {% endblock %} +
+ diff --git a/tests/functional_tests.py b/tests/functional_tests.py index 714a5c4..6054990 100644 --- a/tests/functional_tests.py +++ b/tests/functional_tests.py @@ -193,3 +193,13 @@ def test_setting_selected_style_includes_cookie(client): assert b'dark.css' in response.data assert b'light.css' not in response.data assert style_cookie.value == 'dark' + + +def test_pages_can_supply_alternate_templates(client): + """Test that pages can supply templates other than the default.""" + response = client.get('/') + assert b'class="site-wrap"' in response.data + assert b'class="wide-site-wrap"' not in response.data + response = client.get('/custom-template') + assert b'class="site-wrap"' not in response.data + assert b'class="wide-site-wrap"' in response.data diff --git a/tests/instance/pages/custom-template.md b/tests/instance/pages/custom-template.md new file mode 100644 index 0000000..709952b --- /dev/null +++ b/tests/instance/pages/custom-template.md @@ -0,0 +1,3 @@ +Template: base-wide.html + +testttttttttt