[Zope3-checkins] CVS: Zope3/src/zope/app/onlinehelp - __init__.py:1.1 configure.zcml:1.1 help.txt:1.1 meta.zcml:1.1 metaconfigure.py:1.1 ui.txt:1.1 welcome.txt:1.1
Stephan Richter
srichter@cbu.edu
Tue, 7 Jan 2003 07:27:54 -0500
Update of /cvs-repository/Zope3/src/zope/app/onlinehelp
In directory cvs.zope.org:/tmp/cvs-serv14439/app/onlinehelp
Added Files:
__init__.py configure.zcml help.txt meta.zcml metaconfigure.py
ui.txt welcome.txt
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/onlinehelp/__init__.py ===
##############################################################################
#
# Copyright (c) 2002 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.
#
##############################################################################
"""Implementation of OnlineHelp System.
This the default implmentation of the OnlineHelp. It defines the global
OnlineHelp in which all basic Zope-core help screens are registered.
$Id: __init__.py,v 1.1 2003/01/07 12:27:49 srichter Exp $
"""
import os
from zope.app.container.sample import SampleContainer
from zope.app.traversing import \
traverse, getParent, objectName, IContainmentRoot, Traverser
import zope.app
from zope.proxy.context import ContextWrapper
from zope.app.interfaces.onlinehelp import IOnlineHelpTopic, IOnlineHelp
class OnlineHelpTopic(SampleContainer):
__doc__ = IOnlineHelpTopic.__doc__
__implements__ = IOnlineHelpTopic
def __init__(self, title, path, doc_type='txt'):
"""Initialize object."""
self.title = title
self.setContentPath(path, doc_type)
super(OnlineHelpTopic, self).__init__()
def setTitle(self, title):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelpTopic"
self._title = title
def getTitle(self):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelpTopic"
return self._title
title = property(getTitle, setTitle, None)
def setContentPath(self, path, doc_type='txt'):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelpTopic"
self._content_path = path
self._doc_type = doc_type
def getContent(self):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelpTopic"
raw = open(self._content_path).read()
if self._doc_type == 'txt':
return '<p>' + raw.replace('\n\n', '\n</p><p>') + '</p>'
else:
return raw
class OnlineHelp(OnlineHelpTopic):
__doc__ = IOnlineHelp.__doc__
__implements__ = IOnlineHelp, IContainmentRoot
def __init__(self, title, path, doc_type='txt'):
self._registry = {}
super(OnlineHelp, self).__init__(title, path, doc_type)
def getTopicsForInterfaceAndView(self, interface=None, view=None):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelp"
return self._registry.get((interface, view), [])
def registerHelpTopic(self, parent_path, id, title,
doc_path, doc_type='txt', interface=None, view=None):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelp"
#parent = traverse(self, parent_path)
parent = Traverser(self).traverse(parent_path)
# Create and add topic
id = parent.setObject(id, OnlineHelpTopic(title, doc_path, doc_type))
topic = ContextWrapper(parent[id], parent, name=id)
# Add topic to registry
if not self._registry.has_key((interface, view)):
self._registry[(interface, view)] = []
self._registry[(interface, view)].append(topic)
def unregisterHelpTopic(self, topic_path):
"See Zope.App.OnlineHelp.interfaces.IOnlineHelp"
# Delete topic from tree
topic = Traverser(self).traverse(topic_path)
name = objectName(topic)
parent = getParent(topic)
del parent[name]
# unregister from registry
for item in registry.items():
if topic in item[1]:
item[1].remove(topic)
# Global Online Help
path = os.path.join(os.path.dirname(zope.app.__file__),
'onlinehelp', 'welcome.txt')
help = OnlineHelp('Online Help', path)
=== Added File Zope3/src/zope/app/onlinehelp/configure.zcml ===
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:service="http://namespaces.zope.org/service"
xmlns:help="http://namespaces.zope.org/help"
>
<content class="zope.app.onlinehelp.OnlineHelpTopic">
<require
permission="zope.View"
interface="zope.app.interfaces.onlinehelp.IOnlineHelpTopic"
attributes="__iter__"
/>
</content>
<!-- Setup OnlineHelp as Service -->
<serviceType id="OnlineHelp"
interface="zope.app.interfaces.onlinehelp.IOnlineHelp" />
<service serviceType="OnlineHelp"
permission="zope.Public"
component="zope.app.onlinehelp.help" />
<!-- Register initial Help Topics -->
<help:register
id = "ui"
title = "Zope UI Help"
doc_path = "./ui.txt" />
<help:register
id = "welcome"
title = "Welcome"
parent = "ui"
for = "zope.app.interfaces.onlinehelp.IOnlineHelpTopic"
view = "zope.app.browser.onlinehelp.OnlineHelpTopicView"
doc_path = "./help.txt" />
</zopeConfigure>
=== Added File Zope3/src/zope/app/onlinehelp/help.txt ===
Welcome to the Help System
This is a warm welcome text right here.
=== Added File Zope3/src/zope/app/onlinehelp/meta.zcml ===
<zopeConfigure xmlns="http://namespaces.zope.org/zope">
<directives namespace="http://namespaces.zope.org/help">
<directive name="register"
attributes="parent id title doc_path doc_type for view"
handler="zope.app.onlinehelp.metaconfigure.register" />
<directive name="unregister"
attributes="path"
handler="zope.app.onlinehelp.metaconfigure.unregister" />
</directives>
</zopeConfigure>
=== Added File Zope3/src/zope/app/onlinehelp/metaconfigure.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""Meta-Configuration Handlers for "help" namespace.
These handlers process the registerTopic() and unregisterTopic() directives of
the "help" ZCML namespace.
$Id: metaconfigure.py,v 1.1 2003/01/07 12:27:49 srichter Exp $
"""
import os
from zope.app.onlinehelp import help
from zope.configuration.action import Action
def register(_context, id, title, parent="", doc_path=None, doc_type="txt",
for_=None, view=None):
"""Register an OnlineHelp topic"""
actions = []
doc_path = _context.path(doc_path)
doc_path = os.path.normpath(doc_path)
if for_ is not None:
for_ = _context.resolve(for_)
if view is not None:
view = _context.resolve(view)
return [
Action(discriminator = ('registerHelpTopic', parent, title),
callable = help.registerHelpTopic,
args = (parent, id, title, doc_path, doc_type, for_, view) )
]
def unregister(_context, path):
return [
Action(discriminator = ('unregisterHelpTopic', path),
callable = help.unregisterHelpTopic,
args = (path,) )
]
=== Added File Zope3/src/zope/app/onlinehelp/ui.txt ===
The UI offers powerful tools to build applications using Zope 3. The UI is
aimed at Site Developers and not hard-core developers and content managers.
=== Added File Zope3/src/zope/app/onlinehelp/welcome.txt ===
Welcome to the Zope 3 Online Help System. Here you can find much of the
documentation that is relevant to the usage of this UI and Zope 3 in general.