[Checkins] SVN: zope3org/trunk/src/zorg/wikification/browser/ Added a wiki command for image uploads

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Tue May 2 11:35:28 EDT 2006


Log message for revision 67840:
  Added a wiki command for image uploads

Changed:
  U   zope3org/trunk/src/zorg/wikification/browser/configure.zcml
  A   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_image.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt
  U   zope3org/trunk/src/zorg/wikification/browser/wikilink.py
  U   zope3org/trunk/src/zorg/wikification/browser/wikipage.py

-=-
Modified: zope3org/trunk/src/zorg/wikification/browser/configure.zcml
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/configure.zcml	2006-05-02 14:22:06 UTC (rev 67839)
+++ zope3org/trunk/src/zorg/wikification/browser/configure.zcml	2006-05-02 15:35:27 UTC (rev 67840)
@@ -100,6 +100,10 @@
       <page
         name="uploadFile"
         attribute="uploadFile" />
+       
+      <page
+        name="uploadImage"
+        attribute="uploadImage" />
         
       <page 
         name="wikiupdate.html"
@@ -124,6 +128,10 @@
       <page
         name="uploadFile"
         attribute="uploadFile" />
+
+      <page
+        name="uploadImage"
+        attribute="uploadImage" />
         
       <page 
         name="wikiupdate.html"

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_image.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_image.pt	2006-05-02 14:22:06 UTC (rev 67839)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_image.pt	2006-05-02 15:35:27 UTC (rev 67840)
@@ -0,0 +1,65 @@
+<div class="wiki-form" tal:attributes="id string:upload_form${view/index}">
+    <form method="post"
+           enctype="multipart/form-data"
+           action="uploadImage"
+           onreset="WikiMenu.hideForm();">
+        <div class="wiki-form-title">Upload Image for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
+        <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
+        <input name="cmd" type="hidden" value="upload" />
+        <input name="reference" type="hidden" value="001" 
+                tal:attributes="name string:${view/processor/referenceKey};
+                value string:${view/processor/reference}" />
+        <table>
+            <tr>
+                <td valign="top" class="wiki-field">
+                    Image Name:
+                </td>
+                <td valign="top">
+                    <input class="wiki-input" id="image_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="wiki-field">
+                    Title:
+                </td>
+                <td valign="top">
+                    <input class="wiki-input" id="image_title" name="title" type="text" size="40" value=""/>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="wiki-field">
+                    Description: 
+                </td>
+                <td valign="top">
+                    <textarea class="wiki-input" id="description" name="description"
+                                   cols="37" rows="8" value="123"></textarea>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="wiki-field">
+                    File: 
+                </td>
+                <td>
+                    <input id="data" name="data" size="20" type="file" />
+                </td>
+            </tr>
+            <tr tal:condition="not: view/isUnique"> 
+                <td valign="top" class="wiki-field">
+                    Scope: 
+                </td>
+                <td valign="top" class="wiki-field">
+                    <input name="scope" id="scope" type="checkbox">
+                    Apply to all links named &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;.
+                </td>   
+            </tr>
+            <tr>
+                <td>&nbsp;		
+                </td>
+                <td>
+                    <input name="entry_submit" type="submit" value="Submit">
+                    <input name="cancel_submit" type="reset" value="Cancel"/>
+                </td>
+            </tr>
+        </table>
+    </form>
+</div>
\ No newline at end of file

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-05-02 14:22:06 UTC (rev 67839)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-05-02 15:35:27 UTC (rev 67840)
@@ -15,7 +15,7 @@
                     File Name:
                 </td>
                 <td valign="top">
-                    <input class="wiki-input" id="folder_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
+                    <input class="wiki-input" id="file_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
                 </td>
             </tr>
             <tr>

Modified: zope3org/trunk/src/zorg/wikification/browser/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-05-02 14:22:06 UTC (rev 67839)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-05-02 15:35:27 UTC (rev 67840)
@@ -203,14 +203,14 @@
         remaining = urllib.unquote(link)
         if link in self.traversed :
             return self.traversed[link]
-        path = [x for x in remaining.split("/") if x]        
+        path = [x for x in remaining.split("/") if x]
         while path :         
             try :
                 name = path[0]
                 name = unicode(name, encoding='utf-8')
                 node = zapi.traverseName(node, name)
                 name = path.pop(0)
-            except (TraversalError, UnicodeEncodeError) :
+            except (TraversalError, UnicodeEncodeError, UnicodeDecodeError) :
                 break
         self.traversed[link] = node, path
         return node, path
@@ -715,7 +715,7 @@
         return self.new_link
         
     def startTag(self, attrs) :
-        name = self.addObject()
+        name = self.apply()
         pattern = '<a href="%s"%s>'
         return pattern % (name, self._tagAttrs(attrs))
 
@@ -727,7 +727,7 @@
         
         
 class UploadFilePlaceholder(AddObjectPlaceholder) :
-    """ A placeholder that points to an uploaded file. """
+    """ A placeholder for a file. """
     
     title = u"Upload File"
     _form = ViewPageTemplateFile("./templates/wiki_upload.pt")
@@ -748,7 +748,19 @@
      
         return self._addObject(name, File(data, contenttype))
         
- 
+class UploadImagePlaceholder(UploadFilePlaceholder) :
+    """ A placeholder for an image. """
+    
+    title = u"Upload Image"
+    _form = ViewPageTemplateFile("./templates/wiki_image.pt")
+    
+    def performSubstitution(self) :
+        name = self.apply()
+        self.new_link = '<img src="%s"/>' % (name)
+        return self.new_link
+
+    
+    
 class CreateFolderPlaceholder(AddObjectPlaceholder) :
     """ A placeholder that points to a new folder. """
     
@@ -793,6 +805,7 @@
                
     cmds = dict(rename=RenamedPlaceholder, 
                         upload=UploadFilePlaceholder,
+                        image=UploadImagePlaceholder,
                         folder=CreateFolderPlaceholder,
                         newpage=CreatePagePlaceholder)
 
@@ -803,7 +816,7 @@
     
     def getItemInfos(self) :
         result = []
-        for cmd in 'rename', 'newpage', 'folder', 'upload' :
+        for cmd in 'rename', 'newpage', 'folder', 'upload', 'image' :
             command = self.cmds[cmd]
             result.append(dict(key=cmd, title=command.title))
         return result

Modified: zope3org/trunk/src/zorg/wikification/browser/wikipage.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-05-02 14:22:06 UTC (rev 67839)
+++ zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-05-02 15:35:27 UTC (rev 67840)
@@ -601,6 +601,13 @@
         """
         self._modifyLink('upload', link_id)
         self.request.response.redirect(self.nextURL())
+
+    def uploadImage(self, link_id) :
+        """ Uploads an image for a wikified link and redirects 
+            to the view again.
+        """
+        self._modifyLink('image', link_id)
+        self.request.response.redirect(self.nextURL())
         
     def modifyLink(self, cmd, link_id, verbose=True) :
         """ Modify a single link dynamically and return the new



More information about the Checkins mailing list