make extra nav and footer follow theme

This commit is contained in:
Mike McLean 2012-01-21 21:09:53 -05:00
parent 5b9f515250
commit fa0b2cbbb6
3 changed files with 27 additions and 19 deletions

View file

@ -6,7 +6,7 @@
<a href="https://fedorahosted.org/koji/"><img src="$util.themePath('images/powered-by-koji.png')" alt="Powered By Koji" id="PoweredByKojiLogo"/></a>
</p>
#set $localfooterpath="/usr/share/koji-web/local/extra-footer.html"
#set $localfooterpath=$util.themePath("extra-footer.html", local=True)
#if os.path.exists($localfooterpath)
#set $localfooter="".join(open($localfooterpath).readlines())
$localfooter

View file

@ -47,7 +47,7 @@
<!-- HEADER -->
<div id="header">
<img src="$util.themePath('images/koji.png')" alt="Koji Logo" id="kojiLogo"/>
#set $localnavpath="/usr/share/koji-web/local/extra-nav.html"
#set $localnavpath=$util.themePath("extra-nav.html", local=True)
#if os.path.exists($localnavpath)
#set $localnav="".join(open($localnavpath).readlines())
$localnav

View file

@ -32,31 +32,39 @@ def _initValues(req, title='Build System Info', pageID='summary'):
values['title'] = title
values['pageID'] = pageID
values['currentDate'] = str(datetime.datetime.now())
theme = req.get_options().get('KojiTheme', None)
if theme:
themeCache.clear()
themeInfo['name'] = theme
themeInfo['staticdir'] = req.get_options().get('KojiStaticDir', '/usr/share/koji-web/static')
else:
themeInfo.clear()
themeCache.clear()
themeInfo.clear()
themeInfo['name'] = req.get_options().get('KojiTheme', None)
themeInfo['staticdir'] = req.get_options().get('KojiStaticDir', '/usr/share/koji-web/static')
req._values = values
return values
def themePath(path):
def themePath(path, local=False):
global themeInfo
global themeCache
if not themeInfo:
return "/koji-static/%s" % path
if path in themeCache:
return themeCache[path]
themepath = os.path.join(themeInfo['staticdir'], 'themes', themeInfo['name'], path)
if os.path.exists(themepath):
ret = "/koji-static/themes/%s/%s" % (themeInfo['name'], path)
local = bool(local)
if (path, local) in themeCache:
return themeCache[path, local]
if not themeInfo['name']:
if local:
ret = os.path.join(themeInfo['staticdir'], path)
else:
ret = "/koji-static/%s" % path
else:
ret = "/koji-static/%s" % path
themeCache[path] = ret
themepath = os.path.join(themeInfo['staticdir'], 'themes', themeInfo['name'], path)
if os.path.exists(themepath):
if local:
ret = themepath
else:
ret = "/koji-static/themes/%s/%s" % (themeInfo['name'], path)
else:
if local:
ret = os.path.join(themeInfo['staticdir'], path)
else:
ret = "/koji-static/%s" % path
themeCache[path, local] = ret
return ret
class DecodeUTF8(Cheetah.Filters.Filter):