Improved XMLWriter
authordavyd <davyd>
Sat, 7 Feb 2004 08:17:45 +0000 (08:17 +0000)
committerdavyd <davyd>
Sat, 7 Feb 2004 08:17:45 +0000 (08:17 +0000)
Initial Upload of HTML formatting, etc.

XMLWriter.py
footer.html [new file with mode: 0644]
planet.css [new file with mode: 0644]
sidebar.html [new file with mode: 0644]

index 267789c..8a443ba 100644 (file)
@@ -72,10 +72,12 @@ class Planet:
 
 class XMLWriter:
        def __init__(self, doctype, bloglist):
+               self.blogs      = bloglist
                self.planet     = Planet(bloglist)
                self.items      = self.planet.sort()
                # doctype should be something like XMLWriter.XHTMLWriter
-               self.writer     = doctype(self.items)
+               self.writer             = doctype(self.items)
+               self.writer.parent      = self
        
        def write(self):
                output          = self.writer.write()
@@ -84,18 +86,22 @@ class XMLWriter:
 class XHTMLWriter:
        def __init__(self, planet):
                self.planet     = planet
-               self.maxitems   = 100
+               self.maxitems   = 50
+               self.parent     = None
        
        def __write_item__(self, item):
                output  =       ''
                output  +=      '<div id="item">\n'
                output  +=      '<h2>%s: %s</h2>\n' % (item.blogTitle, item.itemTitle)
                output  +=      '<p class="time">\n'
-               output  +=      '(%s)\n' % time.strftime('%A %B %d, %Y %H:%M %Z', time.localtime(item.itemDate))
+               if item.imageURL:
+                       output += '<a class="image" href="%s"><img class="image" src="%s" alt="%s" /></a>\n' % (item.imageLink, item.imageURL, item.blogTitle)
+               output  +=      '(<a href="%s">%s</a>)\n' % (item.itemURL ,time.strftime('%A %B %d, %Y %H:%M %Z', time.localtime(item.itemDate)))
                output  +=      '</p>\n'
                output  +=      '<p class="body">\n'
                output  +=      item.contents
                output  +=      '\n</p>\n'
+               output  +=      '</div>'
                return output
        
        def write(self):
@@ -106,10 +112,24 @@ class XHTMLWriter:
                output  +=      '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >\n'
                output  +=      '<head>\n'
                output  +=      '<title>Planet UCC</title>\n'
-               # XXX: we'll want a style sheet in here
+               output  +=      '<link rel="stylesheet" href="planet.css" type="text/css" media="screen" />\n'
                output  +=      '</head>\n'
                output  +=      '<body>\n'
-               # XXX: we want some stuff in here, I'm sure
+               output  +=      '<div id="header">\n'
+               output  +=      '</div>\n'
+               output  +=      '<div id="sidebar">\n'
+               try:
+                       output  +=      open('sidebar.html').read()
+               except:
+                       pass
+               if self.parent:
+                       output  +=      '<h2>Feeds</h2>\n'
+                       output  +=      '<p>\n'
+                       for blog in self.parent.blogs:
+                               output  += '<a href="%s">%s</a><br />\n' % (blog.blogURL, blog.blogTitle)
+                       output  +=      '</p>\n'
+               output  +=      '</div>\n'
+               output  +=      '<div id="items">\n'
                for date in self.planet:
                        output  += '<h1>%s</h1>\n' % time.strftime('%A %B %d, %Y', time.localtime(date.planetDate))
                        for item in date.items:
@@ -121,7 +141,12 @@ class XHTMLWriter:
                        # again, check to see if we've written the maximum number of items
                        if itemcount >= self.maxitems:
                                break
-               # XXX: we want further stuff here
-               output  +=      '</body>'
+               output  +=      '</div>\n'
+               output  +=      '<div id="footer">\n'
+               try:
+                       output  +=      open('footer.html').read()
+               except:
+                       pass
+               output  +=      '</body>\n'
                output  +=      '</html>'
                return output
diff --git a/footer.html b/footer.html
new file mode 100644 (file)
index 0000000..d1d646e
--- /dev/null
@@ -0,0 +1,6 @@
+<p>
+ Planet UCC &copy; 2004, Davyd Madeley
+ &lt;<a href="mailto:[email protected]">[email protected]</a>&gt;<br />
+ Written to be <a href="http://www.w3c.org/">specifications compliant</a>.<br />
+ <a href="mailto:[email protected]">[email protected]</a>
+</p>
diff --git a/planet.css b/planet.css
new file mode 100644 (file)
index 0000000..2ac8cba
--- /dev/null
@@ -0,0 +1,106 @@
+DIV#sidebar {
+       position: absolute;
+       right: 0.5em;
+       width: 13.5em;
+}
+
+DIV#sidebar h2 {
+       background-color: black;
+       color: white;
+       font-size: 1em;
+       font-family: sans-serif;
+       margin: 0;
+       margin-top: 1ex;
+       padding: 0.5ex;
+}
+
+DIV#sidebar p {
+       border-color: black;
+       border-style: solid;
+       border-width: 1pt;
+       margin: 0;
+       padding: 0.5ex;
+}
+
+DIV#sidebar a {
+       color: blue;
+       text-decoration: underline;
+}
+DIV#sidebar a:visited {
+       color: blue;
+       text-decoration: underline;
+}
+
+DIV#items {
+       padding-right: 14em;
+}
+
+DIV#items h1 {
+       background-color: black;
+       color: white;
+       font-size: 1.5em;
+       font-family: sans-serif;
+       padding: 0.5ex;
+}
+
+DIV#item {
+       padding: 0.5em;
+}
+
+DIV#item h2 {
+       background-color: #dddddd;
+       color: black;
+       font-size: 1em;
+       font-family: sans-serif;
+       padding: 0.5ex;
+}
+
+DIV#item a > img {
+       border-style: none;
+       padding-left: 0.5ex;
+       padding-right: 0.5ex;
+}
+
+DIV#item img.image {
+       float: right;
+       margin: 10pt;
+       padding: 0em;
+}
+
+DIV#item p.body {
+       padding: 0.5em;
+}
+
+DIV#item p.time {
+       color: #999999;
+}
+
+DIV#item p.body a {
+       color: blue;
+       text-decoration: underline;
+}
+DIV#item p.body a:visited {
+       color: blue;
+       text-decoration: underline;
+}
+DIV#item p.time a {
+       color: #999999;
+       text-decoration: none;
+}
+DIV#item p.time a:visited {
+       color: #999999;
+       text-decoration: none;
+}
+
+DIV#footer {
+       color: #999999;
+       text-align: center;
+}
+DIV#footer a {
+       color: #5555AA;
+       text-decoration: underline;
+}
+DIV#footer a:visited {
+       color: #5555AA;
+       text-decoration: underline;
+}
diff --git a/sidebar.html b/sidebar.html
new file mode 100644 (file)
index 0000000..6836a8e
--- /dev/null
@@ -0,0 +1,6 @@
+<h2>About Planet UCC</h2>
+<p>
+ Planet UCC is an aggregation of weblogs
+ for UCC members.<br />
+ It is currently in Beta.
+</p>

UCC git Repository :: git.ucc.asn.au