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

Unified Diff: sky/tools/sky_server

Issue 688413005: Convert the directory listing to run on top of the platform (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« sky/examples/file-browser.sky ('K') | « sky/framework/xmlhttprequest.sky ('k') | no next file » | 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 0fe0fe91ffd38c7589f56b9b725e90eac950485b..da42f1acf3f82da6c8223d8ae3b911e3756417b9 100755
--- a/sky/tools/sky_server
+++ b/sky/tools/sky_server
@@ -4,8 +4,9 @@
# found in the LICENSE file.
import argparse
-import os
import cherrypy
+import json
+import os
import staticdirindex
@@ -17,28 +18,22 @@ 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>'
+ if cherrypy.request.params.get('format') is None:
+ return '<sky><import src="/sky/examples/file-browser.sky"/><file-browser/></sky>'
+ result = dict()
+ result['directories'] = []
+ result['files'] = []
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)
+ result["directories"].append(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>"
-
+ result["files"].append(file_name)
+ return json.dumps(result)
-# 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
def main():
parser = argparse.ArgumentParser(description='Sky development server')
« sky/examples/file-browser.sky ('K') | « sky/framework/xmlhttprequest.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698