[z3-checkins] r55556 - in z3/deliverance/sandboxes/paul/dvplone: . content etc lib var var/static

paul at codespeak.net paul at codespeak.net
Wed Jun 4 17:21:18 CEST 2008


Author: paul
Date: Wed Jun  4 17:21:16 2008
New Revision: 55556

Added:
   z3/deliverance/sandboxes/paul/dvplone/
   z3/deliverance/sandboxes/paul/dvplone/README.txt
   z3/deliverance/sandboxes/paul/dvplone/content/
   z3/deliverance/sandboxes/paul/dvplone/content/README.txt
   z3/deliverance/sandboxes/paul/dvplone/content/content1.html
   z3/deliverance/sandboxes/paul/dvplone/content/content2.html
   z3/deliverance/sandboxes/paul/dvplone/content/content3.html
   z3/deliverance/sandboxes/paul/dvplone/content/example.html
   z3/deliverance/sandboxes/paul/dvplone/etc/
   z3/deliverance/sandboxes/paul/dvplone/etc/serve.ini
   z3/deliverance/sandboxes/paul/dvplone/etc/themeset1.xml
   z3/deliverance/sandboxes/paul/dvplone/lib/
   z3/deliverance/sandboxes/paul/dvplone/lib/dvswitcher.py
   z3/deliverance/sandboxes/paul/dvplone/lib/theme1.html
   z3/deliverance/sandboxes/paul/dvplone/run.sh
   z3/deliverance/sandboxes/paul/dvplone/var/
   z3/deliverance/sandboxes/paul/dvplone/var/static/
   z3/deliverance/sandboxes/paul/dvplone/var/theme1.html
   z3/deliverance/sandboxes/paul/dvplone/var/theme2.html
Log:
Beginning of a demo for Plone theming

Added: z3/deliverance/sandboxes/paul/dvplone/README.txt
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/README.txt	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,50 @@
+==================================================
+Demo Site for Plone with DVNG
+==================================================
+
+This directory contains a Paste application that demos the use of
+Deliverance (via DVNG) for themeswitching of Plone content.
+
+Quick Start
+-------------------
+
+1) Make sure that lxml, Paste, WSGIFilter, etc. are installed.
+
+2) Make sure that the parent of this directory contains ``dvng``.
+
+3) ``sh run.sh``
+
+4) Go to ``http://localhost:8080``
+
+Nutshell
+---------------
+
+1) Simulate Plone *content* (unthemed) on disk using HTML files.
+
+2) Provide multiple DVNG themes, based on Plone and NuPlone.
+
+3) Simulate using site setup to browse, install, and uninstall
+Deliverance "compiled themeset" packages.
+
+4) Illustrate some extended possibilities of WSGI middleware.
+
+
+Directories
+-------------
+
+- ``content`` contains HTML4 pages mimicking what Plone would be
+  producing
+
+- ``etc`` is the configuration information
+
+- ``var`` contains the volatile site information.  For example:
+
+  - Cached versions of the themeset information that Plone said to
+    use, such as the static CSS/JS/PNG for each theme
+
+  - Debug information from DVNG, to see each stage of the DVNG process
+    (the HTML4 coming in for each request, the HTML going out)
+
+- ``lib`` contains the WSGI application and filters used to both
+  simulate the Plone site and apply the themes.
+

Added: z3/deliverance/sandboxes/paul/dvplone/content/README.txt
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/content/README.txt	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,25 @@
+==================================================
+Sample Plone Content
+==================================================
+
+This directory contains examples of the content in the root folder of
+a Plone site.  In essence, this will be the HTML returned, as normal,
+by Plone.  With, though, the following caveats:
+
+- The content is unthemed.  In this case, "themed" means the
+  Deliverance idea of a "theme", which is the corporate identity.  The
+  content is still "skinned", which includes all portlets, navtrees,
+  and breadcrumbs information (if not in final markup.)
+
+- Much more semantic.  This is an experiment in making Plone more
+  content-oriented.  The HTML produced should be less about the
+  one-and-only user interface.  Alternative UIs, generated on the
+  outside, need convenient access to the information in a stable
+  fashion.
+
+- This demo presumes all the content is HTML4 with no XHTML namespace.
+
+The pages themselves are a guided tour of dvplone.  The ``index.html``
+page provides an overview of some of the features provided in this
+demonstration of Deliverance + Plone.
+

Added: z3/deliverance/sandboxes/paul/dvplone/content/content1.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/content/content1.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,20 @@
+<html>
+    <head>
+        <title>Red Balloons for Neanderthals</title>
+    </head>
+    <body>
+        <ul id="related">
+            <li><a href="item1">Item One</a></li>
+            <li><a href="item2">Item Two</a></li>
+        </ul>
+        <ul id="breadcrumbs">
+            <li><a href="/">Home</a></li>
+            <li><a href="/articles">Articles</a></li>
+            <li>Red Balloons for Neanderthals</li>
+        </ul>
+        <div id="content">
+            <p>The article text <em>goes here</em>.</p>
+            <p>More content here.</p>
+        </div>
+    </body>
+</html>

Added: z3/deliverance/sandboxes/paul/dvplone/content/content2.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/content/content2.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,23 @@
+<html>
+    <head>
+        <title>Red Balloons for Neanderthals</title>
+        <meta name="dv.section" content="DVNG Articles"/>
+        <meta name="dcmi.author" content="Grok Smasher"/>
+        <meta name="dcmi.modified" content="2007/02/21"/>
+    </head>
+    <body>
+        <ul id="related">
+            <li><a href="item1">Item One</a></li>
+            <li><a href="item2">Item Two</a></li>
+        </ul>
+        <ul id="breadcrumbs">
+            <li><a href="/">Home</a></li>
+            <li><a href="/articles">Articles</a></li>
+            <li>Red Balloons for Neanderthals</li>
+        </ul>
+        <div id="content">
+            <p>The article text <em>goes here</em>.</p>
+            <p>More content here.</p>
+        </div>
+    </body>
+</html>

Added: z3/deliverance/sandboxes/paul/dvplone/content/content3.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/content/content3.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,24 @@
+<html>
+    <head>
+        <title>Red Balloons for Neanderthals</title>
+        <meta name="dv.section" content="DVNG Articles"/>
+        <meta name="dcmi.type" content="Gallery Page"/>
+        <meta name="dcmi.author" content="Grok Smasher"/>
+        <meta name="dcmi.modified" content="2007/02/21"/>
+    </head>
+    <body>
+        <ul id="related">
+            <li><a href="item1">Item One</a></li>
+            <li><a href="item2">Item Two</a></li>
+        </ul>
+        <ul id="breadcrumbs">
+            <li><a href="/">Home</a></li>
+            <li><a href="/articles">Articles</a></li>
+            <li>Red Balloons for Neanderthals</li>
+        </ul>
+        <div id="content">
+            <p>The article text <em>goes here</em>.</p>
+            <p>More content here.</p>
+        </div>
+    </body>
+</html>

Added: z3/deliverance/sandboxes/paul/dvplone/content/example.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/content/example.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,14 @@
+<html>
+  <head>
+    <title>Title from example.html</title>
+    <link rel="stylesheet" type="text/css" href="theme.css"/>
+  </head>
+  <body>
+    <div id="content">
+      <h4>Here</h4>
+      <h1>Content from the theme</h1>
+      <p>From the content file (example.html), not the
+    theme. No.  </p>
+    </div>
+  </body>
+</html>

Added: z3/deliverance/sandboxes/paul/dvplone/etc/serve.ini
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/etc/serve.ini	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,20 @@
+[server:main]
+use = egg:Paste#http
+
+[pipeline:main]
+pipeline = egg:Paste#evalerror
+	 egg:Paste#httpexceptions
+	 dvng
+	 content
+
+[app:content]
+use = egg:Paste#static
+document_root = %(here)s/../content
+
+[filter:dvng]
+paste.filter_app_factory = dvswitcher:make_dvng
+
+[filter:deliverance]
+paste.filter_app_factory = deliverance.wsgimiddleware:make_filter
+theme_uri = http://repoze.org/index.html
+rule_uri = file:///%(here)s/rules.xml
\ No newline at end of file

Added: z3/deliverance/sandboxes/paul/dvplone/etc/themeset1.xml
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/etc/themeset1.xml	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?oxygen RNGSchema="themeset.rng" type="xml"?>
+<themeset xmlns="http://openplans.org/deliverance">
+  <customizers theme="themecustom.xsl" content="contentcustom.xsl"/>
+  <theme href="var/theme2.html">
+    <!-- A pretty theme with a sidebar -->
+    <pagetype>
+      <match>
+        <content>/html</content>
+      </match>
+      <rules>
+        <replace theme="//td/h1[@id='pageheading']" content="/html/head/title"/>
+        <replace theme="//div[@id='pagecontent']" content="/html/body/div[@id='content']"/>
+        <replace theme="//ul[@id='navmenu']" content="/html/body/ul[@id='related']"/>
+        <replace theme="//ul[@id='breadcrumbs']" content="/html/body/ul[@id='breadcrumbs']"/>
+      </rules>
+    </pagetype>
+    <match>
+      <!-- These are OR'd together -->
+      <content>/html/head/meta[@name='dv.section']</content>
+      <req key="domain_url">look-at-me.com</req>
+    </match>
+    <rules>
+      <replace theme="//td/h1[@id='pageheading']" content="/html/head/title"/>
+    </rules>
+  </theme>
+  <theme href="var/theme1.html">
+    <rules>
+      <replace theme="//div[@id='pagecontent']" content="/html/body/div[@id='content']"/>
+    </rules>
+  </theme>
+</themeset>

Added: z3/deliverance/sandboxes/paul/dvplone/lib/dvswitcher.py
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/lib/dvswitcher.py	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,35 @@
+"""WSGI middleware to switch Deliverance themes"""
+
+from dvngcompiler import DVNG
+import os
+import lxml.html
+from lxml import etree
+from wsgifilter import Filter
+
+class DVNGFilter(Filter):
+
+    def __init__(self, app, etcdir):
+        self.app = app
+        themesetfn = os.path.join(etcdir, "themeset1.xml")
+        self.dvng = DVNG(themesetfn)
+
+        # Make an XSLT processor from the compiled theme
+        self.processor = etree.XSLT(self.dvng.xslt)
+
+    def filter(self, environ, headers, data):
+
+        # Turn incoming HTML4 data into etree, apply XSLT
+        htmldoc = lxml.html.document_fromstring(data)
+        result = self.processor(htmldoc)
+        response = str(result)
+        return response
+
+#    def __call__(self, environ, start_response):
+#        response_iter = self.app(environ, start_response)
+#        return response_iter
+
+def make_dvng(app, global_conf, **kw):
+    """Choose which Deliverance theme should be used"""
+
+    etcdir = global_conf['here']
+    return DVNGFilter(app, etcdir)

Added: z3/deliverance/sandboxes/paul/dvplone/lib/theme1.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/lib/theme1.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,11 @@
+<html>
+    <head>
+        <title>Theme Page Title</title>
+    </head>
+    <body>
+        <h1 id="pageheading">Theme Page Heading</h1>
+        <div id="pagecontent">
+            <p>Some sample theme content.</p>
+        </div>
+    </body>
+</html>
\ No newline at end of file

Added: z3/deliverance/sandboxes/paul/dvplone/run.sh
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/run.sh	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,2 @@
+
+PYTHONPATH=.:lib:../dvng paster serve etc/serve.ini
\ No newline at end of file

Added: z3/deliverance/sandboxes/paul/dvplone/var/theme1.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/var/theme1.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,11 @@
+<html>
+    <head>
+        <title>Theme Page Title</title>
+    </head>
+    <body>
+        <h1 id="pageheading">Theme Page Heading, No, No, No</h1>
+        <div id="pagecontent">
+            <p>Some sample theme content.</p>
+        </div>
+    </body>
+</html>

Added: z3/deliverance/sandboxes/paul/dvplone/var/theme2.html
==============================================================================
--- (empty file)
+++ z3/deliverance/sandboxes/paul/dvplone/var/theme2.html	Wed Jun  4 17:21:16 2008
@@ -0,0 +1,20 @@
+<html>
+    <head>
+        <title>Second Theme Page Title</title>
+    </head>
+    <body>
+        <table border="0" height="300" cellpadding="20">
+            <tr>
+                <td width="200" bgcolor="gray" valign="top">
+                    <h2 align="center">Navigation</h2>
+                    <ul id="navmenu"/>
+                </td>
+                <td valign="top">
+                    <ul id="breadcrumbs"/>
+                    <h1 id="pageheading">Theme Page Heading</h1>
+                    <div id="pagecontent">Theme content to replace.</div>
+                </td>
+            </tr>
+        </table>
+    </body>
+</html>


More information about the z3-checkins mailing list