[Zope3-checkins] CVS: zopeproducts/zwiki/browser - comment_page.pt:1.2 configure.zcml:1.2 view_page.pt:1.2 wiki.py:1.2 wikipage.py:1.2

Stephan Richter srichter@cbu.edu
Thu, 10 Apr 2003 02:28:45 -0400


Update of /cvs-repository/zopeproducts/zwiki/browser
In directory cvs.zope.org:/tmp/cvs-serv26676/browser

Modified Files:
	comment_page.pt configure.zcml view_page.pt wiki.py 
	wikipage.py 
Log Message:
- Fully functional 'wiki' skin for viewing Wiki Pages. I tried very hard
  (and was successful) in writing only one screen for both interfaces: the
  ZMI and the end user. Here is how you can get to the new skin:

    http://localhost:8080/++skin++wiki/wiki/FrontPage

- Internationalized all of the skin as good as I could. So most of the 
  Site's Software text is displayed in German, including some complex
  message strings.

- Improved 'Add Comment' screen.



=== zopeproducts/zwiki/browser/comment_page.pt 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser/comment_page.pt:1.1	Wed Apr  9 17:47:16 2003
+++ zopeproducts/zwiki/browser/comment_page.pt	Thu Apr 10 02:28:14 2003
@@ -3,21 +3,36 @@
     <style metal:fill-slot="style_slot">
     </style>
   </head>
-  <body i18n:domain="wiki">
+  <body>
     <div metal:fill-slot="body">
 
-      <form action="addComment.html" method="post">
+      <form action="addComment.html" method="post" i18n:domain="wiki">
 
-        <table cellspacing="0" cellpadding="2" border="0">
-          <tr>
-            <td i18n:translate="">Comment</td>
-            <td>
-	      <textarea name="comment" cols="60" rows="10" />
-            </td>
-          </tr>
-        </table>
-        <input type="submit" name="submit" value="Submit" 
-	       i18n:attributes="value submit-button" />
+        <div class="row">
+            <div class="label" i18n:translate="">Comment</div>
+            <div class="field">
+	      <textarea name="comment" cols="60" rows="10"></textarea>
+            </div>
+        </div>
+
+        <div class="row">
+            <div class="label" i18n:translate="">
+              Wiki Source as reference
+            </div>
+            <div class="field">
+	      <textarea name="source" cols="60" rows="5" 
+                  tal:content="view/source"></textarea>
+            </div>
+        </div>
+
+      	<div class="row">
+      	  <div class="controls">
+      	    <input type="submit" value="Refresh" 
+                i18n:attributes="value refresh-button" />
+      	    <input type="submit" name="submit" value="Submit" 
+      		i18n:attributes="value submit-button" />
+      	  </div>
+      	</div>
 
       </form>
 


=== zopeproducts/zwiki/browser/configure.zcml 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser/configure.zcml:1.1	Wed Apr  9 17:47:16 2003
+++ zopeproducts/zwiki/browser/configure.zcml	Thu Apr 10 02:28:14 2003
@@ -2,9 +2,7 @@
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser">
 
-<include package=".skin" />
-
-  <!-- Browser-specific configuration -->
+  <include package=".skin" />
 
   <browser:menu
        id="add_wiki"
@@ -15,7 +13,7 @@
       for="zopeproducts.zwiki.interfaces.IWiki"
       name="+"
       class=".wiki.WikiAdding"
-      permission="zope.ManageContent"
+      permission="zopeproducts.zwiki.AddWikiPage"
       allowed_attributes="addingInfo"
       menu="zmi_actions"
       title="Add"
@@ -33,6 +31,9 @@
       menu="zmi_views"
       title="TOC"/>
 
+  <browser:defaultView
+      name="toc.html"
+      for="zopeproducts.zwiki.interfaces.IWiki"/>
 
   <browser:menuItem menu="add_content"
       for="zope.app.interfaces.container.IAdding"
@@ -55,7 +56,7 @@
       content_factory="zopeproducts.zwiki.wiki.WikiPage"
       permission="zopeproducts.zwiki.AddWikiPage"
       fields="source type"
-      class=".wikipage.EditWikiPage"
+      class=".wikipage.AddWikiPage"
       menu="add_wiki"
       title="Wiki Page"/>
 
@@ -71,11 +72,21 @@
 
   <browser:pages
       for="zopeproducts.zwiki.interfaces.IWikiPage"
+      class=".wikipage.GenericWikiPageViews"
+      permission="zopeproducts.zwiki.ViewWikiPage">
+      <browser:page name="breadcrumbs" attribute="breadcrumbs" />
+      <browser:page name="author" attribute="author" />
+      <browser:page name="modified" attribute="modified" />
+      <browser:page name="jumpto.html" attribute="jumpTo" />
+      <browser:page name="toc.html" attribute="toc" />
+  </browser:pages>
+
+  <browser:pages
+      for="zopeproducts.zwiki.interfaces.IWikiPage"
       class=".wikipage.ViewWikiPage"
       permission="zopeproducts.zwiki.ViewWikiPage">
       <browser:page name="view.html" template="view_page.pt"
           menu="zmi_views" title="View" />
-      <browser:page name="jumpto.html" attribute="jumpTo" />
   </browser:pages>
 
   <browser:pages
@@ -106,10 +117,33 @@
       file="wikipage_icon.gif"
       />
 
-<browser:page
-    name="_traverse" 
-    for="zopeproducts.zwiki.interfaces.IWikiPage"
-    class="zopeproducts.zwiki.traversal.WikiPageTraverser" 
-    permission="zope.Public" />
+  <!-- Make a special WikiPage menu -->
+
+  <browser:menu 
+       id="wikipage_actions" 
+       title="Menu for Wiki Page related actions."
+       />
+
+  <browser:menuItems menu="wikipage_actions" 
+      for="zopeproducts.zwiki.interfaces.IWikiPage">
+    <browser:menuItem title="View" action="@@view.html"/>
+    <browser:menuItem title="Comment" action="@@commentForm.html"/>
+    <browser:menuItem title="Edit" action="@@edit.html"/>
+    <browser:menuItem title="Parents" action="@@parents.html"/>
+    <browser:menuItem title="TOC" action="@@toc.html"/>
+  </browser:menuItems>
+
+  <browser:menuItems menu="wikipage_actions" 
+      for="zopeproducts.zwiki.interfaces.IWiki">
+    <browser:menuItem title="TOC" action="@@toc.html"/>
+  </browser:menuItems>
+
+  <!-- Register a browser-specific traverser --> 
+
+  <browser:page
+      name="_traverse" 
+      for="zopeproducts.zwiki.interfaces.IWikiPage"
+      class="zopeproducts.zwiki.traversal.WikiPageTraverser" 
+      permission="zope.Public" />
 
 </zopeConfigure>


=== zopeproducts/zwiki/browser/view_page.pt 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser/view_page.pt:1.1	Wed Apr  9 17:47:16 2003
+++ zopeproducts/zwiki/browser/view_page.pt	Thu Apr 10 02:28:14 2003
@@ -3,32 +3,12 @@
     <style metal:fill-slot="style_slot">
     </style>
   </head>
-  <body i18n:domain="wiki">
+  <body>
     <div metal:fill-slot="body">
 
-
-      <div id="wikipage_header">
-        <div id="wikipage_path" 
-           tal:content="structure view/breadcrumbs">Wikis/WikiPage
-        </div>
-        <div id="wikipage_info">Last modified by 
-          <b tal:content="view/author">srichter</b> on
-          <span tal:replace="view/modified">March 4, 2002.</span>
-        </div>
-      </div>
-
       <div tal:replace="structure view/render">
         This is the rendered Wiki
       </div>
-
-      <form action="jumpto.html">
-      <div class="box" id="jumpto">
-        <div class="body">
-          <span i18n:translate="">Jump to:</span><input
-            type="text" name="jumpto"/>
-        </div>
-      </div>
-      </form>
 
     </div>
   </body>


=== zopeproducts/zwiki/browser/wiki.py 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser/wiki.py:1.1	Wed Apr  9 17:47:16 2003
+++ zopeproducts/zwiki/browser/wiki.py	Thu Apr 10 02:28:14 2003
@@ -20,6 +20,8 @@
 from zope.app.traversing import objectName
 from zope.app.browser.container.adding import Adding
 
+from zopeproducts.zwiki.interfaces import IWikiPageHierarchy
+
 
 class WikiAdding(Adding):
     """Custom adding view for NewsSite objects."""


=== zopeproducts/zwiki/browser/wikipage.py 1.1 => 1.2 ===
--- zopeproducts/zwiki/browser/wikipage.py:1.1	Wed Apr  9 17:47:16 2003
+++ zopeproducts/zwiki/browser/wikipage.py	Thu Apr 10 02:28:14 2003
@@ -23,6 +23,7 @@
 from zope.component import getAdapter, getView, getService, createObject
 from zope.proxy.context import ContextWrapper
 from zope.app.browser.form.widget import ListWidget
+from zope.app.browser.form.submit import Update
 from zope.app.form.widget import CustomWidget
 from zope.app.traversing import getParent, getPath, objectName
 
@@ -47,6 +48,47 @@
                 (localwikilink, urlchars+urlendchar)
 
 
+class GenericWikiPageViews:
+    """Some generic Wiki page views."""
+    
+    def breadcrumbs(self):
+        """Get the path of this page."""
+        hier = getAdapter(self.context, IWikiPageHierarchy)
+        path = hier.path()
+        html = []
+        for page in path:
+            html.append('<a href="../%s">%s</a>' %(objectName(page),
+                                                   objectName(page)))
+        return ' / '.join(html)
+
+    def author(self):
+        """Get user who last modified the Wiki Page."""
+        creators = getAdapter(self.context, ICMFDublinCore).creators
+        if not creators:
+            return 'unknown'
+        return creators[0]
+
+    def modified(self):
+        """Get last modification date."""
+        date = getAdapter(self.context, ICMFDublinCore).modified
+        if date is None:
+            date = getAdapter(self.context, ICMFDublinCore).created
+        formatter = self.request.locale.getDateTimeFormatter('medium')
+        return formatter.format(date)
+
+    def jumpTo(self, jumpto):
+        """Try to get quickly to another Wiki page"""
+        wiki = getParent(self.context)
+        if jumpto in wiki:
+            return self.request.response.redirect('../'+jumpto)
+        else:
+            return self.request.response.redirect('.')
+
+    def toc(self):
+        """Simply forwards to the real TOC in the Wiki."""
+        return self.request.response.redirect('../@@toc.html')
+
+
 class SourceTypeWidget(ListWidget):
 
     size = 1
@@ -82,46 +124,29 @@
         return rendered_items
 
 
-class EditWikiPage(object):
+class AddWikiPage(object):
 
     type = CustomWidget(SourceTypeWidget)
 
+    def nextURL(self):
+        return '../'+self.context.contentName
 
-class ViewWikiPage:
-    """A rendered View of the wiki page."""
 
-    def breadcrumbs(self):
-        """Get the path of this page."""
-        hier = getAdapter(self.context, IWikiPageHierarchy)
-        path = hier.path()
-        html = []
-        for page in path:
-            html.append('<a href="%s">%s</a>' %(getPath(page),
-                                                objectName(page)))
-        return ' / '.join(html)
+class EditWikiPage(object):
 
-    def author(self):
-        """Get user who last modified the Wiki Page."""
-        creators = getAdapter(self.context, ICMFDublinCore).creators
-        if not creators:
-            return 'unknown'
-        return creators[0]
+    type = CustomWidget(SourceTypeWidget)
 
-    def modified(self):
-        """Get last modification date."""
-        date = getAdapter(self.context, ICMFDublinCore).modified
-        if date is None:
-            date = getAdapter(self.context, ICMFDublinCore).created
-        formatter = self.request.locale.getDateTimeFormatter('medium')
-        return formatter.format(date)
+    def update(self):
+        status = super(EditWikiPage, self).update()
 
-    def jumpTo(self, jumpto):
-        """Try to get quickly to another Wiki page"""
-        wiki = getParent(self.context)
-        if jumpto in wiki:
-            return self.request.response.redirect(getPath(wiki)+'/'+jumpto)
-        else:
-            return self.request.response.redirect('.')
+        if Update in self.request:
+            self.request.response.redirect('./@@view.html')
+
+        return status
+
+
+class ViewWikiPage:
+    """A rendered View of the wiki page."""
 
     def renderWikiLinks(self, source):
         """Add Wiki Links to the source"""
@@ -195,20 +220,21 @@
             if re.match('^["=]', m):     # "
                 return m
             else:
-                return '<a href="%s">%s</a>' % (m, m)
+                return '<a href="../%s">%s</a>' % (m, m)
 
         # it might be a structured text footnote ?
         elif re.search(r'(?si)<a name="%s"' % (m),text):
             return '<a href="#%s">[%s]</a>' % (m,m)
 
-        # a wikiname - if a page (or something) of this name exists, link to it
+        # a wikiname - if a page (or something) of this name exists, link to
+        # it
         elif m in wiki:
-            return '<a href="%s/%s">%s</a>' % (getPath(wiki), quote(m), m)
+            return '<a href="../%s">%s</a>' % (quote(m), m)
 
         # otherwise, provide a "?" creation link
         else:
-            return '%s<a href="%s/+/AddWikiPage=%s">?</a>' %(
-                morig, getPath(wiki), quote(m))
+            return '%s<a href="../+/AddWikiPage=%s">?</a>' %(
+                morig, quote(m))
 
 
     def _interwikilinkReplace(self, match, allowed=0, state=None, text=''):
@@ -289,8 +315,11 @@
         types = getService(self.context, "WikiSourceTypeRegistry")
         source = types.createObject(self.context.type, self.context.source)
         view = getView(source, None, self.request)
-        comment = view.createComment(comment, self.context.getCommentCounter())
+        comment = view.createComment(comment,
+                                     self.context.getCommentCounter())
         self.context.comment(comment)
         return self.request.response.redirect('.')
 
+    def source(self):
+        return '> ' + self.context.source.replace('\n', '\n> ')