[z3-checkins] r5397 - z3/util/trunk

faassen at codespeak.net faassen at codespeak.net
Wed Jun 30 11:22:59 MEST 2004


Author: faassen
Date: Wed Jun 30 11:22:58 2004
New Revision: 5397

Added:
   z3/util/trunk/five_layout.html
Modified:
   z3/util/trunk/mkwebsite.py
   z3/util/trunk/publish.py
Log:
More improvements to web publication scripts. Not quite there yet, but
making progress.


Added: z3/util/trunk/five_layout.html
==============================================================================
--- (empty file)
+++ z3/util/trunk/five_layout.html	Wed Jun 30 11:22:58 2004
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+     "DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>{{title}}</title>
+<link rel="stylesheet" type="text/css" href="{{style}}" title="Design" />
+</head>
+<body>
+
+<div id="Header">
+  <div id="Backgroundimage">
+        <img src="five-head.png"
+        title="background-image" />
+  </div>
+  <ul>
+    <li>
+    <a href="index.html" class="home" title="Z3 Base">Z3 Base</a>
+    </li>
+    <li>
+    <a href="five.html" class="home" title="Five">Five</a>
+    </li>
+    <li>
+    <a href="modzope.html" class="home" title="Mod Zope">Mod Zope</a>
+    </li>
+    <li>
+    <a href="zopexml.html" class="home" title="Zope XML">Zope XML</a>
+    </li>
+  </ul>
+</div>
+
+<div id="Box">
+
+<div id="RightMenu">
+<h4>Quick links</h4>
+<ul>
+  <li>
+    <a href="http://codespeak.net/svn/z3/Five/">svn (the code)</a>
+  </li>
+  <li>
+    <a href="http://codespeak.net/mailman/listinfo/z3-five">z3-five mailing list</a>
+  </li>
+  <li>
+    <a href="http://codespeak.net/mailman/listinfo/z3-checkins">z3-checkins mailing list</a>
+  </li>
+</ul>
+</div>
+
+<div id="Content">
+<h1>{{title}}</h1>
+{{body}}
+</div>
+</div>
+</body>
+</html>

Modified: z3/util/trunk/mkwebsite.py
==============================================================================
--- z3/util/trunk/mkwebsite.py	(original)
+++ z3/util/trunk/mkwebsite.py	Wed Jun 30 11:22:58 2004
@@ -1,23 +1,34 @@
 import publish
+
+class Z3Page(publish.UrlPage):
+    def __init__(self, package, path, name=None):
+        publish.UrlPage.__init__(
+            self,
+            'http://codespeak.net/svn/z3/%s/trunk/%s' % (package, path),
+            name)
+
 website = publish.Website('/home/faassen/tmp/testwebsite')
 
-f = open('/home/faassen/working/z3/util/layout.html')
-data = f.read()
-f.close()
-five_layouter = publish.SimpleLayouter(data, style='../style.css')
-z3_layouter = publish.SimpleLayouter(data, style='style.css')
+z3_layouter = publish.FileSimpleLayouter(
+    'layout.html',
+    style='style.css')
+
+five_layouter = publish.FileSimpleLayouter(
+    'five_layout.html',
+    style='../style.css')
 
 website.registerPages(
     [
-    publish.FilePage('test.txt'),
-    publish.FilePage('test2.txt'),
+    Z3Page('www', 'index.txt'),
     ],
     z3_layouter,
     '.')
 
 website.registerPages(
     [
-    publish.UrlPage('http://codespeak.net/svn/z3/Five/trunk/doc/features.txt'),
+    Z3Page('Five', 'doc/main.txt', 'index'),
+    Z3Page('Five', 'doc/features.txt'),
+    Z3Page('Five', 'doc/manual.txt'),
     ],
     five_layouter,
     'five')

Modified: z3/util/trunk/publish.py
==============================================================================
--- z3/util/trunk/publish.py	(original)
+++ z3/util/trunk/publish.py	Wed Jun 30 11:22:58 2004
@@ -1,6 +1,9 @@
 from docutils import core
 import os, urllib2
 
+class Error(Exception):
+    pass
+
 class Website:
     def __init__(self, website_path):
         self._website_path = website_path
@@ -46,27 +49,38 @@
         return layouter.render(**self.getRstData())
 
 class UrlPage(RstPage):
-    def __init__(self, url):
+    def __init__(self, url, name=None):
         self._url = url
-
+        self._name = name
+        
     def getName(self):
-        i = self._url.rfind('/')
-        name = self._url[i+1:]
-        return os.path.splitext(name)[0] + '.html'
+        name = self._name
+        if name is None:
+            i = self._url.rfind('/')
+            name = self._url[i+1:]
+            name = os.path.splitext(name)[0]
+        return name + '.html'
 
     def getRawData(self):
-        f = urllib2.urlopen(self._url)
+        try:
+            f = urllib2.urlopen(self._url)
+        except urllib2.URLError:
+            raise Error, "Unknown url: %s" % self._url
         data = f.read()
         f.close()
         return data
     
 class FilePage(RstPage):
-    def __init__(self, path):
+    def __init__(self, path, name=None):
         self._path = path
-
+        self._name = name
+        
     def getName(self):
-        name = os.path.basename(self._path)
-        return os.path.splitext(name)[0] + '.html'
+        name = self._name
+        if name is None:
+            name = os.path.basename(self._path)
+            name = os.path.splitext(name)[0]
+        return name + '.html'
 
     def getRawData(self):
         f = open(self._path)
@@ -87,7 +101,14 @@
         for key, value in kw.items():
             layout = layout.replace('{{%s}}' % key, value)
         return layout
-   
+
+class FileSimpleLayouter(SimpleLayouter):
+    def __init__(self, path, **kw):
+        f = open(path, 'r')
+        data = f.read()
+        f.close()
+        SimpleLayouter.__init__(self, data, **kw)
+        
 def html_parts(input_string, source_path=None, destination_path=None,
                input_encoding='unicode', doctitle=1, initial_header_level=1):
     """


More information about the z3-checkins mailing list