Commit b6bc9e84 authored by Amos Latteier's avatar Amos Latteier

Improved Help topic browseablility

  * Now products can specify that their help topics are viewed as part of an existing product using the registerHelpTitle method. This allows us to visually join OFSP, MailHost and other standard Zope products.

  * API docs are now represented as belonging to a sub 'API Documentation' node.
parent 81d887c8
......@@ -276,6 +276,12 @@ class ProductContext:
"""
self.getProductHelp()._setObject(id, topic)
def registerHelpTitle(self, title):
"""
Sets the title of the Product's Product Help
"""
self.getProductHelp().title=title
def registerHelp(self, directory='help', clear=1):
"""
Registers Help Topics for all objects in a directory.
......
......@@ -95,6 +95,8 @@ class APIHelpTopic(HelpTopic.HelpTopic):
"""
Provides API documentation.
"""
isAPIHelpTopic=1
def __init__(self, id, title, file):
self.id=id
......
......@@ -161,6 +161,65 @@ class HelpSys(Acquisition.Implicit, ObjectManager, Item, Persistent):
helpURL=HTMLFile('helpURL',globals())
def tpValues(self):
"""
Tree protocol - returns child nodes
Aggregates Product Helps with the same title.
"""
helps={}
for help in self.helpValues():
if helps.has_key(help.title):
helps[help.title].append(help)
else:
helps[help.title]=[help]
cols=[]
for k,v in helps.items():
cols.append(TreeCollection(k,v,0))
return cols
class TreeCollection:
"""
A temporary wrapper for a collection of objects
objects, used for help topic browsing to make a collection
of objects appear as a single object.
"""
def __init__(self, id, objs, simple=1):
self.id=self.title=id
self.objs=objs
self.simple=simple
def tpValues(self):
values=[]
if self.simple:
values=self.objs
else:
for obj in self.objs:
values=values + list(obj.tpValues())
# resolve overlap
ids={}
for value in values:
if ids.has_key(value.id):
ids[value.id].append(value)
else:
ids[value.id]=[value]
results=[]
for k,v in ids.items():
if len(v)==1:
results.append(v[0])
else:
values=[]
for topic in v:
values=values + list(topic.tpValues())
results.append(TreeCollection(k, values))
results.sort(lambda x, y: cmp(x.id, y.id))
return results
def tpId(self):
return self.id
class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent):
"""
......@@ -232,6 +291,21 @@ class ProductHelp(Acquisition.Implicit, ObjectManager, Item, Persistent):
return filter(
lambda ht, u=REQUEST.AUTHENTICATED_USER: ht.authorized(u), topics)
def tpValues(self):
"""
Tree protocol - child nodes
"""
topics=[]
apitopics=[]
for topic in self.objectValues('Help Topic'):
if hasattr(topic,'isAPIHelpTopic') and topic.isAPIHelpTopic:
apitopics.append(topic)
else:
topics.append(topic)
if apitopics:
topics = topics + [TreeCollection('API Documentation', apitopics)]
return topics
def all_meta_types(self):
f=lambda x: x['name'] in ('Image', 'File')
return filter(f, Products.meta_types) + self.meta_types
......
......@@ -2,11 +2,13 @@
<dtml-call "REQUEST.set('MANAGE_TABS_NO_BANNER',1)">
<dtml-var manage_tabs>
<h2>Contents</h2>
<dtml-tree branches_expr="helpValues(REQUEST)">
<dtml-if "meta_type=='Product Help'">
<dtml-var title_or_id>
<dtml-tree>
<dtml-if "meta_type =='Help Topic'">
<a href="<dtml-var absolute_url>" target="help_main"><dtml-var title_and_id></a>
<dtml-else>
<a href="<dtml-var absolute_url>" target="help_main"><dtml-var title_or_id></a>
<dtml-var title>
</dtml-if>
</dtml-tree>
<dtml-var standard_html_footer>
\ No newline at end of file
......@@ -83,8 +83,8 @@
#
##############################################################################
__doc__='''External Method Product Initialization
$Id: __init__.py,v 1.12 1999/12/13 23:26:41 amos Exp $'''
__version__='$Revision: 1.12 $'[11:-2]
$Id: __init__.py,v 1.13 2000/06/09 01:22:13 amos Exp $'''
__version__='$Revision: 1.13 $'[11:-2]
import ExternalMethod
......@@ -100,3 +100,4 @@ def initialize(context):
)
context.registerHelp()
context.registerHelpTitle('Zope Help')
......@@ -83,8 +83,8 @@
#
##############################################################################
__doc__='''MailHost Product Initialization
$Id: __init__.py,v 1.17 1999/12/13 23:14:46 amos Exp $'''
__version__='$Revision: 1.17 $'[11:-2]
$Id: __init__.py,v 1.18 2000/06/09 01:22:13 amos Exp $'''
__version__='$Revision: 1.18 $'[11:-2]
import MailHost
import SendMailTag
......@@ -102,4 +102,4 @@ def initialize(context):
)
context.registerHelp()
context.registerHelpTitle('Zope Help')
......@@ -83,8 +83,8 @@
#
##############################################################################
__doc__='''Object system core
$Id: __init__.py,v 1.33 1999/12/09 23:43:18 amos Exp $'''
__version__='$Revision: 1.33 $'[11:-2]
$Id: __init__.py,v 1.34 2000/06/09 01:22:13 amos Exp $'''
__version__='$Revision: 1.34 $'[11:-2]
import Version, OFS.Image, OFS.Folder, AccessControl.User
import OFS.DTMLMethod, OFS.DTMLDocument, ZClasses.ObjectManager
......@@ -179,3 +179,4 @@ def initialize(context):
context.registerZClass(ZClasses.ObjectManager.ZObjectManager)
context.registerHelp()
context.registerHelpTitle('Zope Help')
......@@ -110,5 +110,5 @@ def initialize(context):
context.registerBaseClass(CatalogAwareness.CatalogAware)
context.registerHelp()
context.registerHelpTitle('Zope Help')
......@@ -85,8 +85,8 @@
__doc__='''SQL Method Product
$Id: __init__.py,v 1.15 2000/01/10 23:03:45 amos Exp $'''
__version__='$Revision: 1.15 $'[11:-2]
$Id: __init__.py,v 1.16 2000/06/09 01:22:14 amos Exp $'''
__version__='$Revision: 1.16 $'[11:-2]
import Shared.DC.ZRDB.Search, Shared.DC.ZRDB.Aqueduct, SQL
import Shared.DC.ZRDB.RDB
import Shared.DC.ZRDB.sqlvar, Shared.DC.ZRDB.sqlgroup, Shared.DC.ZRDB.sqltest
......@@ -111,6 +111,7 @@ def initialize(context):
)
context.registerHelp()
context.registerHelpTitle('Zope Help')
methods={
# We still need this one, at least for now, for both editing and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment