Ejemplo n.º 1
0
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return
    name = ctx.key
    results = []
    words = textutil.split_words(name)
    for name in xconfig.PLUGINS_DICT:
        plugin = xconfig.PLUGINS_DICT[name]
        unquote_name = xutils.unquote(plugin.fname)
        unquote_name, ext = os.path.splitext(unquote_name)
        plugin_context = plugin
        if textutil.contains_all(unquote_name, words) \
                or (textutil.contains_all(plugin_context.title, words)):
            result = SearchResult()
            result.category = "plugin"
            result.icon = "fa-cube"
            result.name = u(unquote_name)
            if plugin_context != None:
                # result.raw = u(plugin_context.title)
                # result.name = u("插件 %s (%s)") % (u(plugin_context.title), unquote_name)
                if plugin_context.title != None:
                    result.name = u(plugin_context.title + "(" + unquote_name +
                                    ")")
            result.url = u(plugin.url)
            result.edit_link = u("/code/edit?path=" + plugin.fpath)
            results.append(result)
    ctx.tools += results
Ejemplo n.º 2
0
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return
    name = ctx.key
    results = []
    dirname = xconfig.PLUGINS_DIR
    words = textutil.split_words(name)
    for fname in xutils.listdir(dirname):
        unquote_name = xutils.unquote(fname)
        unquote_name, ext = os.path.splitext(unquote_name)
        plugin_context = xconfig.PLUGINS.get(fname)
        if textutil.contains_all(unquote_name, words) \
                or (plugin_context != None and textutil.contains_all(plugin_context.title, words)):
            result = SearchResult()
            result.category = "plugin"
            result.name = u("[插件] " + unquote_name)
            if plugin_context != None:
                # result.raw = u(plugin_context.title)
                # result.name = u("插件 %s (%s)") % (u(plugin_context.title), unquote_name)
                if plugin_context.title != None:
                    result.name = u("[插件] " + plugin_context.title + "(" +
                                    unquote_name + ")")
            result.url = u("/plugins/" + unquote_name)
            result.edit_link = u("/code/edit?path=" +
                                 os.path.join(dirname, fname))
            results.append(result)
    ctx.tools += results
Ejemplo n.º 3
0
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return

    results = []

    for plugin in search_plugins(ctx.key):
        result = SearchResult()
        result.category = "plugin"
        result.icon = "fa-cube"
        result.name = u(plugin.name)
        result.name = u(plugin.title + "(" + plugin.name + ")")
        result.url = u(plugin.url)
        result.edit_link = plugin.edit_link
        results.append(result)

    result_count = len(results)
    if ctx.category != "plugin" and len(results) > 3:
        results = results[:3]
        more = SearchResult()
        more.name = u("查看更多插件(%s)") % result_count
        more.icon = "fa-cube"
        more.url = "/plugins_list?category=plugin&key=" + ctx.key
        results.append(more)
    ctx.tools += results
Ejemplo n.º 4
0
def search_plugins(name):
    results = []
    dirname = xconfig.PLUGINS_DIR
    for fname in xutils.listdir(dirname):
        if name in fname:
            result = SearchResult()
            result.category = "plugin"
            result.name = u("插件 - " + fname)
            result.url = u("/plugins/" + fname)
            result.edit_link = u("/code/edit?path=" +
                                 os.path.join(dirname, fname))
            results.append(result)
    return results
Ejemplo n.º 5
0
def search_plugins(name):
    results = []
    dirname = xconfig.PLUGINS_DIR
    words = textutil.split_words(name)
    for fname in xutils.listdir(dirname):
        unquote_name = xutils.unquote(fname)
        if textutil.contains_all(unquote_name, words):
            result = SearchResult()
            result.category = "plugin"
            result.name = u("插件 - " + unquote_name)
            result.url = u("/plugins/" + fname)
            result.edit_link = u("/code/edit?path=" +
                                 os.path.join(dirname, fname))
            results.append(result)
    return results