[Checkins] SVN: zope.kgs/trunk/src/zope/kgs/ More progress getting the site to work by hooking up data.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Jan 27 04:10:39 EST 2009
Log message for revision 95087:
More progress getting the site to work by hooking up data.
Changed:
U zope.kgs/trunk/src/zope/kgs/site.py
U zope.kgs/trunk/src/zope/kgs/template.py
U zope.kgs/trunk/src/zope/kgs/templates/index.html
U zope.kgs/trunk/src/zope/kgs/templates/master.pt
-=-
Modified: zope.kgs/trunk/src/zope/kgs/site.py
===================================================================
--- zope.kgs/trunk/src/zope/kgs/site.py 2009-01-27 08:52:25 UTC (rev 95086)
+++ zope.kgs/trunk/src/zope/kgs/site.py 2009-01-27 09:10:38 UTC (rev 95087)
@@ -31,6 +31,15 @@
TIMESTAMP_FILENAME = 'cf-timestamp'
+FEATURES = [
+ ('controlled-packages.cfg', u'Controlled Packages'),
+ ('versions.cfg', u'Versions'),
+ ('buildout.cfg', u'Buildout Configuration'),
+ ('links.html', u'Package Links'),
+ ('minimal', u'Minimal Index'),
+ ('index', u'Index'),
+ ]
+
formatter = logging.Formatter('%(levelname)s - %(message)s')
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
@@ -38,6 +47,35 @@
logger.addHandler(handler)
logger.setLevel(logging.ERROR)
+
+def _getRenderedFilename(filename):
+ if not filename:
+ return
+ return os.path.split(filename)[-1].split('.')[0] + '.html'
+
+def generateData(src):
+ versions = []
+ for filename in os.listdir(src):
+ path = os.path.join(src, filename)
+ if not (os.path.isdir(path) and
+ os.path.exists(os.path.join(path, 'controlled-packages.cfg'))):
+ continue
+ kgsPath = os.path.join(path, 'controlled-packages.cfg')
+ set = kgs.KGS(kgsPath)
+ features = []
+ for (filename, title) in FEATURES:
+ if filename in os.listdir(path):
+ features.append({'url': filename, 'title': title})
+ versions.append(
+ {'name': set.version,
+ 'features': features,
+ 'changelog': _getRenderedFilename(set.changelog),
+ 'announcement': _getRenderedFilename(set.announcement),
+ })
+
+ return {'versions': sorted(versions, key=lambda x: x['name']),
+ 'title': set.name}
+
def generateSite(siteDir, templateDir, force=False):
# Create some important variables
kgsPath = os.path.join(siteDir, 'controlled-packages.cfg')
@@ -109,7 +147,11 @@
# Update the full index (which is assumed to live in the site directory)
logger.info("updating the index")
- ppix.generatePackagePages(kgsPath, versionDir)
+ idxDir = os.path.join(versionDir, 'index')
+ if not os.path.exists(idxDir):
+ os.mkdir(idxDir)
+ ppix.generatePackagePages(kgsPath, idxDir)
+ ppix.generateIndexPage(kgsPath, idxDir)
# Update the minimal index
logger.info("updating the minimal index")
@@ -121,7 +163,7 @@
# Generate Web Site
logger.info("Generating Web Site")
- template.generateSite(templateDir, siteDir, None)
+ template.generateSite(templateDir, siteDir, generateData(siteDir))
logger.info("finished generating site.")
Modified: zope.kgs/trunk/src/zope/kgs/template.py
===================================================================
--- zope.kgs/trunk/src/zope/kgs/template.py 2009-01-27 08:52:25 UTC (rev 95086)
+++ zope.kgs/trunk/src/zope/kgs/template.py 2009-01-27 09:10:38 UTC (rev 95087)
@@ -19,36 +19,40 @@
class Template(zope.pagetemplate.pagetemplatefile.PageTemplateFile):
- def __init__(self, path, templates):
+ def __init__(self, path, data, templates):
super(Template, self).__init__(path)
self.templates = templates
+ self.data = data
def pt_getContext(self, args=(), options=None, **ignore):
- rval = {'args': args,
- 'nothing': None,
- 'self': self,
- 'templates': self.templates
- }
+ rval = self.data.copy()
+ rval.update(
+ {'args': args,
+ 'nothing': None,
+ 'self': self,
+ 'templates': self.templates
+ })
rval.update(self.pt_getEngine().getBaseNames())
return rval
class DirectoryContext(object):
- def __init__(self, path, root=None):
+ def __init__(self, path, data, root=None):
self.path = path
+ self.data = data
self.root = root or self
def __getitem__(self, name):
path = os.path.join(self.path, name)
if os.path.exists(path):
- return Template(path, self.root)
+ return Template(path, self.data, self.root)
return None
def generateSite(src, dst, data, templates=None):
if templates is None:
- templates = DirectoryContext(src)
+ templates = DirectoryContext(src, data)
for filename in os.listdir(src):
srcPath = os.path.join(src, filename)
dstPath = os.path.join(dst, filename)
@@ -61,7 +65,7 @@
os.mkdir(dstPath)
generateSite(srcPath, dstPath, data, templates)
elif srcPath.endswith('.html'):
- data = Template(srcPath, templates)()
- open(dstPath, 'w').write(data)
+ html = Template(srcPath, data, templates)()
+ open(dstPath, 'w').write(html)
else:
shutil.copyfile(srcPath, dstPath)
Modified: zope.kgs/trunk/src/zope/kgs/templates/index.html
===================================================================
--- zope.kgs/trunk/src/zope/kgs/templates/index.html 2009-01-27 08:52:25 UTC (rev 95086)
+++ zope.kgs/trunk/src/zope/kgs/templates/index.html 2009-01-27 09:10:38 UTC (rev 95087)
@@ -4,7 +4,9 @@
<title metal:fill-slot="page-title">Introduction to the KGS</title>
</head>
<body>
- <div metal:fill-slot="header">Introduction to the KGS</div>
+ <h1 id="header" metal:fill-slot="title">
+ <em class="name" tal:replace="title">name</em> Known Good Set
+ </h1>
<ul class="level-one" metal:fill-slot="left-nav">
<!--li tal:repeat="version self/versions">
<a href="#">Version <span tal:replace="version/name">1</span></a>
Modified: zope.kgs/trunk/src/zope/kgs/templates/master.pt
===================================================================
--- zope.kgs/trunk/src/zope/kgs/templates/master.pt 2009-01-27 08:52:25 UTC (rev 95086)
+++ zope.kgs/trunk/src/zope/kgs/templates/master.pt 2009-01-27 09:10:38 UTC (rev 95087)
@@ -24,7 +24,7 @@
</head>
<body>
- <h1 id="header">Introduction to the KGS</h1>
+ <h1 id="header" metal:define-slot="title">KGS</h1>
<div id="left-hand-navigation">
<!-- Main Menu -->
More information about the Checkins
mailing list