Use 'raw' and 'tag' for the dir roots, to avoid exposing the underlying path.
authorW. Trevor King <wking@drexel.edu>
Tue, 20 Jul 2010 16:56:04 +0000 (12:56 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 20 Jul 2010 16:56:04 +0000 (12:56 -0400)
For example:
  root=/home/user/path/to/pics
may be a bit personal.

Also use raw paths in previews since they are the only ones available
under static/.

dirtag/web.py

index 59063ec5ca39b21a32ab4f791f27eb8e0c045844..abbbcfde4f1248a055a1042a005f4041be803bac 100755 (executable)
@@ -78,9 +78,12 @@ class WebInterface:
                 % (' '*(4*len(node)-2), self._dir_html_link(node, data)))
 
     def _dir_html_link(self, node, data):
+        root = 'raw'
+        if node.root == self.dirtag.tag_dir:
+            root = 'tag'
         return ('<a href="%s">%s</a>'
                 % ('dir?%s' % urlencode({
-                        'root':node.root,
+                        'root':root,
                         'selected':'/'.join(node),
                         }),
                    '/'.join(node)))
@@ -114,7 +117,7 @@ class WebInterface:
         style = 'style="height=200px; width=200px;"'
         type,encoding = guess_type(node[-1])
         return ('<iframe %s src="static/raw/%s"></iframe>'
-                % (style, '/'.join(node)))
+                % (style, '/'.join(self.dirtag.raw_node(node))))
         #elif node[-1].endswith('.jpg'):
         #    return ('<img %s " src="static/raw/%.s"/>'
         #            % (style, '/'.join(node)))
@@ -135,10 +138,10 @@ class WebInterface:
             )
 
     def _selected_dir(self, root, selected):
-        if root == self.dirtag.raw_dir:
+        if root == 'raw':
             tree = dir_tree(self.dirtag.raw_dir)
         else:
-            assert root == self.dirtag.tag_dir, root
+            assert root == 'tag', root
             tree = dir_tree(self.dirtag.tag_dir)
         s = None
         for node in tree.traverse(depth=1, type='dirs'):