[Zope3-checkins] CVS: zopeproducts/zwiki - INSTALL.txt:1.1 LICENSE.txt:1.1 READMDE.txt:1.1 TODO.txt:1.1 VERSION.txt:1.1 comment_page.pt:1.1 parents_page.pt:1.1 browser.py:1.3 configure.zcml:1.5 view_page.pt:1.2 zwiki.py:1.5

Stephan Richter srichter@cbu.edu
Sun, 6 Apr 2003 21:47:52 -0400


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

Modified Files:
	browser.py configure.zcml view_page.pt zwiki.py 
Added Files:
	INSTALL.txt LICENSE.txt READMDE.txt TODO.txt VERSION.txt 
	comment_page.pt parents_page.pt 
Log Message:
- Added several text files adding documentation. 

- Added Parents Hierarchy management. Reparenting works now via the Web.
  Showing Page sub tree.

- Fixed path to show the 'virtual path' of the Wiki page and renamed it 
  to breadcrumbs.

- Added support for comments.

- In the WikiPage view, show the last modification time and the last 
  modification user (yeah, I just use the creator DC attribute; definitely 
  not right).


=== Added File zopeproducts/zwiki/INSTALL.txt ===
Installation
============

  - create 'zopeproducts' inside your Zope 3 installation src directory

  - add an empty '__init__.py' to zopeproducts

  - copy the 'zwiki' folder to 'zopeproducts'

  - add the following line to products.zml file::

     <include package='zopeproducts.zwiki' />


=== Added File zopeproducts/zwiki/LICENSE.txt ===
Zope Public License (ZPL) Version 2.0
-----------------------------------------------

This software is Copyright (c) Zope Corporation (tm) and
Contributors. All rights reserved.

This license has been certified as open source. It has also
been designated as GPL compatible by the Free Software
Foundation (FSF).

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions in source code must retain the above
   copyright notice, this list of conditions, and the following
   disclaimer.

2. Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions, and the following
   disclaimer in the documentation and/or other materials
   provided with the distribution.

3. The name Zope Corporation (tm) must not be used to
   endorse or promote products derived from this software
   without prior written permission from Zope Corporation.

4. The right to distribute this software or to use it for
   any purpose does not give you the right to use Servicemarks
   (sm) or Trademarks (tm) of Zope Corporation. Use of them is
   covered in a separate agreement (see
   http://www.zope.com/Marks).

5. If any files are modified, you must cause the modified
   files to carry prominent notices stating that you changed
   the files and the date of any change.

Disclaimer

  THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS''
  AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
  NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
  NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  DAMAGE.


This software consists of contributions made by Zope
Corporation and many individuals on behalf of Zope
Corporation.  Specific attributions are listed in the
accompanying credits file.


=== Added File zopeproducts/zwiki/READMDE.txt ===
ZWiki for Zope 3
================

  This product is a port/rewrite of the famous Zope 2 product Zwiki. At the 
  current stage only the most basic Wiki functionalities are implemented and
  much more work needs to be done.

  Features

    - Wiki object. Container of all Wiki pages.

    - WikiPage content object, holding the data, which turned out to be tiny.

    - Beginnings of the PageHierarchyAdapter...no view and not tested.

    - Rendered code recognizes Wiki names, the escaping '!' and the '[]' for
      all lower case Wiki names.

    - Generated Links bring you either to another Wiki page or to an add page.

    - Assinging parents, allowing to create a "virtual" hierarchy.

    - Writing comments about the Wiki Page.

=== Added File zopeproducts/zwiki/TODO.txt ===
To Do
=====

  Tests

    - Add tests for the rendering.

    - Add test for findChildren.

    - Write tests for comment() method in WikiPage.


  Rendering/Views

    - Implement RenderingEngineService that maintains a registry of all
      available rendering methods, so that we can easily plug in new
      engines. Note that the original Zwiki product hard-codes all of the
      rendering possibilities, making ZWikiPage a huge class.

    - Incorporate STX and ReST in the Zope 3 core or at least in this product.

    - Create a custom skin, so that we are not relying on the standard Zope 3
      skin.

    - Make sure FTP and WebDAV work.

    - Have a "Jump to" form on the WikiPage view.
 
    - Create a Management screen (advancedform) that is accessible for users
      without management rights.

    - Table of Contents including unlinked and unparented WikiPages.

    - Improve 'Add Comment' screen to show existing Wiki content.


  Other Features

    - When creating a Wiki, the FrontPage WikiPage should be created by
      default.

    - Implement a custom traverser for WikiPages, so that URLs can represent 
      the page hierarchy.

    - Implement search.

    - Implement better security policies, i.e. custom permissions, roles...

    - Implement events, so that we can have E-mail subscriptions to Wiki
      changes.

    - Implements E-mail subscriptions.

=== Added File zopeproducts/zwiki/VERSION.txt ===
zwiki for z3 0.0.1 

=== Added File zopeproducts/zwiki/comment_page.pt ===
<html metal:use-macro="views/standard_macros/page">
  <head>
    <style metal:fill-slot="style_slot">
    </style>
  </head>
  <body>
    <div metal:fill-slot="body">

      <form action="addComment.html" method="post">
      
        <table cellspacing="0" cellpadding="2" border="0">
          <tr>
            <td>Comment</td>
            <td>
	      <textarea name="comment" cols="60" rows="10" />
            </td>
          </tr>
        </table>
        <input type="submit" name="submit" value="Submit" />

      </form>
      
    </div>
  </body>
</html>


=== Added File zopeproducts/zwiki/parents_page.pt ===
<html metal:use-macro="views/standard_macros/page">
  <head>
    <style metal:fill-slot="style_slot">
    </style>
  </head>
  <body>
    <div metal:fill-slot="body">

      <form action="setParents.html" method="post">
      
        <table cellspacing="0" cellpadding="2" border="0">
          <tr>
            <td>Parents</td>
            <td>
	      <select name="parents:list" multiple="">
                  <div tal:repeat="parent view/availableWikis" tal:omit-tag="">
                <option tal:content="parent" selected=""
                        tal:condition="python: parent in view.parents()">
                  Wiki1
                </option>
                <option tal:content="parent"
                        tal:condition="python: parent not in view.parents()">
                  Wiki1
                </option>
                </div>
              </select>
            </td>
          </tr>
        </table>
        <input type="submit" name="submit" value="Reparent" />

      </form>
      
      <h3>Branch</h3>

      <p tal:replace="structure view/branch" />

    </div>
  </body>
</html>


=== zopeproducts/zwiki/browser.py 1.2 => 1.3 ===
--- zopeproducts/zwiki/browser.py:1.2	Sun Apr  6 17:45:50 2003
+++ zopeproducts/zwiki/browser.py	Sun Apr  6 21:47:51 2003
@@ -18,6 +18,8 @@
 import re
 from urllib import quote, unquote
 
+from zope.app.interfaces.dublincore import ICMFDublinCore
+
 from zope.component import getAdapter
 from zope.app.browser.container.adding import Adding
 from zope.app.traversing import getParent, getPath, objectName
@@ -52,10 +54,30 @@
 class ViewWikiPage:
     """A rendered View of the wiki page."""
 
-    def path(self):
+    def breadcrumbs(self):
         """Get the path of this page."""
-        return "%s/%s" %(objectName(getParent(self.context)),
-                         objectName(self.context))
+        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)
+
+    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 renderWikiLinks(self, source):
         """Add Wiki Links to the source"""
@@ -196,4 +218,27 @@
         hier = getAdapter(self.context, IWikiPageHierarchy)
         hier.reparent(parents)
         return self.request.response.redirect('./@@parents.html')
+
+    def _branchHTML(self, children):
+        html = '<ul>\n'
+        for child, subs in children:
+            html += ' <li><a href="../%s">%s</a></li>\n' %(objectName(child),
+                                                           objectName(child))
+            if subs:
+                html += self._branchHTML(subs)
+        html += '</ul>\n'
+        return html
+        
+    def branch(self):
+        hier = getAdapter(self.context, IWikiPageHierarchy)
+        children = hier.findChildren()
+        return self._branchHTML(children)
         
+
+class WikiPageComment:
+
+    def comment(self, comment):
+        self.context.comment(comment, self.request.user.getLogin())
+        return self.request.response.redirect('.')
+
+    


=== zopeproducts/zwiki/configure.zcml 1.4 => 1.5 ===
--- zopeproducts/zwiki/configure.zcml:1.4	Sun Apr  6 17:45:50 2003
+++ zopeproducts/zwiki/configure.zcml	Sun Apr  6 21:47:51 2003
@@ -133,6 +133,15 @@
       <browser:page name="setParents.html" attribute="setParents" />
   </browser:pages>
 
+  <browser:pages
+      for=".interfaces.IWikiPage"
+      class=".browser.WikiPageComment"
+      permission="zope.ManageContent">
+      <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:defaultView
       name="view.html"
       for=".interfaces.IWikiPage"/>


=== zopeproducts/zwiki/view_page.pt 1.1 => 1.2 ===
--- zopeproducts/zwiki/view_page.pt:1.1	Sat Apr  5 15:50:02 2003
+++ zopeproducts/zwiki/view_page.pt	Sun Apr  6 21:47:51 2003
@@ -6,7 +6,10 @@
   <body>
     <div metal:fill-slot="body">
 
-      <h1 tal:content="view/path">Wikis/WikiPage</h1><br/>
+      <h1 tal:content="structure view/breadcrumbs">Wikis/WikiPage</h1>
+      <div>Last modified by <b tal:content="view/author">Stephan Richter</b> on 
+        <span tal:replace="view/modified">March 4, 2002.</span></div>
+      <br/>
 
       <p tal:replace="structure view/render">This is the rendered Wiki</p>
 


=== zopeproducts/zwiki/zwiki.py 1.4 => 1.5 ===
--- zopeproducts/zwiki/zwiki.py:1.4	Sun Apr  6 17:45:50 2003
+++ zopeproducts/zwiki/zwiki.py	Sun Apr  6 21:47:51 2003
@@ -16,7 +16,9 @@
 $Id$
 """
 from zope.component import getAdapter
+from zope.proxy.context import ContextWrapper
 from zope.app.content.folder import Folder
+from zope.app.traversing import getParent, objectName
 from zope.app.interfaces.annotation import IAnnotations
 
 from zopeproducts.zwiki.interfaces import IWiki, IWikiPage, IWikiPageHierarchy
@@ -42,13 +44,19 @@
     # See zopeproducts.zwiki.interfaces.IWikiPage
     type = u'plain text'
 
+    __comments = 0
+
     def append(self, source):
         "See zopeproducts.zwiki.interfaces.IWikiPage"
         self.source += source
 
     def comment(self, source, user):
         "See zopeproducts.zwiki.interfaces.IWikiPage"
-        self.append(comment_template %(1, user, source))
+        # XXX: KISS for now.
+        self.__comments += 1
+        if self.__comments == 1:
+            self.append('\n\n' + '-'*20);
+        self.append(comment_template %(self.__comments, user, source))
 
 
 class WikiPageHierarchyAdapter:
@@ -76,6 +84,34 @@
 
     parents = property(getParents, setParents)
 
+    def path(self):
+        "See zopeproducts.zwiki.interfaces.IWikiPageHierarchy"
+        # XXX: Allow for multpile parents
+        if not self.getParents():
+            return [self.context]
+        wiki = getParent(self.context)
+        name = self.getParents()[0]
+        wrapped = ContextWrapper(wiki[name], wiki, name=name)
+        hier = getAdapter(wrapped, IWikiPageHierarchy)
+        return hier.path() + [self.context] 
+        
+            
+    def findChildren(self, recursive=True):
+        "See zopeproducts.zwiki.interfaces.IWikiPageHierarchy"
+        wiki = getParent(self.context)
+        children = []
+        for pageName in wiki: 
+            wrapped = ContextWrapper(wiki[pageName], wiki,
+                                     name=pageName)
+            hier = getAdapter(wrapped, IWikiPageHierarchy)
+            if contextName in hier.getParents():
+                if recursive:
+                    subs = hier.findChildren()
+                else:
+                    subs = ()
+                children.append((wrapped, subs))
+        return children
+    
 
 comment_template = '''