From c9f2f394d46559f32369737f1a9f1921acfd93a6 Mon Sep 17 00:00:00 2001 From: Bart Feenstra Date: Tue, 5 May 2020 10:40:52 +0100 Subject: [PATCH 1/5] Generate resources based on template directories. --- betty/assets/templates/page/list-file.html.j2 | 7 - .../event/index.html.j2} | 5 +- .../resource-list/event/index.json.j2 | 0 .../person/index.html.j2} | 3 +- .../resource-list/person/index.json.j2 | 0 .../place/index.html.j2} | 3 +- .../resource-list/place/index.json.j2 | 0 .../source/index.html.j2} | 3 +- .../resource-list/source/index.json.j2 | 0 .../citation/index.html.j2} | 1 + .../templates/resource/citation/index.json.j2 | 1 + .../event/index.html.j2} | 1 + .../templates/resource/event/index.json.j2 | 1 + .../file/index.html.j2} | 1 + .../templates/resource/file/index.json.j2 | 1 + .../person/index.html.j2} | 1 + .../templates/resource/person/index.json.j2 | 1 + .../place/index.html.j2} | 1 + .../templates/resource/place/index.json.j2 | 1 + .../source/index.html.j2} | 1 + .../templates/resource/source/index.json.j2 | 1 + betty/fs.py | 56 ++++--- betty/generate.py | 146 +++++++----------- betty/jinja2.py | 24 +-- betty/plugin/maps/__init__.py | 2 +- betty/plugin/nginx/__init__.py | 2 +- betty/plugin/trees/__init__.py | 2 +- betty/render.py | 16 +- betty/sass.py | 6 +- betty/tests/test_fs.py | 31 +--- 30 files changed, 139 insertions(+), 179 deletions(-) delete mode 100644 betty/assets/templates/page/list-file.html.j2 rename betty/assets/templates/{page/list-event.html.j2 => resource-list/event/index.html.j2} (53%) create mode 100644 betty/assets/templates/resource-list/event/index.json.j2 rename betty/assets/templates/{page/list-person.html.j2 => resource-list/person/index.html.j2} (70%) create mode 100644 betty/assets/templates/resource-list/person/index.json.j2 rename betty/assets/templates/{page/list-place.html.j2 => resource-list/place/index.html.j2} (71%) create mode 100644 betty/assets/templates/resource-list/place/index.json.j2 rename betty/assets/templates/{page/list-source.html.j2 => resource-list/source/index.html.j2} (75%) create mode 100644 betty/assets/templates/resource-list/source/index.json.j2 rename betty/assets/templates/{page/citation.html.j2 => resource/citation/index.html.j2} (96%) create mode 100644 betty/assets/templates/resource/citation/index.json.j2 rename betty/assets/templates/{page/event.html.j2 => resource/event/index.html.j2} (98%) create mode 100644 betty/assets/templates/resource/event/index.json.j2 rename betty/assets/templates/{page/file.html.j2 => resource/file/index.html.j2} (98%) create mode 100644 betty/assets/templates/resource/file/index.json.j2 rename betty/assets/templates/{page/person.html.j2 => resource/person/index.html.j2} (99%) create mode 100644 betty/assets/templates/resource/person/index.json.j2 rename betty/assets/templates/{page/place.html.j2 => resource/place/index.html.j2} (97%) create mode 100644 betty/assets/templates/resource/place/index.json.j2 rename betty/assets/templates/{page/source.html.j2 => resource/source/index.html.j2} (97%) create mode 100644 betty/assets/templates/resource/source/index.json.j2 diff --git a/betty/assets/templates/page/list-file.html.j2 b/betty/assets/templates/page/list-file.html.j2 deleted file mode 100644 index 20afdf9c1..000000000 --- a/betty/assets/templates/page/list-file.html.j2 +++ /dev/null @@ -1,7 +0,0 @@ -{% extends 'base.html.j2' %} -{% set page_title = _('Media') %} -{% block page_content %} - {% with files=entities %} - {% include 'list-file.html.j2' %} - {% endwith %} -{% endblock %} diff --git a/betty/assets/templates/page/list-event.html.j2 b/betty/assets/templates/resource-list/event/index.html.j2 similarity index 53% rename from betty/assets/templates/page/list-event.html.j2 rename to betty/assets/templates/resource-list/event/index.html.j2 index d55a2c333..a3fbc06ed 100644 --- a/betty/assets/templates/page/list-event.html.j2 +++ b/betty/assets/templates/resource-list/event/index.html.j2 @@ -1,7 +1,6 @@ {% extends 'base.html.j2' %} +{% set events = file_resources %} {% set page_title = _('Events') %} {% block page_content %} - {% with events=entities %} - {% include 'list-event.html.j2' %} - {% endwith %} + {% include 'list-event.html.j2' %} {% endblock %} diff --git a/betty/assets/templates/resource-list/event/index.json.j2 b/betty/assets/templates/resource-list/event/index.json.j2 new file mode 100644 index 000000000..e69de29bb diff --git a/betty/assets/templates/page/list-person.html.j2 b/betty/assets/templates/resource-list/person/index.html.j2 similarity index 70% rename from betty/assets/templates/page/list-person.html.j2 rename to betty/assets/templates/resource-list/person/index.html.j2 index 7f1226917..1fbc71393 100644 --- a/betty/assets/templates/page/list-person.html.j2 +++ b/betty/assets/templates/resource-list/person/index.html.j2 @@ -1,9 +1,10 @@ {% extends 'base.html.j2' %} +{% set people = file_resources %} {% set page_title = _('People') %} {% block page_content %} {% import 'macro/person.html.j2' as personMacros %}