From 0f03ad6f384aae74c117f074a20cea57f6261bf2 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 16 Sep 2022 13:31:43 -0500 Subject: [PATCH] allow pages to supply extra footer text --- incorporealcms/pages.py | 5 ++++- incorporealcms/static/css/base.css | 4 ++++ incorporealcms/templates/base.html | 3 ++- tests/functional_tests.py | 8 ++++++++ tests/instance/pages/index-but-with-footer.md | 6 ++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/instance/pages/index-but-with-footer.md diff --git a/incorporealcms/pages.py b/incorporealcms/pages.py index 26e3734..44707d6 100644 --- a/incorporealcms/pages.py +++ b/incorporealcms/pages.py @@ -76,6 +76,8 @@ def handle_markdown_file_path(resolved_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) + extra_footer = get_meta_str(md, 'footer') if md.Meta.get('footer') else None + template = get_meta_str(md, 'template') if md.Meta.get('template') else 'base.html' # check if this has a HTTP redirect @@ -86,7 +88,8 @@ def handle_markdown_file_path(resolved_path): 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')) + navs=parent_navs, mtime=mtime.strftime('%Y-%m-%d %H:%M:%S %Z'), + extra_footer=extra_footer) def request_path_to_instance_resource_path(path): diff --git a/incorporealcms/static/css/base.css b/incorporealcms/static/css/base.css index 192bf61..9fb63e1 100644 --- a/incorporealcms/static/css/base.css +++ b/incorporealcms/static/css/base.css @@ -72,6 +72,10 @@ footer { margin-top: 30px; } +.extra-footer { + margin-bottom: 5px; +} + table { border-collapse: collapse; } diff --git a/incorporealcms/templates/base.html b/incorporealcms/templates/base.html index f598a29..ef72497 100644 --- a/incorporealcms/templates/base.html +++ b/incorporealcms/templates/base.html @@ -31,7 +31,8 @@ {{ content }} {% endblock %} diff --git a/tests/functional_tests.py b/tests/functional_tests.py index 2b6a87f..f914be4 100644 --- a/tests/functional_tests.py +++ b/tests/functional_tests.py @@ -210,3 +210,11 @@ def test_pages_can_supply_alternate_templates(client): response = client.get('/custom-template') assert b'class="site-wrap site-wrap-normal-width"' not in response.data assert b'class="site-wrap site-wrap-double-width"' in response.data + + +def test_extra_footer_per_page(client): + """Test that we don't include the extra-footer if there isn't one (or do if there is).""" + response = client.get('/') + assert b'