[Checkins] SVN: zope3org/trunk/src/zorg/wikification/browser/ refactored wiki link menus and commands

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Fri Apr 21 13:27:04 EDT 2006


Log message for revision 67235:
  refactored wiki link menus and commands

Changed:
  U   zope3org/trunk/src/zorg/wikification/browser/README.txt
  U   zope3org/trunk/src/zorg/wikification/browser/configure.zcml
  U   zope3org/trunk/src/zorg/wikification/browser/scripts/link.js
  U   zope3org/trunk/src/zorg/wikification/browser/style/main.css
  U   zope3org/trunk/src/zorg/wikification/browser/templates/linkmenu.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/view.pt
  A   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt
  A   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
  A   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt
  A   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
  A   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/README.txt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/README.txt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/README.txt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -133,52 +133,63 @@
     >>> print index_page.renderBody()
     <BLANKLINE>
     ...
-    ...PopupMenu.update...>new page</a>...
+    ...WikiMenu.dropDown...>new page</a>...
     ...
-    ...PopupMenu.update...>[New Subject]</a>...
+    ...WikiMenu.dropDown...>[New Subject]</a>...
     ...   
     
-The menu is loaded on demand. 
+The forms for the menu commands are loaded on demand: 
 
     >>> modified = index_page.getModificationStamp()
-    >>> print index_page.popupLinkMenu('wiki-menu5', modified)
-    <span>
+    >>> print index_page.wikiCommandForm('rename', 5, modified)
+    <div class="inline_form" id="create_folder5">
+        <form method="post" enctype="multipart/form-data" action="renameLink" onsubmit="WikiMenu.submitForm(this); return false;" onreset="WikiMenu.hideForm()">
     <BLANKLINE>
-        <div style="display: true;" class="anylinkcss"
-             id="popup_items">
-            <span class="anylinkheader">Edit this Link</span>
-            <div class="anylinkitem"
-                 onclick="editPlaceholderLabel('wiki-link5', 'wiki-menu5', 'New Subject', '')">
-                Rename
-            </div>
-            <a class="anylinkitem"
-               href="http://127.0.0.1/site/@@wikiedit.html?add=NewSubject">
-                Add Page
-            </a>
-            <div class="anylinkitem"
-                 onclick="PopupMenu.showForm('create_folder5')">
-                Create Folder
-            </div>
-            <div class="anylinkitem"
-                 onclick="PopupMenu.showForm('upload_form5')">
-                Upload File
-            </div>
-        </div>
-    ...
-   
+            <h4>Rename Link &quot;New Subject&quot;</h4>
+            <input name="link_id" type="hidden"
+                   value="wiki-link5" />
+            <input name="cmd" type="hidden" value="rename" />
+            <input name="url" type="hidden"
+                   value="http://127.0.0.1/site/index.html" />
+            <table>
+                <tr>
+                    <td valign="top" class="form-title">
+                        New Label:
+                    </td>
+                    <td valign="top">
+                        <input id="link_label" name="label"
+                               type="text" size="40"
+                               value="New Subject" />
+                    </td>
+                </tr>
+    <BLANKLINE>
+                <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>
+    <BLANKLINE>
+    
 If the page has change after the loading the user is alerted that the page
 needs a refresh to be up to date:
 
-    >>> print index_page.popupLinkMenu('wiki-menu5', "modified-timestamp")
-    <span>
-        <div id="popup_items">
-            <form class="inline_form">
-                <span class="anylinkheader">The page has been edited. Please reloaad.
-                </span>
-                <input name="reload" id="reload" type="submit" onselect="window.reload()" value="Reload Page">
-            </form>
-        </div>
-    ...    
+    >>> print index_page.wikiCommandForm('rename', 5, "modified-timestamp")
+    <div>
+        <form class="inline_form" onsubmit="window.reload(); return false;">
+            <span class="anylinkheader">The page has been edited. Please reloaad.
+            </span>
+            <input name="url" type="hidden"
+                   value="http://127.0.0.1/site/index.html" />
+            <input name="reload" id="reload" type="submit" value="Reload Page">
+        </form>
+    </div>
+    <BLANKLINE>
 
 Some of the menu items allow the user to edit the link within the view page.
 
@@ -193,7 +204,7 @@
     >>> print edit_page.modifyLink(cmd='rename', link_id='wiki-link5')
     <BLANKLINE>
     ...
-    ...PopupMenu.update...[New Label]...
+    ...WikiMenu.dropDown...[New Label]...
     ...
       
     

Modified: zope3org/trunk/src/zorg/wikification/browser/configure.zcml
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/configure.zcml	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/configure.zcml	2006-04-21 17:27:03 UTC (rev 67235)
@@ -44,16 +44,16 @@
     <page
         class=".wikipage.WikiFilePage"
         for="zope.app.file.interfaces.IFile"
-        name="popupLinkMenu"
-        attribute="popupLinkMenu"
+        name="wikiCommandForm"
+        attribute="wikiCommandForm"
         permission="zope.View"
         />
 
     <page
         class=".wikipage.WikiContainerPage"
         for="zope.app.folder.interfaces.IFolder"
-        name="popupLinkMenu"
-        attribute="popupLinkMenu"
+        name="wikiCommandForm"
+        attribute="wikiCommandForm"
         permission="zope.View"
         />
 

Modified: zope3org/trunk/src/zorg/wikification/browser/scripts/link.js
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/scripts/link.js	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/scripts/link.js	2006-04-21 17:27:03 UTC (rev 67235)
@@ -1,36 +1,47 @@
 
-var PopupMenu = {
+var WikiMenu = {
 
-    dropmenuID : "",
-
-    initialize : function() {
-        document.onmousedown = PopupMenu.onMouseDown;
-        },
+    linkID : -1,
+    extraInfo : "",
+    caller : null,
+    
+    dropDown : function(obj, e, dropmenuID, extra) {
+    
+        if (WikiMenu.linkID != -1) return
         
-    leave : function (caller, dropmenuID) {
-        // PopupMenu.close();
+        WikiMenu.extraInfo = extra;
+        WikiMenu.caller = obj;
+        target = $(dropmenuID);
+        
+        if (window.event) 
+            event.cancelBubble=true
+        else if (e.stopPropagation) 
+            e.stopPropagation()
+        
+        if (typeof dropmenuobj!="undefined") //hide previous menu
+            dropmenuobj.style.visibility="hidden"
+            clearhidemenu()
+            if (ie5||ns6){
+                obj.onmouseout=delayhidemenu
+                dropmenuobj = target;
+                if (hidemenu_onclick) 
+                    dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
+                dropmenuobj.onmouseover=clearhidemenu
+                dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
+                showhide(dropmenuobj.style, e, "visible", "hidden")
+                dropmenuobj.x=getposOffset(obj, "left")
+                dropmenuobj.y=getposOffset(obj, "top")
+                dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
+                dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
+                }
+        return clickreturnvalue()
         },
-            
-    update : function (caller, dropmenuID, extra)  {
-        document.onmousedown = PopupMenu.onMouseDown;
-        if (PopupMenu.dropmenuID != dropmenuID) {
-            PopupMenu.close();
-            var timestamp =  $('modification_stamp').innerHTML;
-            timestamp = timestamp.replace(/\+/g, '%2b');        // Obey + in datetime str format
-            timestamp = "&modification_stamp=" + timestamp;
-            
-            new Ajax.Updater('wiki_popup_menu', './@@popupLinkMenu', 
-                { parameters: 'menu_id='+ dropmenuID + timestamp + extra});
-            PopupMenu.dropmenuID = dropmenuID  
-            PopupMenu.placeNextTo(caller);
-            }
-        },
-
+        
     close : function (event) {
-        if ($('wiki_popup_menu').innerHTML) {
-            $('wiki_popup_menu').innerHTML = "";
+        if ($('wiki_link_form').innerHTML) {
+            $('wiki_link_form').innerHTML = "";
             }
-        PopupMenu.dropmenuID = "";
+        WikiMenu.linkID = -1;
         },
         
     alertReload : function () {
@@ -38,7 +49,7 @@
         },
         
     editPlaceholderLabel : function (link_id, menu_id, label, extra) {
-        PopupMenu.close();
+        WikiMenu.close();
         var newLabel = prompt('Enter a new label.',  label);
         if (newLabel) {
             var params = '&label=' + newLabel + extra;
@@ -49,58 +60,44 @@
         },
 
         
-    submitForm : function (id, form) {
+    submitForm : function (form) {
+        
         new Ajax.Updater('main', './@@modifyLink', {
             parameters:Form.serialize(form),
             onError: function(request) { alert("Sorry, a server error occurred."); },
-            onComplete: function(request) { PopupMenu.hideForm(id); }
+            onComplete: function(request) { WikiMenu.hideForm(); }
             });
+            
         return false;  
         },
         
-    showForm : function (id) {
-        Element.hide('popup_items');
-        Element.show(id);
+    showForm : function (cmd, id) {
+       if (WikiMenu.linkID != id) {
+            //WikiMenu.close();
+           
+            var timestamp =  $('modification_stamp').innerHTML;
+            timestamp = timestamp.replace(/\+/g, '%2b');        // Obey + in datetime str format
+            timestamp = "&modification_stamp=" + timestamp;
+            
+            new Ajax.Updater('wiki_link_form', './@@wikiCommandForm', 
+                { parameters: 'cmd=' + cmd + '&menu_id='+ id + timestamp + WikiMenu.extraInfo});
+            WikiMenu.linkID = id;  
+            WikiMenu.placeNextTo(WikiMenu.caller);
+            }
         },
         
-    hideForm : function (id) {
-        Element.hide(id);
-        PopupMenu.close();
+    hideForm : function () {
+        WikiMenu.close();
         },
         
     placeNextTo : function(obj) {
         var offsets = Position.positionedOffset(obj)
-                
         var x = offsets[0];
         var y = offsets[1];
-        var menu = $('wiki_popup_menu');
-        menu.style.left=x + "px";
-        menu.style.top=y + 15 + "px";
-        },
-    
-    
-    onMouseDown : function (event) {
-        if (!event) var event = window.event; // IE compatibility
         
-        if (event.target) {
-            targ = event.target;
-            }
-        else if (event.srcElement) {
-            targ = event.srcElement;
-            }
-        
-        var node = targ;
-        while (node) {
-            if (node == $('wiki_popup_menu')) {
-                return;
-                }
-            node = node.parentNode;
-            }
-            
-        PopupMenu.close();
+        var form = $('wiki_link_form');
+        form.style.left=x + "px";
+        form.style.top=y + 15 + "px";
         }
-}
-
-
-window.onload = PopupMenu.initialize;
-
+    
+}
\ No newline at end of file

Modified: zope3org/trunk/src/zorg/wikification/browser/style/main.css
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/style/main.css	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/style/main.css	2006-04-21 17:27:03 UTC (rev 67235)
@@ -23,22 +23,22 @@
 }
 
 .inline_form {
-    position:absolute;
     border: 1px solid #666666;
     padding: 4px;
     font:normal 10px Verdana;
     line-height: 18px;
-    z-index: 100;
     background-color: #EDF0F4;
     width: 400px;
 }
 
-#wiki_popup_menu {
+#wiki_link_form {
     position:absolute;
     z-index: 100;
 }
 
 .anylinkcss {
+    position:absolute;
+    z-index: 100;
     border:1px solid #666666;
     border-bottom-width: 0;
     font:normal 10px Verdana;

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/linkmenu.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/linkmenu.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/linkmenu.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -1,127 +1,8 @@
-<span>
-    <div tal:condition="view/outdated" id="popup_items">
-        <form class="inline_form" >
-            <span class="anylinkheader">The page has been edited. Please reloaad.
-            </span>
-            <input name="reload" id="reload" 
-                type="submit" onselect="window.reload()" 
-                value="Reload Page">
-        </form>
+<div style="visibility: hidden;" class="anylinkcss" id="menu_id" tal:attributes="id string:${view/menu_id}">
+    <span class="anylinkheader">Menu for &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</span>
+    <div class="anylinkitem"
+            tal:repeat="item view/processor/getItemInfos"  
+            tal:attributes="onclick string:WikiMenu.showForm('${item/key}', ${view/index});"
+            tal:content="item/title">Item
     </div>
-    <div tal:condition="not: view/outdated" style="display: true;" class="anylinkcss" id="popup_items">
-        <span class="anylinkheader">Edit this Link</span>
-        <div class="anylinkitem" onclick="editPlaceholderLabel();"
-             tal:attributes="onclick string:editPlaceholderLabel('${view/link_id}', '${view/menu_id}', '${view/unicodeLabel}', '');">
-            Rename
-        </div>
-        <a class="anylinkitem" href="#" tal:attributes="href view/link">
-            Add Page
-        </a>
-        <div class="anylinkitem" tal:attributes="onclick string:PopupMenu.showForm('create_folder${view/index}');">
-            Create Folder
-        </div>
-        <div class="anylinkitem" tal:attributes="onclick string:PopupMenu.showForm('upload_form${view/index}');">
-            Upload File
-        </div>
-    </div>
-    <div class="inline_form" tal:attributes="id string:upload_form${view/index}" style="display:none;">
-        <form method="post"
-               enctype="multipart/form-data"
-               action="uploadFile"
-               tal:attributes="onreset string:PopupMenu.hideForm('upload_form${view/index}');">
-            <h4>Upload File</h4>
-            <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
-            <table>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Name:
-                    </td>
-                    <td valign="top" >
-                        <input id="folder_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
-                    </td>
-                </tr>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Title:
-                    </td>
-                    <td valign="top" >
-                        <input id="file_title" name="title" type="text" size="40" value=""/>
-                    </td>
-                </tr>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Description: 
-                    </td>
-                    <td valign="top" >
-                        <textarea id="description" name="description"
-                                       cols="37" rows="8" value="123"></textarea>
-                    </td>
-                </tr>
-                <tr>
-                    <td valign="top" class="form-title">
-                        File: 
-                    </td>
-                    <td>
-                        <input id="data" name="data" size="20" type="file" />
-                    </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>
-    <div class="inline_form" tal:attributes="id string:create_folder${view/index}" style="display:none;">
-        <form method="post"
-               enctype="multipart/form-data"
-               tal:attributes="onsubmit string:PopupMenu.submitForm('create_folder${view/index}', this);;;
-                               onreset string:PopupMenu.hideForm('create_folder${view/index}');;">
-            <h4>Create Folder</h4>
-            <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
-            <input name="cmd" type="hidden" value="folder" />
-            <table>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Name:
-                    </td>
-                    <td valign="top" >
-                        <input id="folder_name" name="name" type="text" size="40" value="FolderName" tal:attributes="value python: view.upload_name or view.unicodeLabel()" />
-                    </td>
-                </tr>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Title:
-                    </td>
-                    <td valign="top" >
-                        <input id="file_title" name="title" type="text" size="40" value=""/>
-                    </td>
-                </tr>
-                <tr>
-                    <td valign="top" class="form-title">
-                        Description: 
-                    </td>
-                    <td valign="top" >
-                        <textarea id="description" name="description"
-                                       cols="37" rows="8" value="123"></textarea>
-                    </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>
-</span>
-
-
-
+</div>

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/view.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/view.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/view.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -65,8 +65,7 @@
 				<div id="main">
 					<div tal:content="structure view/renderBody" />
 				</div>
-				<div id="wiki_popup_menu"></div>
-				<div id="modification_stamp" tal:content="view/getModificationStamp"></div>
+				<div id="wiki_link_form"></div>
 			</div>
 
 			<div class="col second">

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -0,0 +1,59 @@
+<div class="inline_form" tal:attributes="id string:create_folder${view/index}">
+    <form method="post"
+           enctype="multipart/form-data"
+           onsubmit="WikiMenu.submitForm(this); return false;"
+           onreset="WikiMenu.hideForm()" >
+  
+        <div class="inline-title">Create Folder 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="folder" />
+        <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="form-title">
+                    Folder Name:
+                </td>
+                <td valign="top" >
+                    <input id="folder_name" name="name" type="text" size="40" value="FolderName" tal:attributes="value python: view.upload_name or view.unicodeLabel()" />
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Title:
+                </td>
+                <td valign="top" >
+                    <input id="file_title" name="title" type="text" size="40" value=""/>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Description: 
+                </td>
+                <td valign="top" >
+                    <textarea id="description" name="description"
+                                   cols="37" rows="8" value="123"></textarea>
+                </td>
+            </tr>
+            <tr tal:condition="not: view/isUnique"> 
+                <td valign="top" class="form-title">
+                    Scope: 
+                </td>
+                <td valign="top" class="form-title">
+                    <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

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -0,0 +1,59 @@
+<div class="inline_form" tal:attributes="id string:add_page_form${view/index}">
+    <form method="post"
+           enctype="multipart/form-data"
+           onsubmit="WikiMenu.submitForm(this); return false;"
+           onreset="WikiMenu.hideForm();">
+        <div class="inline-title">Add Page 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="newpage" />
+        <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="form-title">
+                    Page Name:
+                </td>
+                <td valign="top" >
+                    <input id="page_name" name="name" type="text" size="40" value="FileName"  tal:attributes="value python: view.unicodeLabel()" />
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Title:
+                </td>
+                <td valign="top" >
+                    <input id="page_title" name="title" type="text" size="40" value=""/>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Abstract: 
+                </td>
+                <td valign="top" >
+                    <textarea id="description" name="description"
+                                   cols="37" rows="8" value="123"></textarea>
+                </td>
+            </tr>
+
+            <tr tal:condition="not: view/isUnique"> 
+                <td valign="top" class="form-title">
+                    Scope: 
+                </td>
+                <td valign="top" class="form-title">
+                    <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>

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -0,0 +1,12 @@
+<div>
+    <form class="inline_form" onsubmit="window.reload(); return false;">
+        <span class="anylinkheader">The page has been edited. Please reloaad.
+        </span>
+        <input name="reference" type="hidden" value="001" 
+                tal:attributes="name string:${view/processor/referenceKey};
+                                value string:${view/processor/reference}" />
+        <input name="reload" id="reload" 
+            type="submit"
+            value="Reload Page">
+    </form>
+</div>
\ No newline at end of file

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -0,0 +1,40 @@
+<div class="inline_form" tal:attributes="id string:create_folder${view/index}">
+    <form method="post" enctype="multipart/form-data" action="renameLink"
+        onsubmit="WikiMenu.submitForm(this); return false;"
+        onreset="WikiMenu.hideForm()" >
+        
+        <div class="inline-title">Rename 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="rename" />
+        <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="form-title">
+                    New Label:
+                </td>
+                <td valign="top" >
+                    <input id="link_label" name="label" type="text" size="40" value="Label" tal:attributes="value python: view.unicodeLabel()" />
+                </td>
+            </tr>
+            <tr tal:condition="not: view/isUnique"> 
+                <td valign="top" class="form-title">
+                    Scope: 
+                </td>
+                <td valign="top" class="form-title">
+                    <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

Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-04-21 17:27:03 UTC (rev 67235)
@@ -0,0 +1,65 @@
+<div class="inline_form" tal:attributes="id string:upload_form${view/index}">
+    <form method="post"
+           enctype="multipart/form-data"
+           action="uploadFile"
+           onreset="WikiMenu.hideForm();">
+        <div class="inline-title">Upload File 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="form-title">
+                    File Name:
+                </td>
+                <td valign="top" >
+                    <input id="folder_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Title:
+                </td>
+                <td valign="top" >
+                    <input id="file_title" name="title" type="text" size="40" value=""/>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    Description: 
+                </td>
+                <td valign="top" >
+                    <textarea id="description" name="description"
+                                   cols="37" rows="8" value="123"></textarea>
+                </td>
+            </tr>
+            <tr>
+                <td valign="top" class="form-title">
+                    File: 
+                </td>
+                <td>
+                    <input id="data" name="data" size="20" type="file" />
+                </td>
+            </tr>
+            <tr tal:condition="not: view/isUnique"> 
+                <td valign="top" class="form-title">
+                    Scope: 
+                </td>
+                <td valign="top" class="form-title">
+                    <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/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-04-21 17:27:03 UTC (rev 67235)
@@ -111,8 +111,21 @@
             label = label[:-1]
         return label
         
+    def isUnique(self) :
+        """ Returns true if this is the label is unique within a page.
+            Must be called after all placeholders have been generated.
+            
+        """
+        
+        for placeholder in self.processor.placeholders.values() :
+            if placeholder != self :
+                if placeholder.editableLabel() == self.editableLabel() :
+                    return False
+        return True
+        
     def unicodeLabel(self) :
         return unicode(self.editableLabel(), encoding='utf-8')
+        
  
  
 class BaseLinkProcessor(BaseHTMLProcessor) :
@@ -286,6 +299,12 @@
         self.placeholders = {}
         self.placeholder = None     # current placeholder
         
+    def reference(self) :
+        return self.page.getURL()
+        
+    def referenceKey(self) :
+        return "url"
+        
     def createLinkId(self, index) :
         return "wiki-link%s" % index
         
@@ -482,10 +501,10 @@
         for placeholder commands with global scope.
         
         """
-        
         html = BaseHTMLProcessor.output(self)
         for placeholder in self.placeholders.values() :
             html = placeholder.postProcessing(html)
+                       
         return html
         
         
@@ -510,20 +529,18 @@
     """
     
     _menu = ViewPageTemplateFile("./templates/linkmenu.pt")
-    _link = '<a class="wiki-link" href="%s" onmouseover="%s" onmouseout="%s" %s>'
+    _link = '<a class="wiki-link" href="%s" onmouseover="%s" %s>'
     _dimmed = '<span class="dimmed-wiki-link">'
     
     wikified = False
-    outdated = False
     enabled = True
     
     def __init__(self, processor, index, label, link) :
         super(MenuPlaceholder, self).__init__(processor, index, label, link)
         self.enabled = processor.page.isEditable()
         self.menu_id = processor.createMenuId(index)
-        self.onMouseOver = "PopupMenu.update(this, '%s');" % self.menu_id
-        self.onMouseOut = "PopupMenu.leave(this, '%s');" % self.menu_id
-       
+        self.onMouseOver = "WikiMenu.dropDown(this, event, '%s');" % self.menu_id       
+
     def startTag(self, attrs) :
         """ Called when a starttag for a placeholder is detected. """
         
@@ -533,8 +550,8 @@
             self.wikified = True
             attrs.append(("id", self.link_id))
             if self.enabled :
-                return self._link % (link, self.onMouseOver, self.onMouseOut,
-                                                        self._tagAttrs(attrs))
+                return self._link % (link, self.onMouseOver, 
+                                                    self._tagAttrs(attrs))
             else :
                 return self._dimmed
         else :
@@ -554,12 +571,24 @@
             
     def afterCloseTag(self) :
         if self.wikified :
-            return '<span id="outer%s"></span>' % self.menu_id
             menu = self._menu()
             return menu.encode("utf-8")
         return None
-                
 
+
+class NoopPlaceholder(Placeholder) :
+    """ An unmodified placeholder. """
+    
+    def textLink(self) :
+        return "[%s]" % self.label
+     
+    def startTag(self, attrs) :
+        if self.link.endswith(self.page.action) :
+            link = self.link[:-len(self.page.action)]
+        else :
+            link = self.link
+        return '<a href="%s">' % (link)
+
 class SavingPlaceholder(Placeholder) :
     """ A placeholder that saves the result to disk. 
     
@@ -569,40 +598,63 @@
     """
     
     global_scope = False        # default: depends on usecase
+    render_form = False
     
+    def textLink(self) :
+        if self.render_form :
+            return super(SavingPlaceholder, self).textLink()
+        return self.performSubstitution()
+
     def startTag(self, attrs) :
         """ Called when a starttag for a placeholder is detected. """
+        if self.render_form :
+            return super(SavingPlaceholder, self).startTag(attrs)
+            
         pattern = '<a href="%s"%s>'
-        print "Saving", attrs
         return pattern % (self.link, self._tagAttrs(attrs))
 
-
 class RenamedPlaceholder(SavingPlaceholder) :
     """ A placeholder with a changed label. """
     
-    fired = False
-            
-    def textLink(self) :
+    _form = ViewPageTemplateFile("./templates/wiki_rename.pt")
+    title = u"Rename"
+    new_link = ''
+    
+    def _newLabel(self) :
+        label = self.page.parameter("label")
+        if label :
+            return label.encode("utf-8")
+        return self.label
+    
+    def performSubstitution(self) :
         """ Replaces the label in text mode. """
         
-        label = self.page.parameter("label").encode("utf-8")
-        self.fired = True
-        return '[' + label + ']'
+        scope = self.page.parameter('scope')
+        self.global_scope = scope and scope.lower() == 'on'
         
+        label = self._newLabel()
+        self.new_link = '[' + label + ']'
+        return self.new_link
+        
     def afterCloseTag(self) :
         """ Replaces the label after the tag has been closed. """
         
-        if self.nested == 0 and not self.fired :
-            label = self.page.parameter("label").encode("utf-8")
-            self.processor.pieces[-2] = label
+        if self.nested == 0 and not self.new_link :
+            self.processor.pieces[-2] =  self._newLabel()
+ 
+    def postProcessing(self, html) :
+        """ Replaces a textual WikiLink globally. """
+        if self.global_scope and self.new_link :
+            html = html.replace("[%s]" % self.label, self.new_link)
+        return html
+
         
-        
 class AddObjectPlaceholder(SavingPlaceholder) :
     """ A convenient base class for placeholders that add objects. """
     
     new_link = None
     
-    def addObject(self) :
+    def apply(self) :
         """ Main method that adds the object and returns the new url.
             Must be specialized.
         """
@@ -658,8 +710,8 @@
         
         return name.encode("utf-8")
         
-    def textLink(self) :
-        name = self.addObject()
+    def performSubstitution(self) :
+        name = self.apply()
         self.new_link = '<a href="%s">%s</a>' % (name, self.editableLabel())
         return self.new_link
         
@@ -678,7 +730,10 @@
 class UploadFilePlaceholder(AddObjectPlaceholder) :
     """ A placeholder that points to an uploaded file. """
     
-    def addObject(self) :
+    title = u"Upload File"
+    _form = ViewPageTemplateFile("./templates/wiki_upload.pt")
+    
+    def apply(self) :
         """ Upload a file. Returns the name of the new file.
         """
         
@@ -698,7 +753,10 @@
 class CreateFolderPlaceholder(AddObjectPlaceholder) :
     """ A placeholder that points to a new folder. """
     
-    def addObject(self) :
+    title = u"Create Folder"
+    _form = ViewPageTemplateFile("./templates/wiki_folder.pt")
+    
+    def apply(self) :
         """ Creates a new folder. Returns the name of the folder.
         """
         
@@ -713,30 +771,21 @@
         changes the reference of the clicked link. Thus you can have
         several links with the same name and different URLs.
     """
+    
+    title = u"Add Page"
+    
+    _form = ViewPageTemplateFile("./templates/wiki_newpage.pt")
                 
-    def addObject(self) :
+    def apply(self) :
         """ Create a page. Returns the name of the new page.
         """
         
         label = self.editableLabel()
         contenttype = "text/html"
-        name = self.page.parameter('name')
+        name = self.page.parameter('name') or unicode(label, encoding="utf-8")
         return self._addObject(name, File(u'New Page', contenttype))
+        
 
-
-class NoopPlaceholder(Placeholder) :
-    """ An unmodified placeholder. """
-    
-    def textLink(self) :
-        return "[%s]" % self.label
-     
-    def startTag(self, attrs) :
-        if self.link.endswith(self.page.action) :
-            link = self.link[:-len(self.page.action)]
-        else :
-            link = self.link
-        return '<a href="%s">' % (link)
-
 class AjaxLinkProcessor(WikiLinkProcessor) :
     """ A link processor that wikifies the links by modifying the
         href of a link and additionally inserting a javascript based menu
@@ -750,8 +799,16 @@
 
     command = None      # the name of the link modification command
     link_id = None
+    render_form = False
     
     
+    def getItemInfos(self) :
+        result = []
+        for cmd in 'rename', 'newpage', 'folder', 'upload' :
+            command = self.cmds[cmd]
+            result.append(dict(key=cmd, title=command.title))
+        return result
+    
     def createPlaceholder(self, label, link, factory=MenuPlaceholder) :
         """
         Creates a placeholder page element and stores it for later
@@ -769,6 +826,8 @@
                 placeholder = NoopPlaceholder(self, index, label, link)
         else :
             placeholder = factory(self, index, label, link)
+        
+        placeholder.render_form = self.render_form
         self.placeholders[placeholder.link_id] = placeholder
         self.placeholder = placeholder
         return placeholder            

Modified: zope3org/trunk/src/zorg/wikification/browser/wikipage.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-04-21 17:26:12 UTC (rev 67234)
+++ zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-04-21 17:27:03 UTC (rev 67235)
@@ -67,6 +67,8 @@
     """
     
     implements(IWikiPage)
+    
+    _outdated = ViewPageTemplateFile("./templates/wiki_outdated.pt")  
 
     supported = 'text/html', 'application/xhtml+xml', 'application/xml', 'text/xml'
     title = u"Wiki page"
@@ -77,7 +79,7 @@
             'login': '#',
             }
     untitled = u"Untitled"
-
+    processor = None
    
     def __init__(self, context, request, container=None) :
         """ Initializes some usefull instance variables. 
@@ -112,6 +114,10 @@
         """ Returns the base container. Should be overwritten. """
         return None
         
+    def getFile(self) :
+        """ Returns the wikified file. Should be overwritten. """
+        return None
+    
     def getAbstract(self) :
         """ Returns the abstract resp. description. """
         file = self.getFile()
@@ -125,7 +131,6 @@
         except ForbiddenAttribute :
             return False
         
-        
     def renderAbstract(self) :
         """ Render the abstract as ReST. """
         desc = self.getAbstract()
@@ -139,7 +144,7 @@
         """
         file = self.getFile()
         dc = IZopeDublinCore(file, None)
-        if dc is not None :
+        if dc is not None and dc.modified is not None :
             return str(dc.modified)
         return None
         
@@ -168,15 +173,24 @@
         
         processor = ILinkProcessor(self)
         processor.feed(body)
-        return processor.output()
-     
-    def popupLinkMenu(self, menu_id, modification_stamp, current_stamp=None) :
-        """ Render the popup link menu. """
+        html = processor.output()
         
-        modification_stamp = str(modification_stamp)        
-        link_id = menu_id.replace("menu", "link")
-        processor = ILinkProcessor(self)
+        modified = self.getModificationStamp()
+        if modified :
+            pat = '<div id="modification_stamp" style="display:none;">%s</div>'
+            html += pat % modified
+            
+        return html
+             
+    def wikiCommandForm(self, cmd, id, modification_stamp, current_stamp=None) :
+        """ Render the link command form. """
+        
+        processor = self.processor = ILinkProcessor(self)
+        link_id = processor.createLinkId(id)
+        menu_id = processor.createMenuId(id)
+        processor.render_form = True
         processor.link_id = link_id
+        processor.command = cmd
         body = self.getBody()
         processor.feed(body)
         placeholder = processor.placeholders.get(link_id)
@@ -185,12 +199,20 @@
             current_stamp = self.getModificationStamp()
         if placeholder is None :
             return self.message('Invalid link &quot;%s&quot;' % menu_id)
-        placeholder.outdated = modification_stamp != current_stamp
-        return placeholder._menu()
+        
+        if modification_stamp != current_stamp :
+            return self._outdated()
+        
+        form = placeholder._form()
+       #  print "Form:"
+#         print form
+        return form
+        
+    def getURL(self) :
+        return zapi.absoluteURL(self.context, self.request)
       
     def nextURL(self) :
-        url = zapi.absoluteURL(self.context, self.request)
-        return url + self.action
+        return self.getURL() + self.action
 
         
 class WikiContainerPage(WikiPage) :
@@ -567,7 +589,10 @@
         body = self.getBody()
         processor.feed(body)
         file = self.getFile()
-        file.data = processor.output()
+        newbody = processor.output()
+        if newbody != file.data :
+            file.data = newbody
+            zope.event.notify(ObjectModifiedEvent(file))
         
     def uploadFile(self, link_id) :
         """ Uploads a file for a wikified link and redirects 



More information about the Checkins mailing list