[Zope3-checkins] CVS: Zope3/src/zope/app/wiki/browser -
configure.zcml:1.2 view_page.pt:1.2 wiki.py:1.3
wiki_add.pt:1.2 wiki_search.pt:1.2 wikipage.py:1.3
comment_page.pt:NONE
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Mar 2 09:25:34 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/wiki/browser
In directory cvs.zope.org:/tmp/cvs-serv21798/src/zope/app/wiki/browser
Modified Files:
configure.zcml view_page.pt wiki.py wiki_add.pt wiki_search.pt
wikipage.py
Removed Files:
comment_page.pt
Log Message:
Updated Wiki product to follow new API and design patterns. See CHANGES.txt
for detailed information.
=== Zope3/src/zope/app/wiki/browser/configure.zcml 1.1 => 1.2 ===
--- Zope3/src/zope/app/wiki/browser/configure.zcml:1.1 Fri Feb 27 06:06:59 2004
+++ Zope3/src/zope/app/wiki/browser/configure.zcml Tue Mar 2 09:25:03 2004
@@ -1,38 +1,25 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
- i18n_domain="zope"
- >
+ i18n_domain="zope">
<include package=".skin" />
- <browser:menu
- id="add_wiki"
- title="Menu of objects to be added to wikis."/>
-
- <!-- Custom adding view. -->
- <browser:view
- for="zope.app.wiki.interfaces.IWiki"
- name="+"
- class=".wiki.WikiAdding"
- permission="zope.app.wiki.AddWikiPage"
- allowed_attributes="addingInfo"
- menu="zmi_actions"
- title="Add"
- >
- <browser:page name="index.html" template="add.pt" />
- <browser:page name="action.html" attribute="action" />
- </browser:view>
-
<browser:addform
label="Add Wiki"
- name="AddWiki"
+ name="AddWiki.html"
schema="zope.app.wiki.interfaces.IWiki"
content_factory="zope.app.wiki.wiki.Wiki"
- permission="zope.ManageContent"
+ permission="zope.app.wiki.AddWikiPage"
class=".wiki.AddWiki"
- template="wiki_add.pt"
- menu="add_content" title="Wiki"/>
+ template="wiki_add.pt" />
+
+ <browser:addMenuItem
+ class="zope.app.wiki.wiki.Wiki"
+ title="Wiki"
+ description="A Wiki"
+ permission="zope.ManageContent"
+ view="AddWiki.html" />
<browser:page
name="toc.html"
@@ -40,7 +27,7 @@
class=".wiki.TableOfContents"
template="wiki_toc.pt"
permission="zope.app.wiki.ViewWikiPage"
- menu="zmi_views" title="TOC"/>
+ menu="zmi_views" title="TOC" />
<browser:page
name="search.html"
@@ -48,7 +35,7 @@
class=".wiki.WikiSearch"
template="wiki_search.pt"
permission="zope.app.wiki.ViewWikiPage"
- menu="zmi_views" title="Search"/>
+ menu="zmi_views" title="Search" />
<browser:pages
for="zope.app.wiki.interfaces.IWiki"
@@ -61,26 +48,30 @@
<browser:defaultView
name="toc.html"
- for="zope.app.wiki.interfaces.IWiki"/>
+ for="zope.app.wiki.interfaces.IWiki" />
<browser:icon
name="zmi_icon"
for="zope.app.wiki.interfaces.IWiki"
- file="wiki_icon.gif"
- />
+ file="wiki_icon.gif" />
<!-- WikiPage browser configuration -->
<browser:addform
label="Add Wiki Page"
- name="AddWikiPage"
+ name="AddWikiPage.html"
schema="zope.app.wiki.interfaces.IWikiPage"
content_factory="zope.app.wiki.wikipage.WikiPage"
permission="zope.app.wiki.AddWikiPage"
fields="source type"
- class=".wikipage.AddWikiPage"
- menu="add_wiki"
- title="Wiki Page"/>
+ class=".wikipage.AddWikiPage" />
+
+ <browser:addMenuItem
+ class="zope.app.wiki.wikipage.WikiPage"
+ title="Wiki Page"
+ description="A Wiki Page"
+ permission="zope.app.wiki.AddWikiPage"
+ view="AddWikiPage.html" />
<browser:editform
schema="zope.app.wiki.interfaces.IWikiPage"
@@ -122,15 +113,6 @@
<browser:pages
for="zope.app.wiki.interfaces.IWikiPage"
- class=".wikipage.WikiPageComment"
- permission="zope.app.wiki.CommentWikiPage">
- <browser:page name="commentForm.html" template="comment_page.pt"
- menu="zmi_views" title="Add Comment" />
- <browser:page name="addComment.html" attribute="comment" />
- </browser:pages>
-
- <browser:pages
- for="zope.app.wiki.interfaces.IWikiPage"
class=".wikipage.MailSubscriptions"
permission="zope.app.wiki.EditWikiPage">
<browser:page name="subscriptions.html" template="subscriptions.pt"
@@ -145,20 +127,36 @@
<browser:icon
name="zmi_icon"
for="zope.app.wiki.interfaces.IWikiPage"
- file="wikipage_icon.gif"
- />
+ file="wikipage_icon.gif" />
+
+ <!-- Comment browser configuration -->
+
+ <browser:addform
+ label="Comment"
+ name="AddComment.html"
+ schema="zope.app.wiki.interfaces.IComment"
+ content_factory="zope.app.wiki.wikipage.Comment"
+ permission="zope.app.wiki.AddWikiPage"
+ fields="title source type"
+ class=".wikipage.AddComment"/>
+
+ <browser:addMenuItem
+ class="zope.app.wiki.wikipage.Comment"
+ title="Comment"
+ description="A Comment"
+ permission="zope.app.wiki.AddWikiPage"
+ view="AddComment.html" />
<!-- Make a special WikiPage menu -->
<browser:menu
id="wikipage_actions"
- title="Menu for Wiki Page related actions."
- />
+ title="Menu for Wiki Page related actions." />
<browser:menuItems menu="wikipage_actions"
for="zope.app.wiki.interfaces.IWikiPage">
<browser:menuItem title="View" action="@@view.html"/>
- <browser:menuItem title="Comment" action="@@commentForm.html"/>
+ <browser:menuItem title="Comment" action="./+/AddComment.html="/>
<browser:menuItem title="Edit" action="@@edit.html"/>
<browser:menuItem title="Parents" action="@@parents.html"/>
<browser:menuItem title="TOC" action="@@toc.html"/>
@@ -179,15 +177,5 @@
for="zope.app.wiki.interfaces.IWikiPage"
class="zope.app.wiki.traversal.WikiPageTraverser"
permission="zope.Public" />
-
- <!-- Register WikiTextIndex as component -->
-
- <browser:menuItem
- menu="add_component"
- for="zope.app.interfaces.container.IAdding"
- action="zope.app.wiki.index.WikiTextIndex"
- title="Wiki Text Index"
- description="A Wiki-specific full-text index"
- />
</configure>
=== Zope3/src/zope/app/wiki/browser/view_page.pt 1.1 => 1.2 ===
--- Zope3/src/zope/app/wiki/browser/view_page.pt:1.1 Fri Feb 27 06:06:59 2004
+++ Zope3/src/zope/app/wiki/browser/view_page.pt Tue Mar 2 09:25:03 2004
@@ -10,6 +10,22 @@
This is the rendered Wiki
</div>
+ <div tal:define="comments view/comments"
+ tal:condition="comments">
+
+ <hr size="1" width="100%" noshade="" />
+
+ <div tal:repeat="info comments" style="padding-bottom: 1em;">
+ <h4 tal:content="info/title">Title</h4>
+ <i>
+ Posted by <span tal:replace="info/author" />
+ on <span tal:replace="info/modified" />.
+ </i>
+ <div tal:replace="structure info/text" />
+ </div>
+
+ </div>
+
</div>
</body>
</html>
=== Zope3/src/zope/app/wiki/browser/wiki.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/wiki/browser/wiki.py:1.2 Mon Mar 1 10:02:54 2004
+++ Zope3/src/zope/app/wiki/browser/wiki.py Tue Mar 2 09:25:03 2004
@@ -26,12 +26,6 @@
from zope.app.services.hub import Registration
from zope.app.wiki.interfaces import IWikiPageHierarchy
-from zope.app.wiki.index import WikiTextIndex
-
-class WikiAdding(Adding):
- """Custom adding view for NewsSite objects."""
- menu_id = "add_wiki"
-
class AddWiki(object):
"""Add a Wiki"""
@@ -42,21 +36,16 @@
# Get the environment
sm = zapi.getServiceManager(content)
pkg = sm['default']
- hub = pkg['HubIds-1']
# Create, subscribe and add a Registration object.
if 'WikiReg' not in pkg:
reg = Registration()
pkg['WikiReg'] = reg
reg.subscribe()
- # Create, subscribe and add an WikiTextIndex object
- if 'WikiTextIndex' not in pkg:
- index = WikiTextIndex()
- pkg['WikiTextIndex'] = index
- index.subscribe(hub, True)
if self.request.get('frontpage'):
- page = removeAllProxies(zapi.createObject(None, 'WikiPage'))
- page.type = u'reStructured Text (reST)'
+ page = removeAllProxies(
+ zapi.createObject(None, 'zope.wiki.WikiPage'))
+ page.type = u'zope.source.rest'
page.source = u'This is the FrontPage of the Wiki.'
dc = zapi.getAdapter(page, ICMFDublinCore)
dc.created = datetime.now()
@@ -70,40 +59,21 @@
class WikiSearch(object):
"""Search Wiki Pages"""
- def __init__(self, context, request):
- super(WikiSearch, self).__init__(context, request)
- self.hub = zapi.getService(context, HubIds)
-
def query(self):
+ # XXX: Should use indices once they are back in Zope 3
queryText = self.request.get('queryText', '')
- sm = zapi.getServiceManager(self.context)
- results, total = sm['default']['WikiTextIndex'].query(queryText)
- result = {
- 'results': list(self._resultIterator(results)),
- 'total': total,
- }
- return result
+ results = []
+ for name, page in self.context.items():
+ if page.source.find(queryText) >= 0:
+ results.append(name)
+ else:
+ for comment in page.values():
+ if comment.source.find(queryText) >= 0:
+ results.append(name)
+
+ return {'results': results,
+ 'total': len(results)}
- def _resultIterator(self, results):
- for hubid, score in results:
- yield self._cookInfo(hubid, score)
-
- def _cookInfo(self, hubid, score):
- location = self.hub.getPath(hubid)
- scoreLabel = "%.1f%%" % (100.0 * score)
- result = {
- 'location': location,
- 'score': score,
- 'scoreLabel': scoreLabel,
- }
- try:
- object = self.hub.getObject(hubid)
- except NotFoundError:
- pass
- else:
- result['name'] = getName(object)
- return result
-
class TableOfContents:
"""Table of contents for a Wiki"""
=== Zope3/src/zope/app/wiki/browser/wiki_add.pt 1.1 => 1.2 ===
--- Zope3/src/zope/app/wiki/browser/wiki_add.pt:1.1 Fri Feb 27 06:06:59 2004
+++ Zope3/src/zope/app/wiki/browser/wiki_add.pt Tue Mar 2 09:25:03 2004
@@ -14,18 +14,6 @@
<div class="row">
<div class="field">
- <h1><input type="checkbox" name="textindex:int" value="1"
- checked=""/>
- Create Wiki Text Index
- </h1>
- This is strongly recommended. Without the text index you cannot
- search your objects properly. Of course, you can always add
- an index later as well.
- </div>
- </div>
-
- <div class="row">
- <div class="field">
<h1><input type="checkbox" name="frontpage:int" value="1"
checked=""/>
Create "Front Page" Wiki Page
@@ -36,14 +24,14 @@
</div>
</div>
- <div class="row">
- <div class="controls">
- <input type="submit" value="Refresh"
- i18n:attributes="value refresh-button" />
- <input type="submit" name="UPDATE_SUBMIT" value="Submit"
- i18n:attributes="value submit-button" />
- </div>
- </div>
+ <div class="row">
+ <div class="controls"><hr />
+ <input type="submit" value="Refresh"
+ i18n:attributes="value refresh-button">
+ <input type="submit" name="UPDATE_SUBMIT" value=" Add "
+ tal:replace="structure context/renderAddButton|default"/>
+ </div>
+ </div>
</form>
=== Zope3/src/zope/app/wiki/browser/wiki_search.pt 1.1 => 1.2 ===
--- Zope3/src/zope/app/wiki/browser/wiki_search.pt:1.1 Fri Feb 27 06:06:59 2004
+++ Zope3/src/zope/app/wiki/browser/wiki_search.pt Tue Mar 2 09:25:03 2004
@@ -14,18 +14,18 @@
<input type="submit" value="Query" />
</form>
+ <h3>Search Results</h3>
<div tal:condition="request/queryText|nothing" tal:omit-tag="">
<div tal:define="result view/query" tal:omit-tag="">
<div tal:condition="not:result/total">
- No hits. Please try another query.
+ No hits. Please try another query.
</div>
<div tal:condition="result/total">
- <div tal:repeat="info result/results">
+ <div tal:repeat="name result/results">
<a href="location"
- tal:attributes="href info/name"
- tal:content="info/name">FrontPage</a>;
- (Score: <span tal:replace="info/scoreLabel" />)
+ tal:attributes="href name"
+ tal:content="name">FrontPage</a>
</div>
</div>
=== Zope3/src/zope/app/wiki/browser/wikipage.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/wiki/browser/wikipage.py:1.2 Mon Mar 1 10:02:54 2004
+++ Zope3/src/zope/app/wiki/browser/wikipage.py Tue Mar 2 09:25:03 2004
@@ -19,12 +19,15 @@
from urllib import quote, unquote
from datetime import datetime
+from zope.proxy import removeAllProxies
+from zope.publisher.browser import BrowserView
+
from zope.app import zapi
from zope.app.browser.form.submit import Update
-from zope.app.browser.form.vocabularywidget import VocabularyFieldEditWidget
from zope.app.browser.form.widget import ListWidget
from zope.app.form.widget import CustomWidgetFactory
from zope.app.dublincore.interfaces import ICMFDublinCore
+from zope.app.renderer.vocabulary import SourceTypeEditWidget
from zope.app.traversing import getParent, getPath, getName
from zope.app.wiki.interfaces import IWikiPageHierarchy, IMailSubscriptions
@@ -47,18 +50,7 @@
(localwikilink, urlchars+urlendchar)
-class GenericWikiPageViews:
- """Some generic Wiki page views."""
-
- def breadcrumbs(self):
- """Get the path of this page."""
- hier = zapi.getAdapter(self.context, IWikiPageHierarchy)
- path = hier.path()
- html = []
- for page in path:
- html.append('<a href="../%s">%s</a>' %(getName(page),
- getName(page)))
- return ' / '.join(html)
+class DublinCoreViews(BrowserView):
def author(self):
"""Get user who last modified the Wiki Page."""
@@ -74,9 +66,23 @@
date = zapi.getAdapter(self.context, ICMFDublinCore).created
if date is None:
return ''
- formatter = self.request.locale.getDateTimeFormatter('medium')
+ formatter = self.request.locale.dates.getFormatter('dateTime', 'medium')
return formatter.format(date)
+
+class GenericWikiPageViews(DublinCoreViews):
+ """Some generic Wiki page views."""
+
+ def breadcrumbs(self):
+ """Get the path of this page."""
+ hier = zapi.getAdapter(self.context, IWikiPageHierarchy)
+ path = hier.path()
+ html = []
+ for page in path:
+ html.append('<a href="../%s">%s</a>' %(getName(page),
+ getName(page)))
+ return ' / '.join(html)
+
def jumpTo(self, jumpto):
"""Try to get quickly to another Wiki page"""
wiki = getParent(self.context)
@@ -92,7 +98,7 @@
class AddWikiPage(object):
- type_widget = CustomWidgetFactory(VocabularyFieldEditWidget, size=1)
+ type_widget = CustomWidgetFactory(SourceTypeEditWidget)
def nextURL(self):
return '../'+self.context.contentName
@@ -100,7 +106,7 @@
class EditWikiPage(object):
- type_widget = CustomWidgetFactory(VocabularyFieldEditWidget, size=1)
+ type_widget = CustomWidgetFactory(SourceTypeEditWidget)
def update(self):
status = super(EditWikiPage, self).update()
@@ -125,14 +131,28 @@
def render(self):
"""Render the wiki page source."""
- types = zapi.getService(self.context, "SourceTypeRegistry")
- source = types.zapi.createObject(self.context.type,
- self.context.source)
- view = zapi.getView(source, '', self.request)
- html = view.render(self.context)
+ source = zapi.createObject(self, self.context.type, self.context.source)
+ view = zapi.getView(removeAllProxies(source), '', self.request)
+ html = view.render()
html = self.renderWikiLinks(html)
return html
+ def comments(self):
+ result = []
+ for name, comment in self.context.items():
+ dc = DublinCoreViews(comment, self.request)
+ source = zapi.createObject(self, comment.type, comment.source)
+ view = zapi.getView(removeAllProxies(source), '', self.request)
+ result.append({
+ 'name': name,
+ 'title': comment.title,
+ 'author': dc.author(),
+ 'modified': dc.modified(),
+ 'text': view.render()
+ })
+
+ return result
+
def _protectLine(self, match):
return re.sub(wikilink, r'!\1', match.group(1))
@@ -199,7 +219,7 @@
# otherwise, provide a "?" creation link
else:
- return '%s<a href="../+/AddWikiPage=%s">?</a>' %(
+ return '%s<a href="../+/AddWikiPage.html=%s">?</a>' %(
morig, quote(m))
@@ -275,27 +295,19 @@
return self._branchHTML(children)
-class WikiPageComment:
+class AddComment(object):
- def comment(self, comment):
- types = zapi.getService(self.context, "SourceTypeRegistry")
- source = types.zapi.createObject(self.context.type, self.context.source)
- comment = source.createComment(
- comment,
- self.context.getCommentCounter(),
- self.request.user.getTitle(),
- datetime.now().strftime('%m/%d/%Y %H:%M:%S'))
- self.context.comment(comment)
- return self.request.response.redirect('.')
+ type_widget = CustomWidgetFactory(SourceTypeEditWidget)
- def source(self):
- return '> ' + self.context.source.replace('\n', '\n> ')
+ def nextURL(self):
+ return '../'
class MailSubscriptions:
def subscriptions(self):
- return zapi.getAdapter(self.context, IMailSubscriptions).getSubscriptions()
+ return zapi.getAdapter(self.context,
+ IMailSubscriptions).getSubscriptions()
def change(self):
if 'ADD' in self.request:
=== Removed File Zope3/src/zope/app/wiki/browser/comment_page.pt ===
More information about the Zope3-Checkins
mailing list