Add a template context processor that sets link_root on all secure requests,

so that we can generate proper linkbacks to the non-secure version of the
site for all static content.
This commit is contained in:
Magnus Hagander
2009-09-16 16:08:17 +02:00
parent 4be5cd0266
commit df91488ae6
3 changed files with 31 additions and 12 deletions

View File

@ -70,6 +70,12 @@ TEMPLATE_DIRS = (
'../templates/',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.media',
'util.contexts.RootLinkContextProcessor',
)
LOGIN_URL='/account/login/'
LOGIN_REDIRECT_URL='/account/'
LOGOUT_URL='/account/logout/'
@ -95,6 +101,8 @@ INSTALLED_APPS = [
]
SITE_ROOT="http://www.postgresql.org"
# Load local settings overrides
from settings_local import *

View File

@ -1,4 +1,5 @@
from django.template import RequestContext
from django.conf import settings
# This is the whole site navigation structure. Stick in a smarter file?
sitenav = {
@ -88,3 +89,13 @@ class NavContext(RequestContext):
navsection = {}
self.update({'navmenu': navsection})
# Template context processor to add information about the root link
def RootLinkContextProcessor(request):
if request.is_secure():
return {
'link_root': settings.SITE_ROOT,
}
else:
return {}

View File

@ -7,8 +7,8 @@
<link rel="shortcut icon" href="/favicon.ico" />
<style type="text/css" media="screen" title="Normal Text">@import url("/media/css/base.css");</style>
<style type="text/css" media="screen" title="Normal Text">@import url("/media/css/geckofixes.css");</style>
<link rel="alternate" type="application/rss+xml" title="PostgreSQL News" href="/feeds/news/" />
<link rel="alternate" type="application/rss+xml" title="PostgreSQL Events" href="/feeds/events/" />
<link rel="alternate" type="application/rss+xml" title="PostgreSQL News" href="{{link_root}}/feeds/news/" />
<link rel="alternate" type="application/rss+xml" title="PostgreSQL Events" href="{{link_root}}/feeds/events/" />
</head>
<body>
<div id="pgContainerWrap">
@ -27,14 +27,14 @@
<div id="pgTopNavLeft"><img width="7" height="23" alt="" src="/media/img/layout/nav_lft.png" /></div>
<div id="pgTopNavRight"><img width="7" height="23" alt="" src="/media/img/layout/nav_rgt.png" /></div>
<ul id="pgTopNavList">
<li><a href="/" title="Home">Home</a></li>
<li><a href="/about" title="About">About</a></li>
<li><a href="/download" title="Download">Download</a></li>
<li><a href="/docs" title="Documentation">Documentation</a></li>
<li><a href="/community" title="Community">Community</a></li>
<li><a href="/developer" title="Developers">Developers</a></li>
<li><a href="/support" title="Support">Support</a></li>
<li><a href="/account" title="Your account">Your account</a></li>
<li><a href="{{link_root}}/" title="Home">Home</a></li>
<li><a href="{{link_root}}/about" title="About">About</a></li>
<li><a href="{{link_root}}/download" title="Download">Download</a></li>
<li><a href="{{link_root}}/docs" title="Documentation">Documentation</a></li>
<li><a href="{{link_root}}/community" title="Community">Community</a></li>
<li><a href="{{link_root}}/developer" title="Developers">Developers</a></li>
<li><a href="{{link_root}}/support" title="Support">Support</a></li>
<li><a href="{{link_root}}/account" title="Your account">Your account</a></li>
</ul>
</div> <!-- pgTopNav -->
</div> <!-- pgHeaderContainer -->
@ -43,8 +43,8 @@
<br class="pgClearBoth" />
</div> <!-- pgContent -->
<div id="pgFooter">
<a class="navFooter" href="/about/privacypolicy">Privacy Policy</a> |
<a class="navFooter" href="/about/website">About the website</a><br/>
<a class="navFooter" href="{{link_root}}/about/privacypolicy">Privacy Policy</a> |
<a class="navFooter" href="{{link_root}}/about/website">About the website</a><br/>
Copyright &copy; 1996-2009 PostgreSQL Global Development Group
</div> <!-- pgFooter -->
</div>