예제 #1
0
파일: fs.py 프로젝트: ydx2099/xnote
    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)
예제 #2
0
파일: fs.py 프로젝트: ydx2099/xnote
    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)
예제 #3
0
 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))
예제 #4
0
파일: fs.py 프로젝트: 552301/xnote
    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)
예제 #5
0
파일: fs.py 프로젝트: ydx2099/xnote
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
예제 #6
0
파일: fs.py 프로젝트: gavinchan2046/xnote
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