[z3-checkins] r5557 - in z3/util/trunk: . layout resources
faassen at codespeak.net
faassen at codespeak.net
Wed Jul 14 16:50:31 MEST 2004
Author: faassen
Date: Wed Jul 14 16:50:30 2004
New Revision: 5557
Added:
z3/util/trunk/layout/
z3/util/trunk/layout/layout.html
- copied unchanged from r5554, z3/util/trunk/layout.html
z3/util/trunk/layout/main_layout.html
- copied unchanged from r5554, z3/util/trunk/main_layout.html
z3/util/trunk/layout/redirect.html
- copied, changed from r5554, z3/util/trunk/redirect.html
z3/util/trunk/resources/
z3/util/trunk/resources/five-head.png (contents, props changed)
z3/util/trunk/resources/h4_rightmenu.gif (contents, props changed)
z3/util/trunk/resources/pattern.png (contents, props changed)
z3/util/trunk/resources/style.css
Removed:
z3/util/trunk/five_layout.html
z3/util/trunk/layout.html
z3/util/trunk/main_layout.html
z3/util/trunk/redirect.html
Modified:
z3/util/trunk/mkwebsite.py
z3/util/trunk/publish.py
Log:
Refactoring of website production scripts. Can now include resources.
Also reorganized directory structure.
Deleted: /z3/util/trunk/five_layout.html
==============================================================================
--- /z3/util/trunk/five_layout.html Wed Jul 14 16:50:30 2004
+++ (empty file)
@@ -1,56 +0,0 @@
-<?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=".." class="home" title="Z3 Base">Z3 Base</a>
- </li>
- <li>
- <a href="index.html" class="home" title="Five">Five</a>
- </li>
- <li>
- <a href="../modzope" class="home" title="Mod Zope">Mod Zope</a>
- </li>
- <li>
- <a href="../zopexml" 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>
Deleted: /z3/util/trunk/layout.html
==============================================================================
--- /z3/util/trunk/layout.html Wed Jul 14 16:50:30 2004
+++ (empty file)
@@ -1,35 +0,0 @@
-<?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="{{banner}}"
- title="background-image" />
- </div>
- {{site_links}}
-</div>
-
-<div id="Box">
-
-<div id="RightMenu">
-<h4>Nav links</h4>
-{{nav_links}}
-<h4>Quick links</h4>
-{{quick_links}}
-</div>
-
-<div id="Content">
-<h1>{{title}}</h1>
-{{body}}
-</div>
-</div>
-</body>
-</html>
Copied: z3/util/trunk/layout/redirect.html (from r5554, z3/util/trunk/redirect.html)
==============================================================================
--- z3/util/trunk/redirect.html (original)
+++ z3/util/trunk/layout/redirect.html Wed Jul 14 16:50:30 2004
@@ -23,7 +23,7 @@
<h1>This page has moved</h1>
<p>
This page has moved. Please adjust your bookmarks. You will be
-redirected automatically in five seconds, or you can click to <a
+redirected automatically in five seconds, or you can click <a
href="{{url}}">here</a>
</p>
</div>
Deleted: /z3/util/trunk/main_layout.html
==============================================================================
--- /z3/util/trunk/main_layout.html Wed Jul 14 16:50:30 2004
+++ (empty file)
@@ -1,33 +0,0 @@
-<?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="{{banner}}"
- title="background-image" />
- </div>
- {{site_links}}
-</div>
-
-<div id="Box">
-
-<div id="RightMenu">
-<h4>Quick links</h4>
-{{quick_links}}
-</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 Jul 14 16:50:30 2004
@@ -1,16 +1,16 @@
import publish
-class Z3Page(publish.UrlPage):
+class Z3Page(publish.RstPage):
def __init__(self, package, path, name=None):
- publish.UrlPage.__init__(
- self,
- 'http://codespeak.net/svn/z3/%s/trunk/%s' % (package, path),
+ publish.RstPage.__init__(
+ self, publish.UrlSource(
+ 'http://codespeak.net/svn/z3/%s/trunk/%s' % (package, path)),
name)
website = publish.Website('/home/faassen/tmp/testwebsite')
main_layouter = publish.FileSimpleLayouter(
- 'main_layout.html',
+ 'layout/main_layout.html',
style='style.css',
banner='five-head.png',
site_links=[('Z3 Base', 'index.html'),
@@ -24,14 +24,14 @@
]
page_layouter = publish.FileSimpleLayouter(
- 'layout.html',
+ 'layout/layout.html',
style='../style.css',
banner='../five-head.png',
site_links=page_site_links,
)
redirect_layouter = publish.FileSimpleLayouter(
- 'redirect.html',
+ 'layout/redirect.html',
style='style.css',
banner='five-head.png',
site_links=page_site_links,
@@ -83,4 +83,15 @@
url='http://codespeak.net/z3/five',
)
+# register essential resources
+website.registerResources(
+ [
+ publish.FileResource('resources/style.css'),
+ publish.FileResource('resources/five-head.png'),
+ publish.FileResource('resources/h4_rightmenu.gif'),
+ publish.FileResource('resources/pattern.png'),
+ ],
+ '.',
+ )
+
website.save()
Modified: z3/util/trunk/publish.py
==============================================================================
--- z3/util/trunk/publish.py (original)
+++ z3/util/trunk/publish.py Wed Jul 14 16:50:30 2004
@@ -5,31 +5,57 @@
pass
class Website:
+ """A website consists of resources and pages.
+ """
def __init__(self, website_path):
self._website_path = website_path
- self._page_infos = []
+ 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(self._website_path, directory)
- path = os.path.join(path, page.getName())
- self._page_infos.append(PageInfo(page, layouter, path, **kw))
-
+ 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):
- for page_info in self._page_infos:
- page_info.save()
+ """Save all pages and resources.
+ """
+ for info in self._infos:
+ info.save()
-class PageInfo:
- def __init__(self, page, layouter, destination_path, **kw):
- self._page = page
- self._layouter = layouter
+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._page.render(self._layouter, **self._kw)
-
+ 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:
@@ -39,87 +65,93 @@
f.write(data)
f.close()
-class SimplePage:
+class BaseResource:
+ """Base class of all resources.
+ """
def __init__(self, name):
self._name = name
def getName(self):
- return self._name + '.html'
-
+ """Name of resource when written.
+ """
+ return self._name
+
def render(self, layouter, **kw):
- return layouter.render(**kw)
+ raise NotImplementedError
-class RstPage:
+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):
- kw.update(self.getRstData())
+ 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)
- def getRstData(self):
- return html_parts(self.getRawData(), initial_header_level=2)
+class RstPage(BasePage):
+ def getData(self):
+ return html_parts(self._data, initial_header_level=2)
-class UrlPage(RstPage):
- def __init__(self, url, name=None):
- self._url = url
- self._name = name
+class SimplePage(BasePage):
+ def __init__(self, name):
+ self._name = name + '.html'
- def getName(self):
- 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):
- try:
- f = urllib2.urlopen(self._url)
- except urllib2.URLError:
- raise Error, "Unknown url: %s" % self._url
- data = f.read()
- f.close()
- return data
+ def getData(self):
+ return {}
-class FilePage(RstPage):
- def __init__(self, path, name=None):
- self._path = path
- self._name = name
-
- def getName(self):
- 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)
- data = f.read()
- f.close()
- return data
-
class SimpleLayouter:
- """Simple layouter which replaces {{foo}} with values.
+ """Simple layouter which replaces {{foo}} in a template with values.
"""
- def __init__(self, layout, **kw):
- self._layout = layout
+ def __init__(self, template, **kw):
+ self._template = template
self._kw = kw
def render(self, **kw):
kw.update(self._kw)
- layout = self._layout
+ template = self._template
for key, value in kw.items():
if type(value) in (str, unicode):
- layout = layout.replace('{{%s}}' % key, value)
+ 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')
- layout = layout.replace('{{%s}}' % key, ''.join(l))
- return layout
+ 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()
@@ -159,3 +191,34 @@
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/redirect.html
==============================================================================
--- /z3/util/trunk/redirect.html Wed Jul 14 16:50:30 2004
+++ (empty file)
@@ -1,33 +0,0 @@
-<?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>
-<meta http-equiv="REFRESH" content="5; URL={{url}}">
-<title>Redirect page</title
-<link rel="stylesheet" type="text/css" href="{{style}}" title="Design" />
-</head>
-<body>
-
-<div id="Header">
- <div id="Backgroundimage">
- <img src="{{banner}}"
- title="background-image" />
- </div>
- {{site_links}}
-</div>
-
-<div id="Box">
-<div id="Content">
-<h1>This page has moved</h1>
-<p>
-This page has moved. Please adjust your bookmarks. You will be
-redirected automatically in five seconds, or you can click to <a
-href="{{url}}">here</a>
-</p>
-</div>
-</div>
-
-</body>
-</html>
Added: z3/util/trunk/resources/five-head.png
==============================================================================
Binary file. No diff available.
Added: z3/util/trunk/resources/h4_rightmenu.gif
==============================================================================
Binary file. No diff available.
Added: z3/util/trunk/resources/pattern.png
==============================================================================
Binary file. No diff available.
Added: z3/util/trunk/resources/style.css
==============================================================================
--- (empty file)
+++ z3/util/trunk/resources/style.css Wed Jul 14 16:50:30 2004
@@ -0,0 +1,234 @@
+body {
+ background-color: #ffffff;
+ color: #333;
+ font-size: 11px;
+ font-family: sans-serif;
+ margin: 0;
+ padding; 0;
+ background: url("pattern.png");
+ text-align: center;
+}
+
+a { text-decoration: none; }
+
+a:link { color: #111199; }
+
+a:visited { color: #991199; }
+
+a:hover {
+ color: red;
+ border-style: none;
+ text-decoration: underline;
+ background-color: transparent;
+}
+
+a img { padding: 0; }
+
+a:hover img { border: 1px solid red; }
+
+#Header {
+ margin: 0 auto;
+ width: 686px;
+ border: 1px solid #555;
+ background-color: #5555ff;
+}
+
+#Backgroundimage img{
+ margin: 0;
+ padding: 0;
+ border-bottom: 2px solid black;
+}
+
+/* the navigation */
+#Header ul {
+ height: 1.3em;
+ margin: 0;
+ padding: 0.3em 0.5em;
+ white-space: nowrap;
+ font-size: 11px;
+ padding: 0;
+}
+
+#Header ul li {
+ float: left;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+#Header ul li a {
+ text-transform: lowercase;
+ display: block;
+ margin: 0;
+ padding: 0 10px;
+}
+
+#Header a {
+ color: white;
+}
+
+#Header ul li a:hover {
+ color: #111199;
+ text-decoration: none;
+ background-color: #dddddd;
+}
+
+#Box {
+ margin: 0 auto;
+ width: 686px;
+ padding: 0px;
+ text-align: left;
+ border: 1px solid black;
+ border-top: 2px solid #999;
+ background-color: #dddddd;
+}
+
+#Footer {
+ margin: 0 auto;
+ width: 686px;
+ border: 1px solid black;
+ border-top: 0;
+ margin-bottom: 10px;
+ background-color: #d6d6d6;
+}
+
+#Footer a img {
+ border: 0;
+}
+
+#RightMenu {
+ width: 200px;
+ background-color: transparent;
+ color: #666;
+ float: right;
+ padding: 1em 0.5em 0 0.5em;
+}
+
+#RightMenu h4 {
+ font-size: 10px;
+ padding-left: 10px;
+ display: block;
+ border-bottom: 1px dotted #999;
+ background: url("h4_rightmenu.gif") no-repeat left center;
+ color: #888;
+}
+
+#RightMenu a { color: #111199; }
+#Rightmenu a:hover { color: red; }
+#Rightmenu a:visited { color: #991199; }
+
+#RightMenu ul {
+ margin: 0;
+ padding-left: 10px;
+ list-style: circle;
+}
+
+#RightMenu a img {
+ border: 1px solid black;
+}
+
+#RightMenu a:hover img {
+ border: 1px solid red;
+}
+
+#Content {
+ margin: 0;
+ border: 0px;
+ border-right: 1px dotted #CCC;
+ padding: 1em 0.5em 0 0.5em;
+ width: 450px;
+ font-size: 11px;
+}
+
+#Content h4 {
+ font-size: 130%;
+ border-bottom: 2px dotted black;
+ text-align: left;
+ font-family: Georgia, serif;
+}
+
+#Content a img { border: 1px solid black; }
+
+#Content a:hover img { border: 1px solid red; }
+
+#Content a { text-decoration: underline; }
+
+#Content h1 a { text-decoration: none; }
+
+#Content h2 a { text-decoration: none; }
+
+#Content h3 a { text-decoration: none; }
+
+#Content h4 a { text-decoration: none; }
+
+#Content h5 a { text-decoration: none; }
+
+#Content p.par-image {
+ float: right;
+ margin: 3px;
+}
+
+#Content p {
+ margin: 0.5em 0 0.5em 0;
+ font-size: 11px;
+}
+
+
+td.description {
+ width: 90%;
+}
+
+input[type=text], textarea {
+ border: 1px solid #ccc;
+ background-color: #FCFCFC;
+ color: black;
+}
+
+input[type=submit] {
+ border: 1px solid #ccc;
+ background-color: #e7e1ba;
+ color: black;
+}
+
+textarea:focus, input[type=text]:focus {
+ border: 1px solid black;
+ background-color: white;
+ color: black;
+}
+
+input[type=submit]:focus {
+ border: 1px solid black;
+ color: black;
+ }
+
+thead td {
+ text-align:center;
+ font-size: 15pt;
+ font-weight: bold;
+}
+
+table.pixelzilla {
+ padding: 0;
+ margin: 0;
+ border-spacing: 0;
+ width: 100%;
+ }
+
+table.pixelzilla thead th.version{ width: 150px; }
+
+table.pixelzilla thead th { background-color: #eae9be; }
+
+table.pixelzilla td { border-bottom: 1px solid #eae9be; }
+
+.note { border: 1px solid red; }
+
+.resume {
+ border: 1px solid #ddd;
+ padding: 5em;
+}
+
+.resume h1 {
+ font-family: Georgia, Times, serif;
+ text-align: center;
+ text-decoration: underline;
+}
More information about the z3-checkins
mailing list