diff options
author | Magnus Hagander | 2008-10-25 21:34:47 +0000 |
---|---|---|
committer | Magnus Hagander | 2008-10-25 21:34:47 +0000 |
commit | 346e1cc55bd7466400d0494a14370d6b6f5c59e4 (patch) | |
tree | 9805bf12ab0d4fa46afb862b56f4a6707b016748 | |
parent | 730bdd7b278c77707fb5ec2f8daa7f14e2e2766f (diff) |
Split template into a base piece shared for more pages, and a main piece 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.
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2241 8f5c7a92-453e-0410-a47f-ad33c8a6b003
-rwxr-xr-x | planet/generator.py | 16 | ||||
-rw-r--r-- | planet/template/base.tmpl | 23 | ||||
-rw-r--r-- | planet/template/index.tmpl | 25 | ||||
-rw-r--r-- | planet/template/policy.tmpl | 15 | ||||
-rw-r--r-- | planet/www/css/planet.css | 4 |
5 files changed, 59 insertions, 24 deletions
diff --git a/planet/generator.py b/planet/generator.py index e12a6954..c3229805 100755 --- a/planet/generator.py +++ b/planet/generator.py @@ -12,10 +12,12 @@ import psycopg2.extensions 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 @@ class Generator: ) self.items = [] self.feeds = [] + self.staticfiles = ['policy'] def Generate(self): @@ -63,13 +66,22 @@ class Generator: 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): diff --git a/planet/template/base.tmpl b/planet/template/base.tmpl new file mode 100644 index 00000000..47283b35 --- /dev/null +++ b/planet/template/base.tmpl @@ -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="/https/git.postgresql.org/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> diff --git a/planet/template/index.tmpl b/planet/template/index.tmpl index 0d59c15b..d0a72c91 100644 --- a/planet/template/index.tmpl +++ b/planet/template/index.tmpl @@ -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="/https/git.postgresql.org/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} diff --git a/planet/template/policy.tmpl b/planet/template/policy.tmpl new file mode 100644 index 00000000..a3999183 --- /dev/null +++ b/planet/template/policy.tmpl @@ -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> diff --git a/planet/www/css/planet.css b/planet/www/css/planet.css index 5a3ae080..bd9daac7 100644 --- a/planet/www/css/planet.css +++ b/planet/www/css/planet.css @@ -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; } |