[PATCH] Make the templated footer configurable.

Ralph Bean rbean at redhat.com
Sat Jun 6 19:53:50 UTC 2015


We ran into a problem[1] where old footers would cause syntax errors when
interpreted as templates.  This makes that behavior configurable and defaults
to the old literal interpretation.

[1] https://lists.fedoraproject.org/pipermail/buildsys/2015-May/004751.html
---
 www/conf/web.conf                 | 5 +++++
 www/kojiweb/includes/footer.chtml | 5 +++++
 www/kojiweb/wsgi_publisher.py     | 1 +
 www/lib/kojiweb/util.py           | 1 +
 4 files changed, 12 insertions(+)

diff --git a/www/conf/web.conf b/www/conf/web.conf
index 171349b..38f0b61 100644
--- a/www/conf/web.conf
+++ b/www/conf/web.conf
@@ -24,3 +24,8 @@ LoginTimeout = 72
 # Secret = CHANGE_ME
 
 LibPath = /usr/share/koji-web/lib
+
+# If set to True, then the footer will be included literally.
+# If False, then the footer will be included as another Kid Template.
+# Defaults to True
+LiteralFooter = True
diff --git a/www/kojiweb/includes/footer.chtml b/www/kojiweb/includes/footer.chtml
index 684e5a4..8e22022 100644
--- a/www/kojiweb/includes/footer.chtml
+++ b/www/kojiweb/includes/footer.chtml
@@ -8,8 +8,13 @@
 
 #set $localfooterpath=$util.themePath("extra-footer.html", local=True)
 #if os.path.exists($localfooterpath)
+#if $literalFooter
+#set $localfooter="".join(open($localfooterpath).readlines())
+#$localfooter
+#else
 #include $localfooterpath
 #end if
+#end if
 
       </div>
     </div>
diff --git a/www/kojiweb/wsgi_publisher.py b/www/kojiweb/wsgi_publisher.py
index 4f58b8e..e790815 100644
--- a/www/kojiweb/wsgi_publisher.py
+++ b/www/kojiweb/wsgi_publisher.py
@@ -69,6 +69,7 @@ class Dispatcher(object):
         ['KojiFilesURL', 'string', 'http://localhost/kojifiles'],
         ['KojiTheme', 'string', None],
         ['KojiGreeting', 'string', 'Welcome to Koji Web'],
+        ['LiteralFooter', 'boolean', True],
 
         ['WebPrincipal', 'string', None],
         ['WebKeytab', 'string', '/etc/httpd.keytab'],
diff --git a/www/lib/kojiweb/util.py b/www/lib/kojiweb/util.py
index ddee29a..d2777b1 100644
--- a/www/lib/kojiweb/util.py
+++ b/www/lib/kojiweb/util.py
@@ -54,6 +54,7 @@ def _initValues(environ, title='Build System Info', pageID='summary'):
     values['title'] = title
     values['pageID'] = pageID
     values['currentDate'] = str(datetime.datetime.now())
+    values['literalFooter'] = environ['koji.options'].get('LiteralFooter', True)
     themeCache.clear()
     themeInfo.clear()
     themeInfo['name'] = environ['koji.options'].get('KojiTheme', None)
-- 
2.4.2



More information about the buildsys mailing list