[z3-checkins] r5566 - in z3/util/trunk: . layout resource

faassen at codespeak.net faassen at codespeak.net
Wed Jul 14 18:03:12 MEST 2004


Author: faassen
Date: Wed Jul 14 18:03:11 2004
New Revision: 5566

Removed:
   z3/util/trunk/layout/
   z3/util/trunk/mkwebsite.py
   z3/util/trunk/publish.py
   z3/util/trunk/publish_website.sh
   z3/util/trunk/resource/
Log:
This got moved into www.


Deleted: /z3/util/trunk/mkwebsite.py
==============================================================================
--- /z3/util/trunk/mkwebsite.py	Wed Jul 14 18:03:11 2004
+++ (empty file)
@@ -1,143 +0,0 @@
-#!/usr/bin/python
-import publish
-
-class Z3Page(publish.RstPage):
-    def __init__(self, package, path, name=None):
-        publish.RstPage.__init__(
-            self, publish.UrlSource(
-            'http://codespeak.net/svn/z3/%s/trunk/%s' % (package, path)),
-            name)
-
-def createWebSite(path):
-    """Create the website from various resources, and save.
-
-    path - directory to store the created website.
-    """
-
-    # the project links
-    main_project_links = [
-        ('Z3 Base', 'index.html'),
-        ('Five', 'five'),
-        ]
-    
-    # layouter for pages in the website root
-    main_layouter = publish.FileSimpleLayouter(
-        'layout/main_layout.html',
-        style='style.css',
-        banner='five-head.png',
-        site_links=main_project_links,
-        )
-
-    # construct project links for pages under main from main_project_links
-    project_links = []
-    for name, link in main_project_links:
-        if link == 'index.html':
-            link = '..'
-        else:
-            link = '../' + link
-        project_links.append((name, link))
-
-    # layouter for pages in directories under root
-    page_layouter = publish.FileSimpleLayouter(
-        'layout/layout.html',
-        style='../style.css',
-        banner='../five-head.png',
-        site_links=project_links,
-        )
-
-    # layouter for redirect pages
-    redirect_layouter = publish.FileSimpleLayouter(
-        'layout/redirect.html',
-        style='style.css',
-        banner='five-head.png',
-        site_links=project_links,
-        )
-
-    # create a website object
-    website = publish.Website(path)
-
-    # register essential resources in root of site
-    website.registerResources(
-        [
-        publish.FileResource('resource/style.css'),
-        publish.FileResource('resource/five-head.png'),
-        publish.FileResource('resource/h4_rightmenu.gif'),
-        publish.FileResource('resource/pattern.png'),
-        ],
-        '.',
-        )
-
-    # register pages for root of site
-    main_quick_links = [
-        ('svn (the code)',
-         'http://codespeak.net/svn/z3/'),
-
-        ('z3-checkins mailing list',
-         'http://codespeak.net/mailman/listinfo/z3-checkins'),
-        ]
-    
-    website.registerPages(
-        [
-        Z3Page('www', 'index.txt'),
-        ],
-        main_layouter,
-        '.',
-        quick_links=main_quick_links,
-        )
-
-    # redirect old five page
-    website.registerPages(
-        [
-        publish.SimplePage('five'),
-        ],
-        redirect_layouter,
-        '.',
-        url='http://codespeak.net/z3/five',
-        )
-
-    # construct five subsite
-    five_nav_links = [
-        ('Five main', 'index.html'),
-        ('Features', 'features.html'),
-        ('Directives', 'directives.html'),
-        ('Manual', 'manual.html')
-        ]
-
-    five_quick_links = [
-        ('svn (the code)',
-         'http://codespeak.net/svn/z3/Five/'),
-
-        ('z3-five mailing list',
-         'http://codespeak.net/mailman/listinfo/z3-five'),
-
-        ('z3-checkins mailing list',
-         'http://codespeak.net/mailman/listinfo/z3-checkins'),
-        ]
-    
-    website.registerPages(
-        [
-        Z3Page('Five', 'doc/main.txt', 'index'),
-        Z3Page('Five', 'doc/features.txt'),
-        Z3Page('Five', 'doc/directives.txt'),
-        Z3Page('Five', 'doc/manual.txt'),
-        ],
-        page_layouter,
-        'five',
-        nav_links=five_nav_links,
-        quick_links=five_quick_links,
-        )
-
-    # finally, save website
-    website.save()
-
-def main():
-    import sys
-    try:
-        path = sys.argv[1]
-    except IndexError:
-        print "usage: mkwebsite.py website_path"
-        return
-    createWebSite(path)
-    
-if __name__ == '__main__':
-    main()

Deleted: /z3/util/trunk/publish.py
==============================================================================
--- /z3/util/trunk/publish.py	Wed Jul 14 18:03:11 2004
+++ (empty file)
@@ -1,224 +0,0 @@
-from docutils import core
-import os, urllib2
-
-class Error(Exception):
-    pass
-
-class Website:
-    """A website consists of resources and pages.
-    """
-    def __init__(self, website_path):
-        self._website_path = website_path
-        self._resource_infos = []
-        self._infos = []
-
-    def registerPages(self, pages, layouter, directory, **kw):
-        """Register a set of pages.
-
-        The pages all end up in the same directory and share a layouter.
-
-        Optional keyword arguments are also passed through to all of them.
-        """
-        dir_path = os.path.join(self._website_path, directory)
-        for page in pages:
-            path = os.path.join(dir_path, page.getName())
-            self._infos.append(Info(page, layouter, path, **kw))
-
-    def registerResources(self, resources, directory):
-        """Register a set of resources.
-
-        The resources all end up in the same directroy.
-
-        Optional keyword arguments are also passed through to all of them.
-        """
-        self.registerPages(resources, None, directory)
-              
-    def save(self):
-        """Save all pages and resources.
-        """    
-        for info in self._infos:
-            info.save()
-
-class Info:
-    """Information describing what to do with a web page.
-
-    i.e. how to layout it, where to place it when done.
-    """
-    def __init__(self, resource, layouter, destination_path, **kw):
-        self._resource = resource
-        self._destination_path = destination_path
-        self._layouter = layouter
-        self._kw = kw
-         
-    def render(self):
-        return self._resource.render(self._layouter, **self._kw)
-
-    def save(self):
-        """Save this resource.
-        """
-        try:
-            os.makedirs(os.path.dirname(self._destination_path))
-        except os.error:
-            pass
-        data = self.render()
-        f = open(self._destination_path, 'w')
-        f.write(data)
-        f.close()
-
-class BaseResource:
-    """Base class of all resources.
-    """
-    def __init__(self, name):
-        self._name = name
-        
-    def getName(self):
-        """Name of resource when written.
-        """
-        return self._name
-    
-    def render(self, layouter, **kw):
-        raise NotImplementedError
-    
-class BaseDataResource(BaseResource):
-    """A resource that gets its main data from a data source.
-    """
-    def __init__(self, data_source, name=None):
-        BaseResource.__init__(self, name)
-        if self._name is None:
-            self._name = data_source.getName()
-        self._data = data_source.getData()
-        
-class Resource(BaseDataResource):
-    """A resource that is just a file.
-    """    
-    def render(self, layouter, **kw):
-        return self._data
-
-class FileResource(Resource):
-    """Simpler way to create a resource that's just a file.
-    """
-    def __init__(self, path, name=None):
-        Resource.__init__(self, PathSource(path), name)
-        
-class BasePage(BaseDataResource):
-    """Base class of all pages.
-    """
-    def __init__(self, data_source, name=None):
-        BaseDataResource.__init__(self, data_source, name)
-        self._name = os.path.splitext(self._name)[0] + '.html'
-        
-    def getData(self):
-        """Returns a dictionary with data to use in the page.
-        """
-        raise NotImplementedError
-    
-    def render(self, layouter, **kw):        
-        kw.update(self.getData())
-        return layouter.render(**kw)
-
-class RstPage(BasePage):
-    def getData(self):
-        return html_parts(self._data, initial_header_level=2)
-
-class SimplePage(BasePage):
-    def __init__(self, name):
-        self._name = name + '.html'
-        
-    def getData(self):
-        return {}
-    
-class SimpleLayouter:
-    """Simple layouter which replaces {{foo}} in a template with values.
-    """
-    def __init__(self, template, **kw):
-        self._template = template
-        self._kw = kw
-        
-    def render(self, **kw):
-        kw.update(self._kw)
-        template = self._template
-        for key, value in kw.items():
-            if type(value) in (str, unicode):
-                template = template.replace('{{%s}}' % key, value)
-            elif type(value) == type([]):
-                l = []
-                l.append('<ul>\n')
-                for name, url in value:
-                    l.append('  <li><a href="%s">%s</a></li>\n' % (url, name))
-                l.append('</ul>\n')
-                template = template.replace('{{%s}}' % key, ''.join(l))
-        return template
-
-class FileSimpleLayouter(SimpleLayouter):
-    """A layouter which loads its template from file.
-    """
-    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):
-    """
-    Given an input string, returns a dictionary of HTML document parts.
-
-    Dictionary keys are the names of parts, and values are Unicode strings;
-    encoding is up to the client.
-
-    Parameters:
-
-    - `input_string`: A multi-line text string; required.
-    - `source_path`: Path to the source file or object.  Optional, but useful
-      for diagnostic output (system messages).
-    - `destination_path`: Path to the file or object which will receive the
-      output; optional.  Used for determining relative paths (stylesheets,
-      source links, etc.).
-    - `input_encoding`: The encoding of `input_string`.  If it is an encoded
-      8-bit string, provide the correct encoding.  If it is a Unicode string,
-      use "unicode", the default.
-    - `doctitle`: Disable the promotion of a lone top-level section title to
-      document title (and subsequent section title to document subtitle
-      promotion); enabled by default.
-    - `initial_header_level`: The initial level for header elements (e.g. 1
-      for "<h1>").
-    """
-    overrides = {'input_encoding': input_encoding,
-                 'doctitle_xform': doctitle,
-                 'initial_header_level': initial_header_level}
-    parts = core.publish_parts(
-        source=input_string, source_path=source_path,
-        destination_path=destination_path,
-        writer_name='html', settings_overrides=overrides)
-    return parts
-
-
-class PathSource:
-    def __init__(self, path):
-        self._path = path
-        
-    def getName(self):
-        return os.path.basename(self._path)
-    
-    def getData(self):
-        f = open(self._path)
-        data = f.read()
-        f.close()
-        return data
-
-class UrlSource:
-    def __init__(self, url):
-        self._url = url
-        
-    def getName(self):            
-        i = self._url.rfind('/')
-        return self._url[i+1:]
-
-    def getData(self):
-        try:
-            f = urllib2.urlopen(self._url)
-        except urllib2.URLError:
-            raise Error, "Unknown url: %s" % self._url
-        data = f.read()
-        f.close()
-        return data

Deleted: /z3/util/trunk/publish_website.sh
==============================================================================
--- /z3/util/trunk/publish_website.sh	Wed Jul 14 18:03:11 2004
+++ (empty file)
@@ -1,5 +0,0 @@
-#!/bin/bash
-rm -rf /tmp/z3website
-svn export http://codespeak.net/svn/z3/www/trunk /tmp/z3website
-rsync -z -r -v -e ssh /tmp/z3website/ codespeak.net:/www/codespeak.net/htdocs/z3/
-


More information about the z3-checkins mailing list