diff --git a/PluginDirectories/1/zhihu-search.bundle/Icon.png b/PluginDirectories/1/zhihu-search.bundle/Icon.png new file mode 100644 index 00000000..635a2900 Binary files /dev/null and b/PluginDirectories/1/zhihu-search.bundle/Icon.png differ diff --git a/PluginDirectories/1/zhihu-search.bundle/Screenshot.png b/PluginDirectories/1/zhihu-search.bundle/Screenshot.png new file mode 100644 index 00000000..630c58e3 Binary files /dev/null and b/PluginDirectories/1/zhihu-search.bundle/Screenshot.png differ diff --git a/PluginDirectories/1/zhihu-search.bundle/examples.txt b/PluginDirectories/1/zhihu-search.bundle/examples.txt new file mode 100644 index 00000000..3fe5db5c --- /dev/null +++ b/PluginDirectories/1/zhihu-search.bundle/examples.txt @@ -0,0 +1 @@ +zh ~zhihuquery(a) diff --git a/PluginDirectories/1/zhihu-search.bundle/info.json b/PluginDirectories/1/zhihu-search.bundle/info.json new file mode 100644 index 00000000..2a9e52da --- /dev/null +++ b/PluginDirectories/1/zhihu-search.bundle/info.json @@ -0,0 +1,12 @@ +{ + "categories" : [ + "Utilities" + ], + "displayName" : "Zhihu Search", + "name" : "zhihu-search", + "description" : "This is an zhihu search plugin", + "examples" : [ + "zh 如何评价", + "zh good morning" + ] +} \ No newline at end of file diff --git a/PluginDirectories/1/zhihu-search.bundle/plugin.py b/PluginDirectories/1/zhihu-search.bundle/plugin.py new file mode 100644 index 00000000..ce60dcb6 --- /dev/null +++ b/PluginDirectories/1/zhihu-search.bundle/plugin.py @@ -0,0 +1,34 @@ +import urllib +import json +import i18n + + +def results(parsed, original_query): + + search_specs = [ + ["Zhihu", "~zhihuquery", "https://www.zhihu.com/search?type=content&q="] + ] + for name, key, url in search_specs: + if key in parsed: + localizedurl = i18n.localstr(url) + search_url = localizedurl + urllib.quote_plus(parsed[key].encode('UTF-8')) + title = i18n.localstr( + "Search {0} for '{1}'").format(name, parsed[key].encode('UTF-8')) + return { + "title": title, + "run_args": [search_url], + "html": """ + + """ % (json.dumps(search_url)), + "webview_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53", + "webview_links_open_in_browser": True + } + + +def run(url): + import os + os.system('open "{0}"'.format(url))