From 932e63050d6634f46661e911e98edbc1340848ab Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sun, 28 Jul 2024 14:37:46 -0500 Subject: [PATCH] Do the navbar properly The parent navbar decides how to place the child's content. Do not use "next" because that means that the parent must know if they have children. Instead, use body wrapping and always call the "navbar_content" tag with a body. --- src/pgwui_common/templates/auth_base.mak | 12 ++++++- src/pgwui_common/templates/base.mak | 13 ++++---- src/pgwui_common/templates/errors_base.mak | 12 ++----- src/pgwui_common/templates/lib.mak | 37 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 src/pgwui_common/templates/lib.mak diff --git a/src/pgwui_common/templates/auth_base.mak b/src/pgwui_common/templates/auth_base.mak index 9f40a8c..133ab3c 100644 --- a/src/pgwui_common/templates/auth_base.mak +++ b/src/pgwui_common/templates/auth_base.mak @@ -1,6 +1,6 @@ <%doc> - Copyright (C) 2015, 2020, 2021 The Meme Factory, Inc. + Copyright (C) 2015, 2020, 2021, 2024 The Meme Factory, Inc. http://www.karlpinc.com/ This file is part of PGWUI_Common. @@ -57,12 +57,22 @@ errors_base_mak = asset_abspath('pgwui_common:templates/errors_base.mak') auth_parts_mak = asset_abspath('pgwui_common:templates/auth_parts.mak') + lib_mak = asset_abspath('pgwui_common:templates/lib.mak') %> <%inherit file="${errors_base_mak}" /> <%namespace file="${auth_parts_mak}" name="auth_parts" inheritable="True" /> +<%namespace name="lib" file="${lib_mak}" /> + +<%def name="navbar_content()"> + <%parent:navbar_content> + <%lib:have_navbar_logout> + ${caller.body()} + + + <%def name="upload_form(extra_rows=[], upload_nulls=True)">
diff --git a/src/pgwui_common/templates/base.mak b/src/pgwui_common/templates/base.mak index 513484e..ecaa100 100644 --- a/src/pgwui_common/templates/base.mak +++ b/src/pgwui_common/templates/base.mak @@ -35,12 +35,7 @@ % if 'pgwui_menu' in pgwui['urls']: | Menu % endif - - -<%def name="navbar()"> - + ${caller.body()} @@ -59,7 +54,11 @@ - ${self.navbar()} + <%block name="navbar"> + + <%block name="summary_info" /> diff --git a/src/pgwui_common/templates/errors_base.mak b/src/pgwui_common/templates/errors_base.mak index ee4f0ac..dd6ff15 100644 --- a/src/pgwui_common/templates/errors_base.mak +++ b/src/pgwui_common/templates/errors_base.mak @@ -1,6 +1,6 @@ <%doc> - Copyright (C) 2015, 2020, 2021 The Meme Factory, Inc. + Copyright (C) 2015, 2020, 2021, 2024 The Meme Factory, Inc. http://www.karlpinc.com/ This file is part of PGWUI_Common. @@ -19,8 +19,7 @@ License along with this program. If not, see . - Base template for a form that reports multiple errors - and has "logout" in the navbar + Base template for a form that reports multiple errors. Karl O. Pinc @@ -42,13 +41,6 @@ <%inherit file="${base_mak}" /> -<%def name="navbar_content()"> - ${parent.navbar_content()} - % if 'pgwui_logout' in pgwui['urls']: - | Logout - % endif - - <%block name="summary_info"> % if filename:

File supplied: ${filename}

diff --git a/src/pgwui_common/templates/lib.mak b/src/pgwui_common/templates/lib.mak new file mode 100644 index 0000000..0dd412d --- /dev/null +++ b/src/pgwui_common/templates/lib.mak @@ -0,0 +1,37 @@ + +<%doc> + Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/ + + This file is part of PGWUI_Common. + + This program is free software: you can redistribute it and/or + modify it under the terms of the GNU Affero General Public License + as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public + License along with this program. If not, see + . + + Library template of utility functions. + + Karl O. Pinc + + This template uses the following variables in it's context: + + pgwui Dict + urls Dict of urls, keyed by pgwui component name + + + +<%def name="have_navbar_logout()"> + ${caller.body()} + % if 'pgwui_logout' in pgwui['urls']: + | Logout + % endif + -- 2.34.1