Do the navbar properly
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 28 Jul 2024 19:37:46 +0000 (14:37 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 29 Jul 2024 14:52:47 +0000 (09:52 -0500)
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
src/pgwui_common/templates/base.mak
src/pgwui_common/templates/errors_base.mak
src/pgwui_common/templates/lib.mak [new file with mode: 0644]

index 9f40a8cc50c06841625a82b27aa3eaa6193ef558..133ab3c839e128d55dedbe67ddb1da44dd367835 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <%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.
 
     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()}
+    </%lib:have_navbar_logout>
+  </%parent:navbar_content>
+</%def>
 
 <%def name="upload_form(extra_rows=[], upload_nulls=True)">
   <form action="" enctype="multipart/form-data" method="post">
index 513484e0e8564b016723d03b620b579419dd58dd..ecaa100e2faffd6b0989360fc0312655e8422a18 100644 (file)
   % if 'pgwui_menu' in pgwui['urls']:
     | <a href="${pgwui['urls']['pgwui_menu']}">Menu</a>
   % endif
-</%def>
-
-<%def name="navbar()">
-  <p class="navbar">
-    ${self.navbar_content()}
-  </p>
+  ${caller.body()}
 </%def>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 </head>
 
 <body>
-  ${self.navbar()}
+  <%block name="navbar">
+    <p class="navbar">
+    <%self:navbar_content />
+    </p>
+  </%block>
 
   <%block name="summary_info" />
 
index ee4f0ac6367927830981e6b307c6ab3bb168a7de..dd6ff151ef84fdce8c5087bbe618d1e4e8ba7ea1 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <%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
      <http://www.gnu.org/licenses/>.
  
-  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 <kop@karlpinc.com>
 
 
 <%inherit file="${base_mak}" />
 
-<%def name="navbar_content()">
-  ${parent.navbar_content()}
-  % if 'pgwui_logout' in pgwui['urls']:
-    | <a href="${pgwui['urls']['pgwui_logout']}">Logout</a>
-  % endif
-</%def>
-
 <%block name="summary_info">
   % if filename:
       <p>File supplied: <em class="filename">${filename}</em></p>
diff --git a/src/pgwui_common/templates/lib.mak b/src/pgwui_common/templates/lib.mak
new file mode 100644 (file)
index 0000000..0dd412d
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<%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
+     <http://www.gnu.org/licenses/>.
+  Library template of utility functions.
+  Karl O. Pinc <kop@meme.com>
+
+  This template uses the following variables in it's context:
+
+    pgwui    Dict
+      urls   Dict of urls, keyed by pgwui component name
+
+</%doc>
+
+<%def name="have_navbar_logout()">
+   ${caller.body()}
+   % if 'pgwui_logout' in pgwui['urls']:
+     | <a href="{pgwui["urls"]["pgwui_logout"]}"> Logout</a>
+   % endif
+</%def>