--- /dev/null
+#
+# 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.
+#
+#
+
+class FOAFWriter:
+ def __init__(self, planet):
+ self.parent = None
+
+ def __write_item__(self, blog):
+ output = ''
+ output += '<foaf:member>\n'
+ output += ' <foaf:Agent>\n'
+ output += ' <foaf:name>%s</foaf:name>\n' % blog.blogName
+ output += ' <foaf:weblog>\n'
+ output += ' <foaf:Document rdf:about="%s" />\n' % blog.blogURL
+ output += ' <dc:title>%s</dc:title>\n' % blog.blogTitle
+ output += ' <rdfs:seeAlso>\n'
+ output += ' <rss:channel rdf:about="%s" />\n' % blog.feedURL
+ output += ' </rdfs:seeAlso>\n'
+ output += ' </foaf:Document>\n'
+ output += ' </foaf:weblog>\n'
+ output += ' </foaf:Agent>\n'
+ output += '</foaf:member>\n'
+ return output
+
+ def write(self):
+ itemcount = 0
+ output = ''
+ output += '<rdf:RDF>\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 += ' <foaf:Group>\n'
+ output += ' <foaf:name>Planet UCC</foaf:name>\n'
+ output += ' <foaf:homepage>http://planet.ucc.asn.au/</foaf:homepage>\n'
+ output += ' <rdfs:seeAlso rdf:resource="http://planet.ucc.asn.au/foaf.xml" />\n'
+ for blog in self.parent.blogs:
+ output += self.__write_item__(blog)
+ output += ' </foaf:Group>\n'
+ output += '</rdf:RDF>'
+ return output