[Checkins] SVN: zope3org/trunk/src/zorg/wikification/browser/ Added
a new edit form for wiki links
Uwe Oestermeier
uwe_oestermeier at iwm-kmrc.de
Fri Jan 19 11:33:55 EST 2007
Log message for revision 72105:
Added a new edit form for wiki links
Changed:
U zope3org/trunk/src/zorg/wikification/browser/style/main.css
A zope3org/trunk/src/zorg/wikification/browser/templates/wiki_setlink.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/style/main.css
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/style/main.css 2007-01-19 14:37:39 UTC (rev 72104)
+++ zope3org/trunk/src/zorg/wikification/browser/style/main.css 2007-01-19 16:33:54 UTC (rev 72105)
@@ -42,7 +42,11 @@
width: 300px;
}
-
+.wiki-input-item
+{
+ width: 600px;
+}
+
#wiki_link_form {
position:absolute;
z-index: 100;
Added: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_setlink.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_setlink.pt 2007-01-19 14:37:39 UTC (rev 72104)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_setlink.pt 2007-01-19 16:33:54 UTC (rev 72105)
@@ -0,0 +1,62 @@
+<div class="wiki-form" tal:attributes="id string:set_link${view/index}">
+ <form method="post" enctype="multipart/form-data" action="externalLink"
+ onsubmit="WikiMenu.submitForm(this); return false;"
+ onreset="WikiMenu.hideForm()" >
+
+ <div class="wiki-form-title">Set Link "<span tal:replace="view/unicodeLabel">Name</span>"</div>
+ <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
+ <input name="cmd" type="hidden" value="setlink" />
+ <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">
+ New URL:
+ </td>
+ <td valign="top">
+ <input class="wiki-input" id="link_url" name="url" type="text" size="40"/>
+ </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 "<span tal:replace="view/unicodeLabel">Name</span>".
+ </td>
+ </tr>
+
+
+ <tr>
+ <td class="wiki-field">Link Target
+ </td>
+ <td class="wiki-field"><select id="target" class="wiki-input" name="target">
+ <option value="_self" class="wiki-field">Open in the same window.</option>
+ <option value="_blank" class="wiki-field">Open in a new window.</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="wiki-field">Link list</td>
+ <td><input type="hidden" id="href" name="href" type="text" value=""/>
+ <select tal:replace="structure view/renderContextLinks"></select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <input tal:condition="view/isUnique" type="hidden"
+ name="scope" id="scope" value="on">
+
+ </td>
+ <td>
+ <input name="entry_submit" type="submit" value="Submit">
+ <input name="cancel_submit" type="reset" value="Cancel"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
Modified: zope3org/trunk/src/zorg/wikification/browser/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py 2007-01-19 14:37:39 UTC (rev 72104)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py 2007-01-19 16:33:54 UTC (rev 72105)
@@ -688,7 +688,60 @@
html = html.replace("[%s]" % self.label, self.new_link)
return html
+
+class SetLinkPlaceholder(SavingPlaceholder) :
+ """ A placeholder with a changed URL. """
+
+ _form = ViewPageTemplateFile("./templates/wiki_setlink.pt")
+ title = u"Set Link"
+ new_link = ''
+
+ selection = u"""<select id="select_link" name="select_link" class="wiki-input"
+ onchange="this.form.href.value=this.options[this.selectedIndex].value;">
+ <option class="wiki-field" value="">---</option>"""
+
+ option = u'<option class="wiki-input-item" value="%s" title="%s">%s (%s)</option>'
+
+ def _newURL(self) :
+ url = self.page.parameter('url') or self.page.parameter('href')
+ if url :
+ return url.encode('utf-8')
+ return ''
+ def performSubstitution(self) :
+ """ Replaces the label in text mode. """
+
+ scope = self.page.parameter('scope')
+ if scope :
+ self.global_scope = scope.lower() == 'on'
+
+ url = self._newURL()
+ target = self.page.parameter('target').encode('utf-8')
+ self.new_link = '<a href="%s" target="%s">%s</a>' % (url, target, self.editableLabel())
+ return self.new_link
+
+ def renderContextLinks(self):
+ """Renders a selection of internal links."""
+ links = sorted(self.page.getInternalLinks())
+ result = [self.selection]
+ for url, title, path in links:
+ result.append(self.option % (url, url, title, path))
+ result.append(u'</select>')
+ return u''.join(result)
+
+ def afterCloseTag(self) :
+ """ Replaces the label after the tag has been closed. """
+
+ 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. """
@@ -887,7 +940,8 @@
that allows the user to choose an edit option.
"""
- cmds = dict(rename=RenamedPlaceholder,
+ cmds = dict(rename=RenamedPlaceholder,
+ setlink=SetLinkPlaceholder,
upload=UploadFilePlaceholder,
image=UploadImagePlaceholder,
folder=CreateFolderPlaceholder,
@@ -900,7 +954,7 @@
def getItemInfos(self) :
result = []
- for cmd in 'rename', 'newpage', 'folder', 'upload', 'image' :
+ for cmd in 'rename', 'setlink', '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 2007-01-19 14:37:39 UTC (rev 72104)
+++ zope3org/trunk/src/zorg/wikification/browser/wikipage.py 2007-01-19 16:33:54 UTC (rev 72105)
@@ -224,7 +224,20 @@
def nextURL(self) :
return self.getURL() + self.action
+
+ def getInternalLinks(self, container=None):
+ if container is None:
+ container = self.getContainer()
+ for value in container.values():
+ url = zapi.absoluteURL(value, self.request)
+ title = IZopeDublinCore(value).title
+ path = zapi.getPath(value)
+ yield url, title, path
+ if IContainer.providedBy(value):
+ self.getInternalLinks(value)
+
+
class WikiContainerPage(WikiPage) :
""" Wiki view for a container. """
More information about the Checkins
mailing list