From 99d7a8bdfcaa595f8b3e9ab93249d7fdb0d3fbfe Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 19 Nov 2024 15:28:43 +0100 Subject: [PATCH] Some fixes and improve jinja2 template performance by reducing include statements --- app/static/css/materialize.override.css | 26 +- app/static/js/app.js | 6 +- .../data-processing-and-analysis.html.j2 | 52 -- .../_base/_modals/terms_of_use.html.j2 | 32 - app/templates/_base/dropdowns.html.j2 | 9 - app/templates/_base/footer.html.j2 | 40 -- app/templates/_base/metas.html.j2 | 2 - app/templates/_base/modals.html.j2 | 5 - .../_base/navbar_primary_content.html.j2 | 95 --- app/templates/_base/scripts.html.j2 | 113 ---- app/templates/_base/sidenav.html.j2 | 77 --- app/templates/_base/stylesheets.html.j2 | 21 - app/templates/auth/register.html.j2 | 1 + app/templates/base.html.j2 | 600 +++++++++++++++--- app/templates/corpora/analysis.html.j2 | 3 + app/templates/corpora/corpus.html.j2 | 14 +- app/templates/corpora/public_corpus.html.j2 | 14 +- app/templates/main/dashboard.html.j2 | 50 +- app/templates/main/news.html.j2 | 98 +-- app/templates/main/news_new.html.j2 | 2 +- app/templates/main/privacy_policy.html.j2 | 10 +- .../services/file_setup_pipeline.html.j2 | 2 +- app/templates/users/settings/settings.html.j2 | 12 +- 23 files changed, 654 insertions(+), 630 deletions(-) delete mode 100644 app/templates/_base/_modals/data-processing-and-analysis.html.j2 delete mode 100644 app/templates/_base/_modals/terms_of_use.html.j2 delete mode 100644 app/templates/_base/dropdowns.html.j2 delete mode 100644 app/templates/_base/footer.html.j2 delete mode 100644 app/templates/_base/metas.html.j2 delete mode 100644 app/templates/_base/modals.html.j2 delete mode 100644 app/templates/_base/navbar_primary_content.html.j2 delete mode 100644 app/templates/_base/scripts.html.j2 delete mode 100644 app/templates/_base/sidenav.html.j2 delete mode 100644 app/templates/_base/stylesheets.html.j2 diff --git a/app/static/css/materialize.override.css b/app/static/css/materialize.override.css index cc7b73bf..77aa4724 100644 --- a/app/static/css/materialize.override.css +++ b/app/static/css/materialize.override.css @@ -1,25 +1,3 @@ -/* #region sidenav-fixed */ -/* - * The sidenav-fixed class is used which causes the sidenav to be fixed and open - * on large screens and hides to the regular functionality on smaller screens. - * In order to prevent the sidenav to overlap the content, the content (header, main and footer) - * gets an offset equal to the width of the sidenav. - * - * Read more: https://materializecss.com/sidenav.html#variations - */ -@media only screen and (min-width: 993px) { - body[data-sidenav-fixed="true" i] header, - body[data-sidenav-fixed="true" i] main, - body[data-sidenav-fixed="true" i] footer { - padding-left: 300px; - } - - body[data-sidenav-fixed="true" i] .navbar-fixed > nav { - width: calc(100% - 300px); - } -} -/* #endregion sidenav-fixed */ - /* #region sticky-footer */ /* * Sticky Footer: @@ -32,13 +10,13 @@ * * Read more: https://materializecss.com/footer.html#sticky-footer */ - body[data-sticky-footer="true" i] { + body { display: flex; min-height: 100vh; flex-direction: column; } -body[data-sticky-footer="true" i] main { +main { flex: 1 0 auto; } /* #endregion sticky-footer */ diff --git a/app/static/js/app.js b/app/static/js/app.js index 281452f7..c1aafc59 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -159,19 +159,21 @@ nopaque.App = class App { // Header navigation processes and services Dropdown. M.Dropdown.init( - document.querySelector('#nav-processes-and-services-dropdown-trigger'), + document.querySelector('#navbar-data-processing-and-analysis-dropdown-trigger'), { constrainWidth: false, + container: document.querySelector('#dropdowns'), coverTrigger: false } ); // Header navigation account Dropdown. M.Dropdown.init( - document.querySelector('#nav-account-dropdown-trigger'), + document.querySelector('#navbar-account-dropdown-trigger'), { alignment: 'right', constrainWidth: false, + container: document.querySelector('#dropdowns'), coverTrigger: false } ); diff --git a/app/templates/_base/_modals/data-processing-and-analysis.html.j2 b/app/templates/_base/_modals/data-processing-and-analysis.html.j2 deleted file mode 100644 index e6a9440a..00000000 --- a/app/templates/_base/_modals/data-processing-and-analysis.html.j2 +++ /dev/null @@ -1,52 +0,0 @@ - diff --git a/app/templates/_base/_modals/terms_of_use.html.j2 b/app/templates/_base/_modals/terms_of_use.html.j2 deleted file mode 100644 index 72078f69..00000000 --- a/app/templates/_base/_modals/terms_of_use.html.j2 +++ /dev/null @@ -1,32 +0,0 @@ - diff --git a/app/templates/_base/dropdowns.html.j2 b/app/templates/_base/dropdowns.html.j2 deleted file mode 100644 index b2679d70..00000000 --- a/app/templates/_base/dropdowns.html.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{% if current_user.is_authenticated %} - -{% endif %} diff --git a/app/templates/_base/footer.html.j2 b/app/templates/_base/footer.html.j2 deleted file mode 100644 index 47ade6aa..00000000 --- a/app/templates/_base/footer.html.j2 +++ /dev/null @@ -1,40 +0,0 @@ -
-
-
- - - -
-
- - - -
-
-
Legal Notice
- -
-
-
- diff --git a/app/templates/_base/metas.html.j2 b/app/templates/_base/metas.html.j2 deleted file mode 100644 index 30185f8f..00000000 --- a/app/templates/_base/metas.html.j2 +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/app/templates/_base/modals.html.j2 b/app/templates/_base/modals.html.j2 deleted file mode 100644 index b4e092a2..00000000 --- a/app/templates/_base/modals.html.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{% if current_user.is_authenticated and not current_user.terms_of_use_accepted %} -{% include "_base/_modals/terms_of_use.html.j2" %} -{% endif %} - -{% include "_base/_modals/data-processing-and-analysis.html.j2" %} diff --git a/app/templates/_base/navbar_primary_content.html.j2 b/app/templates/_base/navbar_primary_content.html.j2 deleted file mode 100644 index 3a3e6eca..00000000 --- a/app/templates/_base/navbar_primary_content.html.j2 +++ /dev/null @@ -1,95 +0,0 @@ -{% if current_user.is_authenticated %} -{# menu icon #} -{# shown for small/medium devices #} -menu - -{# nopaque logo #} -{# shown for large devices #} - - -{# left aligned navigation items #} -{# shown for large devices #} - -{% else %} -{# nopaque logo+wordmark+slogan #} -{# shown for large devices #} - -{% endif %} - -{# nopaque logo+wordmark #} -{# small/medium devices #} - - -{# right aligned navigation items #} -{# large devices #} - diff --git a/app/templates/_base/scripts.html.j2 b/app/templates/_base/scripts.html.j2 deleted file mode 100644 index a5139f07..00000000 --- a/app/templates/_base/scripts.html.j2 +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - -{% assets - filters='rjsmin', - output='gen/nopaque.%(version)s.js', - 'js/index.js', - 'js/app.js', - 'js/utils.js', - - 'js/forms/index.js', - 'js/forms/base-form.js', - 'js/forms/create-contribution-form.js', - 'js/forms/create-corpus-file-form.js', - 'js/forms/create-job-form.js', - - 'js/resource-displays/index.js', - 'js/resource-displays/resource-display.js', - 'js/resource-displays/corpus-display.js', - 'js/resource-displays/job-display.js', - - 'js/resource-lists/index.js', - 'js/resource-lists/resource-list.js', - 'js/resource-lists/admin-user-list.js', - 'js/resource-lists/corpus-file-list.js', - 'js/resource-lists/corpus-follower-list.js', - 'js/resource-lists/corpus-list.js', - 'js/resource-lists/corpus-text-info-list.js', - 'js/resource-lists/corpus-token-list.js', - 'js/resource-lists/detailed-public-corpus-list.js', - 'js/resource-lists/job-input-list.js', - 'js/resource-lists/job-list.js', - 'js/resource-lists/job-result-list.js', - 'js/resource-lists/public-corpus-list.js', - 'js/resource-lists/public-user-list.js', - 'js/resource-lists/spacy-nlp-pipeline-model-list.js', - 'js/resource-lists/tesseract-ocr-pipeline-model-list.js', - - 'js/requests/index.js', - 'js/requests/admin.js', - 'js/requests/contributions.js', - 'js/requests/corpora.js', - 'js/requests/jobs.js', - 'js/requests/users.js', - - 'js/corpus-analysis/index.js', - 'js/corpus-analysis/cqi/index.js', - 'js/corpus-analysis/cqi/constants.js', - 'js/corpus-analysis/cqi/errors.js', - 'js/corpus-analysis/cqi/status.js', - 'js/corpus-analysis/cqi/api/index.js', - 'js/corpus-analysis/cqi/api/client.js', - 'js/corpus-analysis/cqi/models/index.js', - 'js/corpus-analysis/cqi/models/resource.js', - 'js/corpus-analysis/cqi/models/attributes.js', - 'js/corpus-analysis/cqi/models/subcorpora.js', - 'js/corpus-analysis/cqi/models/corpora.js', - 'js/corpus-analysis/cqi/client.js', - 'js/corpus-analysis/query-builder/index.js', - 'js/corpus-analysis/query-builder/element-references.js', - 'js/corpus-analysis/query-builder/query-builder.js', - 'js/corpus-analysis/query-builder/structural-attribute-builder-functions.js', - 'js/corpus-analysis/query-builder/token-attribute-builder-functions.js', - 'js/corpus-analysis/app.js', - 'js/corpus-analysis/concordance-extension.js', - 'js/corpus-analysis/reader-extension.js', - 'js/corpus-analysis/static-visualization-extension.js' --%} - -{% endassets -%} - - - - diff --git a/app/templates/_base/sidenav.html.j2 b/app/templates/_base/sidenav.html.j2 deleted file mode 100644 index b8be43f5..00000000 --- a/app/templates/_base/sidenav.html.j2 +++ /dev/null @@ -1,77 +0,0 @@ - diff --git a/app/templates/_base/stylesheets.html.j2 b/app/templates/_base/stylesheets.html.j2 deleted file mode 100644 index e48cdc49..00000000 --- a/app/templates/_base/stylesheets.html.j2 +++ /dev/null @@ -1,21 +0,0 @@ - -{% assets - output='gen/nopaque.%(version)s.css', - 'css/materialize.css', - 'css/materialize.override.css', - 'css/nopaque-icons.css', - 'css/theme-colors.css', - 'css/corpus-status-colors.css', - 'css/corpus-status-text.css', - 'css/job-status-colors.css', - 'css/job-status-text.css', - 'css/service-colors.css', - 'css/pagination.css', - 'css/service-icons.css', - 'css/s-attr-colors.css', - 'css/spacing.css', - 'css/status-spinner.css', - 'css/utils.css' --%} - -{% endassets -%} diff --git a/app/templates/auth/register.html.j2 b/app/templates/auth/register.html.j2 index 7d006702..133b202a 100644 --- a/app/templates/auth/register.html.j2 +++ b/app/templates/auth/register.html.j2 @@ -30,6 +30,7 @@ {{ wtf.render_field(form.submit, class_='width-100', material_icon='send') }} + {% endblock page_content %} diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index 08acd35c..9b304005 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -1,106 +1,544 @@ -{% if title is not defined %} -{% set title = 'nopaque' %} -{% endif %} - -{% if sidenav_fixed is not defined %} -{% set sidenav_fixed = false %} -{% endif %} - -{% if sticky_footer is not defined %} -{% set sticky_footer = true %} -{% endif %} - -{% if navbar_fixed is not defined %} -{% set navbar_fixed = true %} -{% endif %} - -{% if navbar_extended is not defined %} -{% set navbar_extended = false %} -{% endif %} - -{% block doc %} - - {% block html %} + - {% block head %} - {% block metas %} - {% include "_base/metas.html.j2" %} - {% endblock metas %} + + + + - - {%- block title %}{{ title }}{% endblock title -%} - + {{ title if title is defined else 'nopaque' }} + {% block stylesheets %} - {% include "_base/stylesheets.html.j2" %} + + {% assets + output='gen/nopaque.%(version)s.css', + 'css/materialize.css', + 'css/materialize.override.css', + 'css/nopaque-icons.css', + 'css/theme-colors.css', + 'css/corpus-status-colors.css', + 'css/corpus-status-text.css', + 'css/job-status-colors.css', + 'css/job-status-text.css', + 'css/service-colors.css', + 'css/pagination.css', + 'css/service-icons.css', + 'css/s-attr-colors.css', + 'css/spacing.css', + 'css/status-spinner.css', + 'css/utils.css' + -%} + + {% endassets -%} {% endblock stylesheets %} - {% endblock head %} + - - {% block body %} -
- {% block header %} - {% if navbar_fixed %} + +
- {% block main %} {% block page_content %}{% endblock page_content %} - {% endblock main %} - - - -
- {% block modals %} - {% include "_base/modals.html.j2" %} - {% endblock modals %} -
-