示例#1
0
文件: preview.py 项目: ydx2099/xnote
def check_resource(path):
    if xutils.is_img_file(path):
        pathlist = path.split("/")
        pathlist = map(lambda name: xutils.quote(name), pathlist)
        uri = "/fs//" + "/".join(pathlist)
        # print(uri)
        raise web.seeother(uri)
    return False
示例#2
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))
示例#3
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
示例#4
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
示例#5
0
def get_link(filename, webpath):
    if xutils.is_img_file(filename):
        return "![%s](%s)" % (filename, webpath)
    return "[%s](%s)" % (filename, webpath)