Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: sky/tools/sky_server

Issue 690133002: Add support for directory listings in sky_server. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/tools/staticdirindex.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | sky/tools/staticdirindex.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698