Browse files

1) Added redirect map 2) Added "Give" 3) Better handling of titles

  • Loading branch information...
1 parent 1d9a6f0 commit 9ccd67ffdb5e2ed1d1902b994a294e239b86467a @dustball dustball committed Apr 4, 2012
Showing with 31 additions and 17 deletions.
  1. +27 −14 main.py
  2. BIN static/.DS_Store
  3. +1 −0 templates/base.html
  4. +2 −2 templates/content.html
  5. +1 −1 templates/index.html
View
41 main.py
@@ -78,20 +78,33 @@ class MainHandler(webapp.RequestHandler):
def get(self, pagename, site = PB_WIKI):
skip_cache = self.request.get('cache') == '0'
version = os.environ['CURRENT_VERSION_ID']
- if CDN_ENABLED:
- cdn = CDN_HOSTNAME
- try:
- if not(pagename):
- pagename = 'FrontPage'
- page = _request(PB_API_URL % (site, pagename), cache_ttl=604800, force=skip_cache)
- if page and "name" in page:
- self.response.out.write(template.render('templates/content.html', locals()))
- else:
- raise LookupError
- except LookupError:
- self.response.out.write(template.render('templates/404.html', locals()))
- self.error(404)
-
+
+ redirect_urls = {
+ # From: To
+ 'Assemble': 'Give',
+ 'key': 'http://signup.hackerdojo.com/key',
+ }
+ if pagename in redirect_urls:
+ url = redirect_urls[pagename]
+ self.redirect(url, permanent=True)
+ else:
+ if CDN_ENABLED:
+ cdn = CDN_HOSTNAME
+ try:
+ if not(pagename):
+ pagename = 'FrontPage'
+ page = _request(PB_API_URL % (site, pagename), cache_ttl=604800, force=skip_cache)
+ # Convert quasi-camel-case to
+ title = re.sub('([a-z])([A-Z])', r'\1 \2', pagename)
+ if page and "name" in page:
+ self.response.out.write(template.render('templates/content.html', locals()))
+ else:
+ raise LookupError
+ except LookupError:
+ self.response.out.write(template.render('templates/404.html', locals()))
+ self.error(404)
+
+
def main():
application = webapp.WSGIApplication([
('/api/pbwebhook', PBWebHookHandler),
View
BIN static/.DS_Store
Binary file not shown.
View
1 templates/base.html
@@ -22,6 +22,7 @@
<a href="/Contact">Contact</a>
<a href="http://wiki.hackerdojo.com/">Wiki</a>
<a href="/About">About</a>
+ <a href="/Give">Give</a>
<a href="/Membership">Membership</a>
<a href="http://events.hackerdojo.com/">Events</a>
</nav>
View
4 templates/content.html
@@ -1,11 +1,11 @@
{% extends 'base.html' %}
-{% block title %}{{page.name|title}}{% endblock %}
+{% block title %}{{title|title}}{% endblock %}
{% block content %}
<style>h2.tagline {display:none}</style>
<div id="content" class="wikihtml">
- <p style="margin-top:1em; padding-bottom:1em; margin-bottom:2em; border-bottom:1px dotted #ccc; font-size:12px; font-weight:bold"><a href="/">Home</a> &gt; {{page.name|title}}</p>
+ <p style="margin-top:1em; padding-bottom:1em; margin-bottom:2em; border-bottom:1px dotted #ccc; font-size:12px; font-weight:bold"><a href="/">Home</a> &gt; {{title|title}}</p>
{% autoescape off %}{{page.html}}{% endautoescape %}
</div>
View
2 templates/index.html
@@ -16,7 +16,7 @@
{% block content %}
<section class="hero-image" >
- <a href="/Assemble" style="position:absolute; right:-105px; top:-70px; z-index:200"><img width="292" height="282" alt="Help save the Dojo! Donate now" src="{{cdn}}/static/images/save2.png" border="0"></a>
+ <a href="/Give" style="position:absolute; right:-105px; top:-70px; z-index:200"><img width="292" height="282" alt="Help save the Dojo! Donate now" src="{{cdn}}/static/images/save2.png" border="0"></a>
<div id="mycarousel" style="overflow:hidden">
<ul style="overflow:none">
<li>

0 comments on commit 9ccd67f

Please sign in to comment.