add the ability to specify the content license in the footer

e.g. for marking all pages as CC BY-SA 4.0

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
2026-02-24 09:58:30 -06:00
parent d22c3f84ac
commit bcb2b1be7e
2 changed files with 17 additions and 1 deletions

View File

@@ -44,7 +44,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
</div> </div>
<footer> <footer>
{% if extra_footer %}<div class="extra-footer"><i>{{ extra_footer|safe }}</i></div>{% endif %} {% if extra_footer %}<div class="extra-footer"><i>{{ extra_footer|safe }}</i></div>{% endif %}
<div class="footer"><i>Last modified: {{ mtime }}</i></div> <div class="footer">
<i>Last modified: {{ mtime }}.<br />
{% if config.LICENSE %} Available via {{ config.LICENSE|safe }}{% endif %}.
</i>
</div>
</footer> </footer>
{% endblock %} {% endblock %}
</div> </div>

View File

@@ -217,3 +217,15 @@ def test_index_in_source_link_is_stripped():
assert '<a href=".#anchor">Anchored This Index</a>' in content assert '<a href=".#anchor">Anchored This Index</a>' in content
assert '<a href="../">Parent</a>' in content assert '<a href="../">Parent</a>' in content
assert '<a href="../#anchor">Anchored Parent</a>' in content assert '<a href="../#anchor">Anchored Parent</a>' in content
def test_license_link():
"""Test that the config's license HTML is displayed in the footer."""
with patch('incorporealcms.Config.LICENSE',
'<a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>', create=True):
assert 'Available via <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.'\
in handle_markdown_file_path('index.md', PAGES_DIR)
# default, no config
assert '<a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>'\
not in handle_markdown_file_path('index.md', PAGES_DIR)