Set iframe src attribute to selected file, and serve those files through static/
authorW. Trevor King <wking@drexel.edu>
Sun, 18 Jul 2010 17:23:00 +0000 (13:23 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 18 Jul 2010 17:23:00 +0000 (13:23 -0400)
dirtag/web.py
static/dirtag.js

index 0d33ebf6cc84c1613bd85f7382c3efe283b24422..4c4cd439c66a5bc7e1c9cc9ce096c16763975859 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 from optparse import OptionParser
+import os
 from os import path
 from urllib import urlencode
 
@@ -165,10 +166,17 @@ if __name__ == '__main__':
             'tools.encode.on': True,
             'tools.encode.encoding': 'utf8',
             })
+
+    static_dir = path.abspath(options.static_dir)
     app_config = {
         '/static': {
             'tools.staticdir.on': True,
-            'tools.staticdir.dir': path.abspath(options.static_dir),
+            'tools.staticdir.dir': static_dir,
             }
         }
-    cherrypy.quickstart(w, '/', app_config)
+    raw_link = path.join(static_dir, 'raw')
+    os.symlink(path.relpath(d.raw_dir, static_dir), raw_link)
+    try:
+        cherrypy.quickstart(w, '/', app_config)
+    finally:
+        os.remove(raw_link)
index a51198dabaf0b6d5bf43015ecbe7dbd2589181ab..336c928f63fa0f368ffbc552c00cd54c244f16eb 100644 (file)
@@ -126,7 +126,7 @@ function set_selected_element(path, tags, id) {
     element.file_path = path;
     element.file_tags = tags;
     element.tree_id = id;
-    // element.source = ...
+    element.setAttribute('src', '/static/raw/'+path.join('/'));
 }
 
 function raw_tree_select() {