Permalink
Browse files

Split template into a base piece shared for more pages, and a main pi…

…ece for the frontend.

Add support for building static files if template has changed.

And finally, write a policy document using this method and link it in from the front page.
  • Loading branch information...
1 parent 40194b1 commit fef87f9f359eb1b582f0e119cdc959e882342c3d @mhagander committed Oct 25, 2008
Showing with 59 additions and 24 deletions.
  1. +14 −2 generator.py
  2. +23 −0 template/base.tmpl
  3. +3 −22 template/index.tmpl
  4. +15 −0 template/policy.tmpl
  5. +4 −0 www/css/planet.css
View
@@ -12,10 +12,12 @@
import PyRSS2Gen
import ConfigParser
import datetime
+import os.path
import sys
import tidy
import urllib
from mako.template import Template
+from mako.lookup import TemplateLookup
from HTMLParser import HTMLParser
from planethtml import *
@@ -32,6 +34,7 @@ def __init__(self,db):
)
self.items = []
self.feeds = []
+ self.staticfiles = ['policy']
def Generate(self):
@@ -63,13 +66,22 @@ def Generate(self):
rss.write_xml(open("www/rss20.xml","w"), encoding='utf-8')
- self.WriteFromTemplate('template/index.tmpl', 'www/index.html')
+ self.WriteFromTemplate('index.tmpl', 'www/index.html')
+ for staticfile in self.staticfiles:
+ self.UpdateStaticFile(staticfile)
def WriteFromTemplate(self, templatename, outputname):
- tmpl = Template(filename=templatename, output_encoding='utf-8', input_encoding='utf-8')
+ lookup = TemplateLookup(directories=['template'], output_encoding='utf-8', input_encoding='utf-8')
+ tmpl = lookup.get_template(templatename)
f = open(outputname, "w")
f.write(tmpl.render_unicode(feeds=self.feeds, posts=self.items).encode('utf-8'))
f.close()
+
+ def UpdateStaticFile(self, filename):
+ if not os.path.exists("www/%s.html" % (filename)) or \
+ os.path.getmtime("www/%s.html" % (filename)) < os.path.getmtime("template/%s.tmpl" % (filename)):
+ print "Updating %s.html" % (filename)
+ self.WriteFromTemplate("%s.tmpl" % (filename), "www/%s.html" % (filename))
def TruncateAndCleanDescription(self, txt):
View
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">
+ <head>
+ <title>Planet PostgreSQL</title>
+ <meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="alternate" type="application/rss+xml" title="Planet PostgreSQL" href="http://planet.postgresql.org/rss20.xml" />
+ <style type="text/css" media="screen" title="Normal Text">@import url("css/planet.css");</style>
+ </head>
+ <body>
+ <div id="planetWrap">
+ <div id="planetHeader">
+ <div class="fl"><img src="http://www.postgresql.org/layout/images/hdr_left.png" alt="PostgreSQL" /></div>
+ <div class="fr"><img width="210" height="80" src="http://www.postgresql.org/layout/images/hdr_right.png" alt="The world's most advanced open source database" /></div>
+ <div class="cb"></div>
+ </div> <!-- planetHeader -->
+ <div id="planetMain">
+${self.body()}
+ </div> <!-- planetMain -->
+ </div> <!-- planetWrap -->
+ </body>
+</html>
View
@@ -1,21 +1,4 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">
- <head>
- <title>Planet PostgreSQL</title>
- <meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8" />
- <link rel="shortcut icon" href="/favicon.ico" />
- <link rel="alternate" type="application/rss+xml" title="Planet PostgreSQL" href="http://planet.postgresql.org/rss20.xml" />
- <style type="text/css" media="screen" title="Normal Text">@import url("css/planet.css");</style>
- </head>
- <body>
- <div id="planetWrap">
- <div id="planetHeader">
- <div class="fl"><img src="http://www.postgresql.org/layout/images/hdr_left.png" alt="PostgreSQL" /></div>
- <div class="fr"><img width="210" height="80" src="http://www.postgresql.org/layout/images/hdr_right.png" alt="The world's most advanced open source database" /></div>
- <div class="cb"></div>
- </div> <!-- planetHeader -->
- <div id="planetMain">
+<%inherit file="base.tmpl" />
<div id="planetRight">
<div class="planetRightTitle">Subscriptions</div>
<ul>
@@ -27,6 +10,8 @@
<ul>
<li><a href="rss20.xml"><img src="img/feed-icon-14x14.png" alt="rss" /></a> <a href="rss20.xml">Planet PostgreSQL</a></li>
</ul>
+ <div class="planetRightTitle">Planet</div>
+ <p><a href="policy.html">Policy</a> for being listed on Planet PostgreSQL</a></p>
</div> <!-- planetRight -->
<div id="planetLeft">
% for post in posts:
@@ -42,10 +27,6 @@
</div>
% endfor
</div> <!-- planetLeft -->
- </div> <!-- planetMain -->
- </div> <!-- planetWrap -->
- </body>
-</html>
<%def name="coalescelink(txt, link)">
%if link=='':
${txt}
View
@@ -0,0 +1,15 @@
+<%inherit file="base.tmpl" />
+<h1>Planet PostgreSQL policy</h1>
+<p>
+The following simple rules cover the blogs being listed on Planet PostgreSQL:
+</p>
+ <ul>
+ <li>All blogs should be about PostgreSQL or closely related technologies. If you want to blog
+ about other things as well, please put your PostgreSQL specific posts in a separate
+ category/tag/label, and use the feed for this category only for Planet PostgreSQL.</li>
+ <li>All topics related to PostgreSQL are of course appreciated - both technical and
+ non-technical.</li>
+ <li>Avoid inflammatory posts or personal attacks in posts syndicated.</li>
+ <li>Publishing of advertising in the syndicated part of your blog is not permitted</li>
+</ul>
+<p>Violating these rules will cause your blog to be removed from Planet PostgreSQL.</p>
View
@@ -131,6 +131,10 @@ div#planetRight ul {
padding-left: 15px;
}
+div#planetRight p {
+ padding-left: 15px;
+}
+
div.fl { float: left; border: none; text-align: left; }
div.fr { float: right; }
div.cb { clear: both; }

0 comments on commit fef87f9

Please sign in to comment.