Index: sky/tools/sky_server |
diff --git a/sky/tools/sky_server b/sky/tools/sky_server |
index 5308b2de9ee4d81e26ee5f1c7a0b8f26da024342..bd40138855effbc00a1b9b2a17965075cc6803fb 100755 |
--- a/sky/tools/sky_server |
+++ b/sky/tools/sky_server |
@@ -6,6 +6,7 @@ |
import argparse |
import os |
import cherrypy |
+import staticdirindex |
BUILD_DIRECTORY = 'out' |
@@ -16,6 +17,25 @@ SKY_ROOT = os.path.join(SRC_ROOT, 'sky') |
GEN_ROOT = os.path.join(SRC_ROOT, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'gen') |
+# FIXME: This should be replaced by just json and inflated into DOM client-side. |
+def skydir(section="", dir="", path="", **kwargs): |
+ url = "%s%s" % (cherrypy.request.headers.get('Host', ''), |
+ cherrypy.request.path_info) |
+ sky = "<listing>" |
+ sky += "<style>a { display: block; }" |
+ sky += "header { border-bottom: 1px solid lightgrey }</style>" |
+ sky += '<header>Listing for: <a href="' + url + '">' + url +'</a></header>' |
+ for _, dir_names, file_names in os.walk(path.rstrip(r"\/")): |
+ for dir_name in sorted(dir_names): |
+ sky += "<a href=\"%s/\">%s/</a>\n" % (dir_name, dir_name) |
+ |
+ del dir_names[:] # limit to one level |
+ |
+ for file_name in sorted(file_names): |
+ sky += "<a href=\"%s\">%s</a>\n" % (file_name, file_name) |
+ return sky + "</listing>" |
abarth-chromium
2014/10/31 02:21:37
So much the XSS
|
+ |
+ |
# FIXME: This doesn't yet support directory listings. We'll do something like: |
# http://tools.cherrypy.org/wiki/staticdirindex |
# but have it spit .sky instead of HTML |
@@ -43,6 +63,7 @@ def main(): |
'/': { |
'tools.staticdir.on': True, |
'tools.staticdir.dir': os.path.abspath(args.app_path), |
+ 'tools.staticdir.indexlister': skydir, |
}, |
'/mojo': { |
'tools.staticdir.on': True, |