From: W. Trevor King Date: Sun, 18 Jul 2010 17:23:00 +0000 (-0400) Subject: Set iframe src attribute to selected file, and serve those files through static/ X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b4ade1769208245ef6f7838f8ac2110bd2d5170;p=dirtag.git Set iframe src attribute to selected file, and serve those files through static/ --- diff --git a/dirtag/web.py b/dirtag/web.py index 0d33ebf..4c4cd43 100755 --- a/dirtag/web.py +++ b/dirtag/web.py @@ -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) diff --git a/static/dirtag.js b/static/dirtag.js index a51198d..336c928 100644 --- a/static/dirtag.js +++ b/static/dirtag.js @@ -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() {