[Checkins] SVN: zwiki/trunk/ - Added preview feature

Baiju M baiju.m.mail at gmail.com
Wed Nov 28 07:02:46 EST 2007


Log message for revision 82007:
   - Added preview feature
   - Bit cleanup in docs and tests
  

Changed:
  U   zwiki/trunk/README.txt
  U   zwiki/trunk/TODO.txt
  U   zwiki/trunk/buildout.cfg
  U   zwiki/trunk/setup.py
  U   zwiki/trunk/src/zwiki/README.txt
  D   zwiki/trunk/src/zwiki/browser/browser.txt
  U   zwiki/trunk/src/zwiki/browser/configure.zcml
  U   zwiki/trunk/src/zwiki/browser/ftests.py
  A   zwiki/trunk/src/zwiki/browser/page_add.pt
  A   zwiki/trunk/src/zwiki/browser/wiki_edit.pt
  U   zwiki/trunk/src/zwiki/browser/wikipage.py
  U   zwiki/trunk/src/zwiki/browser/zwiki.txt
  U   zwiki/trunk/src/zwiki/ftesting.zcml

-=-
Modified: zwiki/trunk/README.txt
===================================================================
--- zwiki/trunk/README.txt	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/README.txt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -5,46 +5,5 @@
 the current stage only the most basic Wiki functionalities are
 implemented and much more work needs to be done.
 
-Features
---------
+For more details see: src/zwiki/README.txt
 
-Rendering
-
-  - Plain Text
-
-  - Structured Text
-
-  - reStructured Text (reST)
-
-
-Wiki
-
-  - Table of Contents
-
-  - Mail Subscription for entire Wiki
-
-  - Full-text Search
-
-
-Wiki Page
-
-  - Proper rendering of Wiki Links
-
-  - Edit Wiki Page
-
-  - Comment on a Wiki Page
-
-  - Declare Wiki Hierarchy (Parents)
-
-  - Local, WikiPage-based Mail Subscription
-
-  - Jumping to other Wikis
-
-
-Miscellaneous
-
-  - Somewhat sophisticated rendering mechanism. New source types and
-    their render methods can now be configured (added) via ZCML.
-
-  - A fully independent skin called 'wiki'; Note that this skin will
-    be only useful in the context of a Wiki Page.

Modified: zwiki/trunk/TODO.txt
===================================================================
--- zwiki/trunk/TODO.txt	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/TODO.txt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -1,14 +1,15 @@
 TODO
 ====
 
-Tests
 
+- Save older versions of pages
+- Check why `handle_save_action` and `handle_preview_action`
+  in `zwiki.browser.wikipage.EditWikiPage` is called two times.
+- full i18n support, now some strings are not i18ned
+- fix [[Test Link]] problem
 
-  - Convert unit tests to doc tests
 
-  - Add functional tests
 
-
 Rendering/Views
 
   - Create custom HTMLDocument class for rendering the STX and ReST in Wiki

Modified: zwiki/trunk/buildout.cfg
===================================================================
--- zwiki/trunk/buildout.cfg	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/buildout.cfg	2007-11-28 12:02:46 UTC (rev 82007)
@@ -2,8 +2,6 @@
 develop = .
 parts = zwikiapp instance test
 
-find-links = http://download.zope.org/distribution/
-
 [zope3]
 location =
 
@@ -20,6 +18,7 @@
             <include package="zope.sendmail" />
             <include package="zope.app.zptpage"/>
             <include package="zope.app.renderer"/>
+            <include package="zope.formlib"/>
             <include package="zwiki" />
 
             <securityPolicy 

Modified: zwiki/trunk/setup.py
===================================================================
--- zwiki/trunk/setup.py	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/setup.py	2007-11-28 12:02:46 UTC (rev 82007)
@@ -43,6 +43,8 @@
       install_requires = ['setuptools',
                           'zope.schema',
                           'zope.sendmail',
+                          'zope.formlib',
+                          'zope.cachedescriptors',
                           'zope.app.zcmlfiles',
                           'zope.app.twisted',
                           'zope.app.securitypolicy',
@@ -50,6 +52,7 @@
                           'zope.app.zptpage',
                           'zope.app.skins',
                           'zope.app.renderer',
+                          'zope.app.apidoc',
                           'Pygments',
                           ],
       extras_require = dict(test=['zope.app.testing',

Modified: zwiki/trunk/src/zwiki/README.txt
===================================================================
--- zwiki/trunk/src/zwiki/README.txt	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/README.txt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -5,10 +5,12 @@
 the current stage only the most basic Wiki functionalities are
 implemented and much more work needs to be done.
 
+
 Features
 --------
 
 Rendering
+~~~~~~~~~
 
   - Plain Text
 
@@ -18,6 +20,7 @@
 
 
 Wiki
+~~~~
 
   - Table of Contents
 
@@ -27,11 +30,14 @@
 
 
 Wiki Page
+~~~~~~~~~
 
   - Proper rendering of Wiki Links
 
   - Edit Wiki Page
 
+  - Preview while editing a page
+
   - Comment on a Wiki Page
 
   - Declare Wiki Hierarchy (Parents)
@@ -42,9 +48,37 @@
 
 
 Miscellaneous
+~~~~~~~~~~~~~
 
   - Somewhat sophisticated rendering mechanism. New source types and
     their render methods can now be configured (added) via ZCML.
 
   - A fully independent skin called 'wiki'; Note that this skin will
     be only useful in the context of a Wiki Page.
+
+Installation
+------------
+
+ 1. First checkout zwiki source from here::
+
+      svn co svn://svn.zope.org/repos/main/zwiki/trunk zwiki
+
+ 2. Run ``bootstrap.py`` from inside folder::
+
+      cd zwiki
+      python2.4 bootstrap.py
+
+ 3. After bootstraping run ``buildout`` command::
+
+      ./bin/buildout
+
+ 4. Firnally to run wiki application, execute ``instance`` script::
+
+      ./bin/instance fg
+
+ 5. Now open http://localhost:8080/manage, use 'admin' as username
+    and 'admin' as password.  Add wiki instance by clicking in the left
+    menu item for wiki adding.
+
+ 6. After adding wiki, you can access wiki from: 
+    http://localhost:8080/++skin++wiki/Wiki/FrontPage

Deleted: zwiki/trunk/src/zwiki/browser/browser.txt
===================================================================
--- zwiki/trunk/src/zwiki/browser/browser.txt	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/browser/browser.txt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -1,77 +0,0 @@
-==========
-Wiki Views
-==========
-
-ViewWikiPage
-------------
-
-Let's start by creating a wiki:
-
-  >>> print http(r"""
-  ... POST /+/AddWiki.html%3D HTTP/1.1
-  ... Authorization: Basic mgr:mgrpw
-  ... Content-Type: application/x-www-form-urlencoded
-  ... 
-  ... frontpage%3Aint=1&UPDATE_SUBMIT=Add&add_input_name=wiki""")
-  HTTP/1.1 303 See Other
-  ...
-
-Then add some cyrillic (utf-8) text for FrontPage:
-
-  >>> print http(r"""
-  ... POST /wiki/FrontPage/@@edit.html HTTP/1.1
-  ... Authorization: Basic mgr:mgrpw
-  ... Content-Type: multipart/form-data; boundary=---------------------------177450441711245361571701954867
-  ... 
-  ... -----------------------------177450441711245361571701954867
-  ... Content-Disposition: form-data; name="field.source"
-  ... 
-  ... Cyrillic text: Тест
-  ... -----------------------------177450441711245361571701954867
-  ... Content-Disposition: form-data; name="field.type"
-  ... 
-  ... zope.source.plaintext
-  ... -----------------------------177450441711245361571701954867
-  ... Content-Disposition: form-data; name="field.type-empty-marker"
-  ... 
-  ... 1
-  ... -----------------------------177450441711245361571701954867
-  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
-  ... 
-  ... Change
-  ... -----------------------------177450441711245361571701954867--
-  ... """)
-  HTTP/1.1 303 See Other
-  ...
-
-Now we can check the result:
-
-  >>> print http(r"""
-  ... GET /wiki/FrontPage/@@view.html HTTP/1.1
-  ... Authorization: Basic mgr:mgrpw
-  ... """)
-  HTTP/1.1 200 Ok
-  ...
-        Cyrillic text: Тест
-  ...
-  
-Code-block directive
---------------------
-
-  >>> from zope.testbrowser.testing import Browser
-  >>> browser = Browser()
-  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
-  >>> browser.handleErrors = False
-  >>> browser.open("http://localhost/wiki/FrontPage/@@edit.html")
-  >>> browser.getControl(name='field.type').displayValue = ['ReStructured Text (ReST)']
-  >>> browser.getControl(name='field.source').value = " \
-  ... \n\n..code-block:: python\
-  ... \n\n\tclass Test(object):\
-  ... \n\t\tdef test(self):\
-  ... \n\t\t\ta=3\
-  ... \n\n\n"
-  >>> browser.getControl('Change').click()
-  >>> browser.open("http://localhost/wiki/FrontPage/@@edit.html")
-
-This isn't working right now in the test. But doesn't cause errors. ;-)
-

Modified: zwiki/trunk/src/zwiki/browser/configure.zcml
===================================================================
--- zwiki/trunk/src/zwiki/browser/configure.zcml	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/browser/configure.zcml	2007-11-28 12:02:46 UTC (rev 82007)
@@ -12,14 +12,16 @@
       content_factory="zwiki.wiki.Wiki"
       permission="zwiki.AddWikiPage"
       class=".wiki.AddWiki"
-      template="wiki_add.pt" />
+      template="wiki_add.pt" 
+      />
 
   <browser:addMenuItem
       class="zwiki.wiki.Wiki"
       title="Wiki"
       description="A Wiki"
       permission="zope.ManageContent"
-      view="AddWiki.html" />
+      view="AddWiki.html" 
+      />
 
   <browser:containerViews
       for="zwiki.interfaces.IWiki"
@@ -33,7 +35,8 @@
       class=".wiki.TableOfContents"
       template="wiki_toc.pt"
       permission="zwiki.ViewWikiPage"
-      menu="zmi_views" title="TOC" />
+      menu="zmi_views" title="TOC" 
+      />
 
   <browser:page
       name="search.html" 
@@ -41,25 +44,33 @@
       class=".wiki.WikiSearch"
       template="wiki_search.pt"
       permission="zwiki.ViewWikiPage"
-      menu="zmi_views" title="Search" />
+      menu="zmi_views" title="Search" 
+      />
 
   <browser:pages
       for="zwiki.interfaces.IWiki"
       class=".wikipage.MailSubscriptions"
       permission="zwiki.EditWikiPage">
-      <browser:page name="subscriptions.html" template="subscriptions.pt"
-          menu="zmi_views" title="Subscriptions" />
+
+      <browser:page
+          name="subscriptions.html"
+          template="subscriptions.pt"
+          menu="zmi_views"
+          title="Subscriptions"
+          />
       <browser:page name="changeSubscriptions.html" attribute="change" />
   </browser:pages>
 
   <browser:defaultView
       name="toc.html"
-      for="zwiki.interfaces.IWiki" />
+      for="zwiki.interfaces.IWiki" 
+      />
 
   <browser:icon
       name="zmi_icon"
       for="zwiki.interfaces.IWiki"
-      file="wiki_icon.gif" />
+      file="wiki_icon.gif" 
+      />
 
   <!-- WikiPage browser configuration -->
 
@@ -68,36 +79,55 @@
       add="zwiki.CommentWikiPage"
       />
 
-  <browser:addform
+  <adapter
+      factory=".wikipage.page_add_template"
+      name="page_add"
+      />
+
+  <browser:page
+      name="AddWikiPage.html"
+      for="zope.app.container.interfaces.IAdding"
+      class=".wikipage.AddWikiPage"
+      template="page_add.pt"
+      permission="zwiki.AddWikiPage" 
+      />
+
+  <!--browser:addform
       label="Add Wiki Page"
       name="AddWikiPage.html"
       schema="zwiki.interfaces.IWikiPage"
       content_factory="zwiki.wikipage.WikiPage"
       permission="zwiki.AddWikiPage"
       fields="source type"
-      class=".wikipage.AddWikiPage" />
+      class=".wikipage.AddWikiPage" 
+      /-->
 
-  <browser:addMenuItem
+  <!--browser:addMenuItem
       class="zwiki.wikipage.WikiPage"
       title="Wiki Page"
       description="A Wiki Page"
       permission="zwiki.AddWikiPage"
-      view="AddWikiPage.html" />
+      view="AddWikiPage.html" 
+      /-->
 
-  <browser:editform
-      schema="zwiki.interfaces.IWikiPage"
+  <adapter
+      factory=".wikipage.wiki_edit_page_template"
+      name="wiki_edit"
+      />
+
+  <browser:page
+      name="edit.html"
       for="zwiki.interfaces.IWikiPage"
-      label="Change Wiki Page"
-      name="edit.html"
-      permission="zwiki.EditWikiPage"
-      fields="source type"
       class=".wikipage.EditWikiPage"
-      menu="zmi_views" title="Edit" />
+      template="wiki_edit.pt"
+      permission="zwiki.EditWikiPage" 
+      />
 
   <browser:pages
       for="zwiki.interfaces.IWikiPage"
       class=".wikipage.GenericWikiPageViews"
       permission="zwiki.ViewWikiPage">
+
       <browser:page name="breadcrumbs" attribute="breadcrumbs" />
       <browser:page name="author" attribute="author" />
       <browser:page name="modified" attribute="modified" />
@@ -109,16 +139,26 @@
       for="zwiki.interfaces.IWikiPage"
       class=".wikipage.ViewWikiPage"
       permission="zwiki.ViewWikiPage">
-      <browser:page name="view.html" template="view_page.pt"
-          menu="zmi_views" title="View" />
+
+      <browser:page
+          name="view.html"
+          template="view_page.pt"
+          menu="zmi_views"
+          title="View" 
+          />
   </browser:pages>
 
   <browser:pages
       for="zwiki.interfaces.IWikiPage"
       class=".wikipage.EditWikiParents"
       permission="zwiki.ReparentWikiPage">
-      <browser:page name="parents.html" template="parents_page.pt"
-          menu="zmi_views" title="Parents" />
+
+      <browser:page
+          name="parents.html"
+          template="parents_page.pt"
+          menu="zmi_views"
+          title="Parents" 
+          />
       <browser:page name="setParents.html" attribute="setParents" />
   </browser:pages>
 
@@ -126,8 +166,13 @@
       for="zwiki.interfaces.IWikiPage"
       class=".wikipage.MailSubscriptions"
       permission="zwiki.EditWikiPage">
-      <browser:page name="subscriptions.html" template="subscriptions.pt"
-          menu="zmi_views" title="Subscriptions" />
+
+      <browser:page
+          name="subscriptions.html" 
+          template="subscriptions.pt"
+          menu="zmi_views"
+          title="Subscriptions" 
+          />
       <browser:page name="changeSubscriptions.html" attribute="change" />
   </browser:pages>
 
@@ -149,36 +194,41 @@
       content_factory="zwiki.comment.Comment"
       permission="zwiki.CommentWikiPage"
       fields="title source type"
-      class=".wikipage.AddComment" />
+      class=".wikipage.AddComment" 
+      />
 
   <browser:addMenuItem
       class="zwiki.comment.Comment"
       title="Comment"
       description="A Comment"
       permission="zwiki.CommentWikiPage"
-      view="AddComment.html" />
+      view="AddComment.html" 
+      />
 
   <!-- Make a special WikiPage menu -->
 
   <browser:menu 
-       id="wikipage_actions" 
-       title="Menu for Wiki Page related actions." />
+      id="wikipage_actions" 
+      title="Menu for Wiki Page related actions." />
 
   <browser:menuItems menu="wikipage_actions" 
       for="zwiki.interfaces.IWikiPage">
-    <browser:menuItem title="View" action="@@view.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"/>
-    <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
+
+      <browser:menuItem title="View" action="@@view.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"/>
+      <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
   </browser:menuItems>
 
-  <browser:menuItems menu="wikipage_actions" 
+  <browser:menuItems
+      menu="wikipage_actions" 
       for="zwiki.interfaces.IWiki">
-    <browser:menuItem title="Table of Contents" action="@@toc.html"/>
-    <browser:menuItem title="Search" action="@@search.html"/>
-    <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
+
+      <browser:menuItem title="Table of Contents" action="@@toc.html"/>
+      <browser:menuItem title="Search" action="@@search.html"/>
+      <browser:menuItem title="Subscriptions" action="@@subscriptions.html"/>
   </browser:menuItems>
 
   <!-- Register a browser-specific traverser --> 

Modified: zwiki/trunk/src/zwiki/browser/ftests.py
===================================================================
--- zwiki/trunk/src/zwiki/browser/ftests.py	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/browser/ftests.py	2007-11-28 12:02:46 UTC (rev 82007)
@@ -21,10 +21,8 @@
 import unittest
 
 def test_suite():
-    browser = FunctionalDocFileSuite("browser.txt")
-    browser.layer = ZWikiLayer
     zwiki = FunctionalDocFileSuite("zwiki.txt")
     zwiki.layer = ZWikiLayer
     return unittest.TestSuite((
-        browser,
-        zwiki,))
+        zwiki,
+        ))

Added: zwiki/trunk/src/zwiki/browser/page_add.pt
===================================================================
--- zwiki/trunk/src/zwiki/browser/page_add.pt	                        (rev 0)
+++ zwiki/trunk/src/zwiki/browser/page_add.pt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -0,0 +1,31 @@
+<html metal:use-macro="views/standard_macros/page"
+    i18n:domain="zwiki">
+  <head>
+    <style metal:fill-slot="style_slot">
+    </style>
+  </head>
+  <body>
+    <div metal:fill-slot="body">
+
+      <p tal:define="status view/update"
+         tal:condition="status"
+         tal:content="status" 
+         />
+
+      <form action="." tal:attributes="action request/URL">
+
+        <div tal:repeat="widget view/widgets">
+          <b tal:content="widget/label" i18n:translate="">label</b>
+          <div tal:content="structure widget"></div>
+        </div>
+
+        <input tal:repeat="action view/actions"
+            tal:replace="structure action/render"
+            />
+
+      </form>
+      <hr/>
+      <div tal:replace="structure view/output">Output goes here</div>
+    </div>
+  </body>
+</html>

Added: zwiki/trunk/src/zwiki/browser/wiki_edit.pt
===================================================================
--- zwiki/trunk/src/zwiki/browser/wiki_edit.pt	                        (rev 0)
+++ zwiki/trunk/src/zwiki/browser/wiki_edit.pt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -0,0 +1,31 @@
+<html metal:use-macro="views/standard_macros/page"
+    i18n:domain="zwiki">
+  <head>
+    <style metal:fill-slot="style_slot">
+    </style>
+  </head>
+  <body>
+    <div metal:fill-slot="body">
+
+      <p tal:define="status view/update"
+         tal:condition="status"
+         tal:content="status" 
+         />
+
+      <form action="." tal:attributes="action request/URL">
+
+        <div tal:repeat="widget view/widgets">
+          <b tal:content="widget/label" i18n:translate="">label</b>
+          <div tal:content="structure widget"></div>
+        </div>
+
+        <input tal:repeat="action view/actions"
+            tal:replace="structure action/render"
+            />
+
+      </form>
+      <hr/>
+      <div tal:replace="structure view/output">Output goes here</div>
+    </div>
+  </body>
+</html>

Modified: zwiki/trunk/src/zwiki/browser/wikipage.py
===================================================================
--- zwiki/trunk/src/zwiki/browser/wikipage.py	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/browser/wikipage.py	2007-11-28 12:02:46 UTC (rev 82007)
@@ -24,6 +24,12 @@
 from zope.publisher.browser import BrowserView
 from zope.dublincore.interfaces import ICMFDublinCore
 from zope.app.form.browser.submit import Update
+from zope.formlib import form
+from zope.formlib import namedtemplate
+from zope.app.pagetemplate import ViewPageTemplateFile
+from zwiki.interfaces import IWikiPage
+import zope.cachedescriptors.property
+from zwiki.wikipage import WikiPage
 
 from zwiki.interfaces import IWikiPageHierarchy, IMailSubscriptions
 
@@ -95,26 +101,8 @@
         return self.request.response.redirect('../@@toc.html')
 
 
-class AddWikiPage(object):
+class RenderWiki(object):
 
-    def nextURL(self):
-        return '../'+self.context.contentName
-
-
-class EditWikiPage(object):
-
-    def update(self):
-        status = super(EditWikiPage, self).update()
-
-        if Update in self.request:
-            self.request.response.redirect('./@@view.html')
-
-        return status
-
-
-class ViewWikiPage(object):
-    """A rendered View of the wiki page."""
-
     def renderWikiLinks(self, html):
         """Add Wiki Links to the source"""
         html = protectedLine.sub(self._protectLine, html)
@@ -122,31 +110,6 @@
         html = wikilink.sub(self._wikilinkReplace, html)
         return html
 
-    def render(self):
-        """Render the wiki page source."""
-        source = createObject(self.context.type, self.context.source)
-        view = getMultiAdapter((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 = createObject(comment.type, comment.source)
-            view = getMultiAdapter(
-                (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 wikilink.sub(r'!\1', match.group(1))
 
@@ -251,6 +214,88 @@
         return match.group(0)
 
 
+class AddWikiPage(form.AddForm, RenderWiki):
+    form_fields = form.Fields(IWikiPage)
+    template = namedtemplate.NamedTemplate('page_add')
+    preview_actions = form.Actions()
+    output = ""
+
+    def create(self, data):
+        wikipage = WikiPage()
+        form.applyChanges(wikipage, self.form_fields, data)
+        return wikipage
+
+    @form.action(u'Preview', preview_actions)
+    def handle_review_action(self, action, data):
+        source = createObject(data['type'], data['source'])
+        view = getMultiAdapter((removeAllProxies(source), self.request))
+        html = view.render()
+        html = self.renderWikiLinks(html)
+        self.output = html
+
+    @zope.cachedescriptors.property.Lazy
+    def actions(self):
+        base = list(super(AddWikiPage, self).actions)
+        preview_actions = list(self.preview_actions)
+        return base + preview_actions
+
+    def nextURL(self):
+        return '../'+self.context.contentName
+
+
+class EditWikiPage(form.EditForm, RenderWiki):
+    form_fields = form.Fields(IWikiPage)
+    template = namedtemplate.NamedTemplate('wiki_edit')
+    output = ""
+
+    actions = form.Actions(
+        form.Action('Save', success='handle_save_action'),
+        form.Action('Preview', success='handle_preview_action'),
+        )
+    
+    def handle_save_action(self, action, data):
+        if form.applyChanges(self.context, self.form_fields, data):
+            self.status = 'Object updated'
+        else:
+            self.status = 'No changes'
+        self.request.response.redirect('./@@view.html')
+
+    def handle_preview_action(self, action, data):
+        source = createObject(data['type'], data['source'])
+        view = getMultiAdapter((removeAllProxies(source), self.request))
+        html = view.render()
+        html = self.renderWikiLinks(html)
+        self.output = html
+
+class ViewWikiPage(RenderWiki):
+    """A rendered View of the wiki page."""
+
+    def render(self):
+        """Render the wiki page source."""
+        source = createObject(self.context.type, self.context.source)
+        view = getMultiAdapter((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 = createObject(comment.type, comment.source)
+            view = getMultiAdapter(
+                (removeAllProxies(source), self.request))
+            result.append({
+                'name': name,
+                'title': comment.title,
+                'author': dc.author(),
+                'modified': dc.modified(),
+                'text': view.render()
+                })
+
+        return result
+
+
 class EditWikiParents(object):
 
     def parents(self):
@@ -305,3 +350,13 @@
                 IMailSubscriptions(self.context).removeSubscriptions(emails)
 
         self.request.response.redirect('.')
+
+#Templates
+
+page_add_template = namedtemplate.NamedTemplateImplementation(
+    ViewPageTemplateFile('page_add.pt'),
+    form.interfaces.IPageForm)
+
+wiki_edit_page_template = namedtemplate.NamedTemplateImplementation(
+    ViewPageTemplateFile('wiki_edit.pt'),
+    form.interfaces.IPageForm)

Modified: zwiki/trunk/src/zwiki/browser/zwiki.txt
===================================================================
--- zwiki/trunk/src/zwiki/browser/zwiki.txt	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/browser/zwiki.txt	2007-11-28 12:02:46 UTC (rev 82007)
@@ -1,6 +1,6 @@
 
-Sqaure Initialization
----------------------
+Wiki Initialization
+-------------------
 
 Initialize the browser and set authorization::
 
@@ -8,7 +8,7 @@
   >>> browser = Browser()
   >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
 
-Open square adding form and check url::
+Open wiki adding form and check url::
 
   >>> browser.open('http://localhost/+/AddWiki.html=')
   >>> browser.url
@@ -51,14 +51,14 @@
   >>> editlink.click()
   >>> browser.url
   'http://localhost/++skin++wiki/MyWiki/FrontPage/@@edit.html'
-  >>> source = browser.getControl(name="field.source")
+  >>> source = browser.getControl(name="form.source")
   >>> source.value = 'Visit this TestPage'
   >>> source.value
   'Visit this TestPage'
 
 Submit the form, test url and visit TestPage::
 
-  >>> browser.getControl(name="UPDATE_SUBMIT").click()
+  >>> browser.getControl(name="form.actions.save").click()
   >>> browser.url
   'http://localhost/++skin++wiki/MyWiki/FrontPage/@@view.html'
   >>> browser.title
@@ -72,14 +72,14 @@
 
 Edit TestPage::
 
-  >>> source = browser.getControl(name="field.source")
+  >>> source = browser.getControl(name="form.source")
   >>> source.value = 'Go to FrontPage'
   >>> source.value
   'Go to FrontPage'
 
 Submit the form, test url and visit FrontPage::
 
-  >>> browser.getControl(name="UPDATE_SUBMIT").click()
+  >>> browser.getControl(name="form.actions.add").click()
   >>> browser.url
   'http://localhost/++skin++wiki/MyWiki/TestPage'
   >>> browser.title
@@ -117,3 +117,29 @@
   >>> 'This is comment 1' in browser.contents
   True
 
+Edit FrontPage with some complex data::
+
+  >>> editlink = browser.getLink("Edit")
+  >>> editlink.click()
+  >>> browser.url
+  'http://localhost/++skin++wiki/MyWiki/FrontPage/@@edit.html'
+  >>> source = browser.getControl(name="form.source")
+  >>> source.value = 'Visit [this [Test Link]]'
+
+(Enable this)::
+
+  >>> #browser.getControl(name="form.actions.save").click()
+  >>> #browser.url
+  >>> #'http://localhost/++skin++wiki/MyWiki/FrontPage/@@view.html'
+
+Test code-block directive::
+
+  >>> browser.open("http://localhost/++skin++wiki/MyWiki/FrontPage/@@edit.html")
+  >>> browser.getControl(name='form.type').displayValue = ['ReStructured Text (ReST)']
+  >>> browser.getControl(name='form.source').value = " \
+  ... \n\n..code-block:: python\
+  ... \n\n\tclass Test(object):\
+  ... \n\t\tdef test(self):\
+  ... \n\t\t\ta=3\
+  ... \n\n\n"
+  >>> browser.getControl(name='form.actions.save').click()

Modified: zwiki/trunk/src/zwiki/ftesting.zcml
===================================================================
--- zwiki/trunk/src/zwiki/ftesting.zcml	2007-11-28 09:30:48 UTC (rev 82006)
+++ zwiki/trunk/src/zwiki/ftesting.zcml	2007-11-28 12:02:46 UTC (rev 82007)
@@ -19,6 +19,7 @@
   <include package="zope.sendmail" />
   <include package="zope.app.zptpage"/>
   <include package="zope.app.renderer"/>
+  <include package="zope.formlib"/>
   <include package="zwiki" />
 
   <securityPolicy 



More information about the Checkins mailing list