summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/filebrowser/templates/standard_template.pt6
-rw-r--r--examples/filebrowser/web/jump.py28
2 files changed, 33 insertions, 1 deletions
diff --git a/examples/filebrowser/templates/standard_template.pt b/examples/filebrowser/templates/standard_template.pt
index 9cf589a..31e7359 100644
--- a/examples/filebrowser/templates/standard_template.pt
+++ b/examples/filebrowser/templates/standard_template.pt
@@ -23,7 +23,11 @@
<legend>clipboard <a onclick="toggle('copybin', {link: this})"
tal:attributes="hiddenhtml
servlet/icons/1uparrow.png/alt=show/title=show+clipboard/html"
- tal:content="structure servlet/icons/1downarrow.png/alt=hide/title=hide+clipboard/html"/></legend>
+ tal:content="structure servlet/icons/1downarrow.png/alt=hide/title=hide+clipboard/html"/>
+ <a onclick="jump(this)"
+ tal:attributes="jumpurl servlet/globalurl/jump"
+ tal:content="structure servlet/icons/goto.png/alt=goto/title=jump+to+file/html"/>
+</legend>
<div id="copybin">
<metal:tpl use-macro="here/copybin.pt/macros/copybin">
</metal:tpl>
diff --git a/examples/filebrowser/web/jump.py b/examples/filebrowser/web/jump.py
new file mode 100644
index 0000000..72f7b39
--- /dev/null
+++ b/examples/filebrowser/web/jump.py
@@ -0,0 +1,28 @@
+from filebrowser.sitepage import *
+
+class jump(SitePage):
+
+ def setup(self):
+ name = self.fields.name.strip()
+ action = 'view'
+ if name.startswith('edit:'):
+ action = 'edit'
+ name = name[5:].strip()
+ root = self.pathcontext.path('/')
+ if name == 'root':
+ possible = [root]
+ else:
+ possible = root.find_filename(name)
+ if not possible:
+ self.message.write('No files with %r found' % name)
+ self.redirect(self.environ['HTTP_REFERER'])
+ dest = possible[0]
+ if possible[1:]:
+ self.message.write('Other matches:')
+ for path in possible[1:]:
+ self.message.write(
+ '<a href="%s">%s</a>'
+ % (self.pathurl(path.path, action=action), path.path))
+ self.redirect(self.pathurl(dest.path, action=action))
+
+ \ No newline at end of file