From: davyd Date: Mon, 22 Mar 2004 06:06:17 +0000 (+0000) Subject: Addition of new features++, read ChangeLog X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=dc7db379d1b11f9de8894865689f1c626d62a523;p=planet-ucc.git Addition of new features++, read ChangeLog --- diff --git a/Changelog b/Changelog index 8b94210..3d91b86 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,27 @@ +2004-03-20 +========== + * update-planet, XMLWriter.py, XHTMLWriter.py, RSS1Writer.py, RSS2Writer.py, + XMLParse2.py + Stopped overwriting .blogTitle, adding a field .blogName to store the name + of the syndicated blogger. + * XHTMLWriter.py, planet.css + Added (heavily modified code) from [TRS] to make it show the name of the + blog when you hover over the name of the person. The name of the blogger, + and name of the article are now linked (this is not obvious after changes + to planet.css). + * Added FOAFWriter.py + A plugin to XMLWriter to do FOAF (Friend Of A Friend) XML feeds. FOAF + actually seems quite complex in what it can tell you, however the FOAF + feeds from the Planets is quite simplistic. This should suffice [YAK]. + * Added OPMLWriter.py + A plugin to XMLWriter to do OPML. + * update-planet, launch-update-planet.sh + FOAF and OPML support. + * sidebar.html + Mentions of new syndication. + * faq.html + Fixed annoying mistakes. Should really write an FAQ. + 2004-03-15 ========== * update-planet diff --git a/FOAFWriter.py b/FOAFWriter.py new file mode 100644 index 0000000..39ff3fe --- /dev/null +++ b/FOAFWriter.py @@ -0,0 +1,52 @@ +# +# FOAFWriter +# +# A plugin to XMLWriter to output FOAF (friend of a friend). +# +# I have a quick look through some sample FOAF, it seems it +# can get quite intricate in things it can tell you, however +# other Planets only offer this basic feed. Given this is almost +# all the information we know, that can't be too bad. +# +# (c) 2004, Davyd Madeley +# + +class FOAFWriter: + def __init__(self, planet): + self.parent = None + + def __write_item__(self, blog): + output = '' + output += '\n' + output += ' \n' + output += ' %s\n' % blog.blogName + output += ' \n' + output += ' \n' % blog.blogURL + output += ' %s\n' % blog.blogTitle + output += ' \n' + output += ' \n' % blog.feedURL + output += ' \n' + output += ' \n' + output += ' \n' + output += ' \n' + output += '\n' + return output + + def write(self): + itemcount = 0 + output = '' + output += '\n' + output += ' xmlns="http://purl.org/rss/1.0/"\n' + output += ' xmlns:dc="http://purl.org/dc/elements/1.1/"\n' + output += ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n' + # XXX: probably need other doctypes here + # infact, need to check XML structures + output += ' \n' + output += ' Planet UCC\n' + output += ' http://planet.ucc.asn.au/\n' + output += ' \n' + for blog in self.parent.blogs: + output += self.__write_item__(blog) + output += ' \n' + output += '' + return output diff --git a/OPMLWriter.py b/OPMLWriter.py new file mode 100644 index 0000000..c7bca14 --- /dev/null +++ b/OPMLWriter.py @@ -0,0 +1,33 @@ +# +# OPMPWriter +# +# A plugin to XMLWriter to output OPML +# +# This is apparently the most horrific abuse of XML known to man. +# +# (c) 2004, Davyd Madeley +# + +import time + +class OPMLWriter: + def __init__(self, planet): + self.parent = None + + def write(self): + output = '' + output += '\n' + output += ' \n' + output += ' Planet UCC\n' + date = time.strftime("%a, %d %b %Y %H:%M:%S +0800", time.localtime()) + output += ' %s\n' % date + output += ' %s\n' % date + output += ' Planetmaster\n' + output += ' planet@ucc.asn.au\n' + output += ' \n' + output += ' \n' + for blog in self.parent.blogs: + output += ' \n' % (blog.blogName, blog.feedURL) + output += ' \n' + output += '' + return output diff --git a/RSS1Writer.py b/RSS1Writer.py index 7d7ce17..9609e74 100644 --- a/RSS1Writer.py +++ b/RSS1Writer.py @@ -17,7 +17,7 @@ class RSS1Writer: def __write_item__(self, item): output = '' output += '\n' % item.itemURL - output += ' %s: %s\n' % (item.blogTitle, item.itemTitle) + output += ' %s: %s\n' % (item.blogName, item.itemTitle) output += ' %s\n' % item.itemURL output += ' \n' output += cgi.escape(item.contents) diff --git a/RSS2Writer.py b/RSS2Writer.py index f61d315..cd19d11 100644 --- a/RSS2Writer.py +++ b/RSS2Writer.py @@ -17,7 +17,7 @@ class RSS2Writer: def __write_item__(self, item): output = '' output += '\n' - output += ' %s: %s\n' % (item.blogTitle, item.itemTitle) + output += ' %s: %s\n' % (item.blogName, item.itemTitle) output += ' %s\n' % item.itemURL output += ' \n' output += cgi.escape(item.contents) diff --git a/XHTMLWriter.py b/XHTMLWriter.py index 3ef84c9..93aa9de 100644 --- a/XHTMLWriter.py +++ b/XHTMLWriter.py @@ -17,11 +17,12 @@ class XHTMLWriter: def __write_item__(self, item): output = '' output += '
\n' - output += '

%s: %s

\n' % (item.blogTitle, item.itemTitle) + output += '

%s: %s

\n' % (item.blogURL, item.blogTitle, item.blogName, + item.itemURL, item.itemTitle) output += '

\n' if item.imageURL: - output += '%s\n' % (item.imageLink, item.imageURL, item.blogTitle) - output += '(%s)\n' % (item.itemURL ,time.strftime('%A %B %d, %Y %H:%M AWST', time.localtime(item.itemDate))) + output += '%s\n' % (item.imageLink, item.imageURL, item.blogName) + output += '(%s)\n' % (item.itemURL ,time.strftime('posted on %A %B %d, %Y at %H:%M AWST', time.localtime(item.itemDate))) output += '

\n' output += '

\n' output += item.contents @@ -62,7 +63,7 @@ class XHTMLWriter: blogscopy = self.parent.blogs + [] blogscopy.sort(self.__blog_sort__) for blog in blogscopy: - output += '%s (feed)
\n' % (blog.blogURL, blog.blogTitle, blog.feedURL) + output += '%s (feed)
\n' % (blog.blogURL, blog.blogName, blog.feedURL) output += '

\n' output += '
\n' output += '
\n' @@ -89,7 +90,7 @@ class XHTMLWriter: return output def __blog_sort__(self, blog1, blog2): - name1, name2 = blog1.blogTitle.split(' ')[-1], blog2.blogTitle.split(' ')[-1] + name1, name2 = blog1.blogName.split(' ')[-1], blog2.blogName.split(' ')[-1] if name1 < name2: return -1 if name1 == name2: return 0 if name1 > name2: return 1 diff --git a/XMLParse2.py b/XMLParse2.py index 3a14e2b..861b333 100644 --- a/XMLParse2.py +++ b/XMLParse2.py @@ -17,6 +17,7 @@ feedparser.USER_AGENT = "PlanetUCC/1.0b +http://planet.ucc.asn.au/ %s" % feedpar class Blog: def __init__(self): + self.blogName = None self.blogTitle = None self.blogURL = None self.feedURL = None diff --git a/XMLWriter.py b/XMLWriter.py index 7f60c4e..a4bca9d 100644 --- a/XMLWriter.py +++ b/XMLWriter.py @@ -14,6 +14,7 @@ class PlanetItem: self.itemURL = item.itemURL self.itemDate = item.itemDate self.blogTitle = blog.blogTitle + self.blogName = blog.blogName self.blogURL = blog.blogURL self.imageURL = blog.imageURL self.imageLink = blog.imageLink diff --git a/faq.html b/faq.html index 887552b..0350e70 100644 --- a/faq.html +++ b/faq.html @@ -23,7 +23,7 @@

- Monday February 09, 2004 12:12 AWST + Monday March 20, 2004 01:20 AWST

@@ -63,8 +63,9 @@

diff --git a/launch-update-planet.sh b/launch-update-planet.sh index 284a42e..4687fa2 100755 --- a/launch-update-planet.sh +++ b/launch-update-planet.sh @@ -13,6 +13,6 @@ cd $HOME/projects/planetucc/ EXITSTATUS=$? if [ $EXITSTATUS -eq 0 ]; then scp planet.html planet@mussel.ucc.asn.au:public-html/index.html - scp rss[12].xml planet@mussel.ucc.asn.au:public-html/ + scp {rss1,rss2,foaf,opml}.xml planet@mussel.ucc.asn.au:public-html/ fi cd $OLDPWD diff --git a/planet.css b/planet.css index 293f861..ea0c89d 100644 --- a/planet.css +++ b/planet.css @@ -83,6 +83,15 @@ padding: 0.5ex; } +.item h2 a { + text-decoration: none; + color: black; +} +.item h2 a:visited { + text-decoration: none; + color: black; +} + .item img { border-style: none; padding-left: 1ex; diff --git a/sidebar.html b/sidebar.html index a05da67..e29615c 100644 --- a/sidebar.html +++ b/sidebar.html @@ -20,8 +20,10 @@

Syndication

Planet UCC offers - RSS 1.0, and - RSS 2.0 + RSS 1.0, + RSS 2.0, + FOAF, and + OPML feeds of this webpage.

Links

diff --git a/update-planet b/update-planet index c4477ff..4e23e5b 100755 --- a/update-planet +++ b/update-planet @@ -12,7 +12,7 @@ import sys, codecs # planetUCC modules import XMLParse2 as XMLParse, XMLWriter, CacheHandler # planetUCC output plugins -import XHTMLWriter, RSS2Writer, RSS1Writer +import XHTMLWriter, RSS2Writer, RSS1Writer, FOAFWriter, OPMLWriter # step 1: read in the config and check each object from cache cache = CacheHandler.CacheHandler() @@ -34,7 +34,7 @@ for feed in feeds: # XMLParse2 takes two paramaters, a URL and a CacheObject blog = XMLParse.XMLParse(feed[1], feed[2]).parse() if blog: - blog.blogTitle = feed[0] + blog.blogName = feed[0] blog.feedURL = feed[1] blogs.append(blog) # check the old copy of the cache, vs the new copy @@ -67,3 +67,14 @@ try: codecs.open('rss1.xml', 'wb', 'utf-8').write(xmlwriter.write(RSS1Writer.RSS1Writer)) except: sys.stderr.write('DEBUG: update-planet: could not write rss1.xml, aborting\n') + +try: + codecs.open('foaf.xml', 'wb', 'utf-8').write(xmlwriter.write(FOAFWriter.FOAFWriter)) +except: + sys.stderr.write('DEBUG: update-planet: could not write foaf.xml, aborting\n') + +try: + codecs.open('opml.xml', 'wb', 'utf-8').write(xmlwriter.write(OPMLWriter.OPMLWriter)) +except: + sys.stderr.write('DEBUG: update-planet: could not write opml.xml, aborting\n') + raise