Permalink
Browse files

Show link to twitter feed on the frontpage, if one is

configured.
  • Loading branch information...
mhagander committed Aug 30, 2009
1 parent e2b23e8 commit 04bd0b419f5badee2efa0438c90fe3c987f4926b
Showing with 14 additions and 3 deletions.
  1. +8 −3 generator.py
  2. +6 −0 template/index.tmpl
View
@@ -23,8 +23,8 @@
from planethtml import *
class Generator:
- def __init__(self,db):
- self.db = db
+ def __init__(self,cfg):
+ self.db = psycopg2.connect(cfg.get('planet','db'))
self.tidyopts = dict( drop_proprietary_attributes=1,
alt_text='',
hide_comments=1,
@@ -39,6 +39,10 @@ def __init__(self,db):
self.allposters = []
self.allteams = []
self.staticfiles = ['policy','add']
+ if cfg.has_option('twitter','account'):
+ self.twittername = cfg.get('twitter','account')
+ else:
+ self.twittername = None
settings.configure(
TEMPLATE_DIRS=('template',),
@@ -136,6 +140,7 @@ def WriteFromTemplate(self, templatename, outputname):
'allposters': self.allposters,
'allteams': self.allteams,
'posts': self.items,
+ 'twittername': self.twittername,
})).encode('utf-8'))
f.close()
@@ -232,4 +237,4 @@ def GetText(self):
if __name__=="__main__":
c = ConfigParser.ConfigParser()
c.read('planet.ini')
- Generator(psycopg2.connect(c.get('planet','db'))).Generate()
+ Generator(c).Generate()
View
@@ -32,6 +32,12 @@
<li><a href="rss20.xml"><img src="img/feed-icon-14x14.png" alt="rss" /></a> <a href="rss20.xml">All feeds (full entries)</a></li>
<li><a href="rss20_short.xml"><img src="img/feed-icon-14x14.png" alt="rss" /></a> <a href="rss20_short.xml">All feeds (short entries)</a></li>
</ul>
+{%if twittername %}
+ <div class="planetRightTitle">Twitter</div>
+ <ul>
+ <li>Follow @<a href="http://twitter.com/{{twittername}}">{{twittername}}</a> on Twitter for the latest updates!</li>
+ </ul>
+{%endif%}
<div class="planetRightTitle">Planet</div>
<ul>
<li><a href="policy.html">Policy</a> for being listed on Planet PostgreSQL.</li>

0 comments on commit 04bd0b4

Please sign in to comment.