def GET(self): fpath = xutils.get_argument("path") basename, ext = os.path.splitext(fpath) encoded_fpath = xutils.encode_uri_component(fpath) if ext == ".txt": raise web.found("/fs_text?path=%s" % encoded_fpath) if ext in (".html", ".htm"): raise web.found("/fs/%s" % encoded_fpath) if ext in (".md", ".csv"): raise web.found("/code/preview?path=%s" % encoded_fpath) if ext in (".key", ".numbers"): os.system("open %r" % fpath) parent_fpath = os.path.abspath(os.path.dirname(fpath)) encoded_parent = xutils.encode_uri_component(parent_fpath) raise web.found("/fs/%s" % encoded_parent) if ext == ".db": raise web.found("/tools/sql?path=%s" % encoded_fpath) if xutils.is_text_file(fpath): raise web.found("/code/edit?path=%s" % encoded_fpath) raise web.found("/fs/%s" % encoded_fpath)
def GET(self): fpath = xutils.get_argument("path") basename, ext = os.path.splitext(fpath) encoded_fpath = xutils.encode_uri_component(fpath) if xutils.is_text_file(fpath): raise web.found("/code/edit?path=%s" % encoded_fpath) raise web.found("/fs_hex?path=%s" % encoded_fpath)
def GET(self): # TODO 使用文件扩展 path = xutils.get_argument("path") path = xutils.get_real_path(path) if xutils.is_img_file(path): return """<html><img style="width: 100%%;" src="/fs/%s"></html>""" % path if xutils.is_text_file(path): raise web.seeother("/code/edit?path=%s&embed=true" % xutils.quote_unicode(path)) raise web.seeother("/fs_plugins?path=%s&embed=true" % xutils.quote_unicode(path))
def GET(self): fpath = xutils.get_argument("path") basename, ext = os.path.splitext(fpath) encoded_fpath = xutils.encode_uri_component(fpath) if ext == ".txt": raise web.found("/fs_text?path=%s" % encoded_fpath) if ext in (".html", ".htm"): raise web.found("/fs/%s" % encoded_fpath) if ext in (".md", ".csv"): raise web.found("/code/preview?path=%s" % encoded_fpath) if xutils.is_text_file(fpath): raise web.found("/code/edit?path=%s" % encoded_fpath) raise web.found("/fs/%s" % encoded_fpath)
def assemble_file_object(item): item.encoded_path = xutils.encode_uri_component(item.path) item.icon = "fa-file-o" if item.type == "dir": item.icon = "fa-folder orange" elif item.ext in xconfig.FS_VIDEO_EXT_LIST: item.icon = "fa-file-video-o" elif item.ext in xconfig.FS_CODE_EXT_LIST: item.icon = "fa-file-code-o" elif item.ext in xconfig.FS_AUDIO_EXT_LIST: item.icon = "fa-file-audio-o" elif item.ext in xconfig.FS_ZIP_EXT_LIST: item.icon = "fa-file-zip-o" elif xutils.is_text_file(item.path): item.icon = "fa-file-text-o" elif xutils.is_img_file(item.path): item.icon = "fa-file-image-o" return item
def process_file_list(pathlist, parent=None): filelist = [FileItem(fpath, parent, merge=True) for fpath in pathlist] for item in filelist: item.encoded_path = xutils.encode_uri_component(item.path) item.icon = "fa-file-o" if item.type == "dir": item.icon = "fa-folder orange" elif item.ext in xconfig.FS_VIDEO_EXT_LIST: item.icon = "fa-file-video-o" elif item.ext in xconfig.FS_CODE_EXT_LIST: item.icon = "fa-file-code-o" elif item.ext in xconfig.FS_AUDIO_EXT_LIST: item.icon = "fa-file-audio-o" elif item.ext in xconfig.FS_ZIP_EXT_LIST: item.icon = "fa-file-zip-o" elif xutils.is_text_file(item.path): item.icon = "fa-file-text-o" elif xutils.is_img_file(item.path): item.icon = "fa-file-image-o" filelist.sort() return filelist