[Zope3-checkins] CVS: Zope3/src/zope/app/browser - onlinehelp.py:1.1 onlinehelptopic.pt:1.1 configure.zcml:1.14
Stephan Richter
srichter@cbu.edu
Tue, 7 Jan 2003 07:28:14 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv14439/app/browser
Modified Files:
configure.zcml
Added Files:
onlinehelp.py onlinehelptopic.pt
Log Message:
Implementation of the OnlineHelp proposal. Since we do not have STX yet,
it works only with regular Text or HTML files at the moment.
I added a box to the Rotterdam skin which shows all relevant Help Topics.
Currently you can only see a Help Topic for the File Upload screen.
To Do:
- Clean up code a bit.
- Write Documentation (ZCML, Recipe, ...)
- Implement STX or ReST support.
- Writing Help File for the various screens!
=== Added File Zope3/src/zope/app/browser/onlinehelp.py ===
##############################################################################
#
# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""OnlineHelp views
$Id: onlinehelp.py,v 1.1 2003/01/07 12:27:40 srichter Exp $
"""
from zope.interface.implements import flattenInterfaces
from zope.component import getService, getView
from zope.publisher.browser import BrowserView
from zope.app.onlinehelp import OnlineHelpTopic
from zope.app.traversing import getPhysicalRoot
from zope.proxy.context import ContextWrapper
from zope.app.traversing import getParents, objectName
from zope.proxy.introspection import removeAllProxies
class OnlineHelpTopicView(BrowserView):
def _makeSubTree(self, topic):
html = '<ul>\n'
for entry in topic.items():
entry = ContextWrapper(entry[1], topic, name=entry[0])
html += ' <li><a href="%s">%s</a></li>\n' %(
getView(entry, 'absolute_url', self.request)(),
entry.getTitle())
html += self._makeSubTree(entry)
html += '</ul>\n'
return html
def getTopicTree(self):
onlinehelp = getPhysicalRoot(self.context)
return self._makeSubTree(onlinehelp)
class FindRelevantHelpTopics(BrowserView):
"""This object is used as a view on a view, so that we can get all the
required information."""
def __call__(self):
class FindResult:
def __init__(self, url, topic):
self.url = url
self.topic = topic
view = self.context
obj = view.context
help = getService(obj, 'OnlineHelp')
ifaces = flattenInterfaces(removeAllProxies(obj.__implements__))
topics = []
for klass in view.__class__.__bases__ + (view.__class__, None):
for iface in ifaces:
for topic in help.getTopicsForInterfaceAndView(iface, klass):
parents = getParents(topic)
path = map(objectName, parents[:-1]+[topic])
url = getView(obj, 'absolute_url', self.request)()
url += '/++help++/'+'/'.join(path)
topics.append(FindResult(url, topic))
return topics
=== Added File Zope3/src/zope/app/browser/onlinehelptopic.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" tal:content="context/getTitle">Title</title>
</head>
<body>
<div metal:fill-slot="body">
<h1 tal:content="context/getTitle">Title of Help Topic</h1>
<p tal:content="structure context/getContent">Content of Online Help.</p>
</div>
<div metal:fill-slot="commonTasks"
tal:content="structure view/getTopicTree" />
</body>
</html>
=== Zope3/src/zope/app/browser/configure.zcml 1.13 => 1.14 ===
--- Zope3/src/zope/app/browser/configure.zcml:1.13 Tue Dec 31 16:53:27 2002
+++ Zope3/src/zope/app/browser/configure.zcml Tue Jan 7 07:27:40 2003
@@ -75,6 +75,34 @@
<include package=".skins" />
<include package=".index" />
+<!-- OnlineHelp -->
+
+ <page
+ for="*"
+ name="find_help_topics"
+ class=".onlinehelp.FindRelevantHelpTopics"
+ permission="zope.Public"
+ allowed_attributes="__call__"
+ />
+
+ <!-- XXX: This sucks. You cannot define a content type without making
+ a '+' view, since some menu code will complain otherwise. -->
+ <page
+ name="+"
+ for="zope.app.interfaces.onlinehelp.IOnlineHelpTopic"
+ permission="zope.View"
+ template="onlinehelptopic.pt"
+ class="zope.app.browser.onlinehelp.OnlineHelpTopicView"
+ />
+
+ <page
+ name="index.html"
+ for="zope.app.interfaces.onlinehelp.IOnlineHelpTopic"
+ permission="zope.View"
+ template="onlinehelptopic.pt"
+ class="zope.app.browser.onlinehelp.OnlineHelpTopicView"
+ />
+
<!-- Introspection -->
<!-- XXX wrong perm -->