mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add v2ex workflow
This commit is contained in:
parent
2249bbb0f5
commit
820d0cde86
9 changed files with 128 additions and 74 deletions
BIN
Plugins/winalfred.Plugin.V2ex/Images/app.ico
Normal file
BIN
Plugins/winalfred.Plugin.V2ex/Images/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
34
Plugins/winalfred.Plugin.V2ex/main.py
Normal file
34
Plugins/winalfred.Plugin.V2ex/main.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#encoding=utf8
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
import webbrowser
|
||||
|
||||
def safeSelectText(s,path):
|
||||
return s.select(path)[0].text if len(s.select(path)) > 0 else ""
|
||||
|
||||
def query(key):
|
||||
r = requests.get('http://v2ex.com/?tab=all')
|
||||
bs = BeautifulSoup(r.text)
|
||||
results = []
|
||||
for i in bs.select(".box div.item"):
|
||||
res = {}
|
||||
title = safeSelectText(i,".item_title")
|
||||
subTitle = safeSelectText(i,".fade")
|
||||
url = "http://v2ex.com" + i.select(".item_title a")[0]["href"]
|
||||
|
||||
res["Title"] = title
|
||||
res["SubTitle"] = subTitle
|
||||
res["ActionName"] = "openUrl"
|
||||
res["IcoPath"] = "Images\\app.ico"
|
||||
res["ActionPara"] = url
|
||||
results.append(res)
|
||||
return json.dumps(results)
|
||||
|
||||
def openUrl(url):
|
||||
webbrowser.open(url)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print query("movie geo")
|
||||
8
Plugins/winalfred.Plugin.V2ex/plugin.ini
Normal file
8
Plugins/winalfred.Plugin.V2ex/plugin.ini
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[plugin]
|
||||
ActionKeyword = v2ex
|
||||
Name = WinAlfred.V2ex
|
||||
Author = qianlifeng
|
||||
Version = 0.1
|
||||
Language = python
|
||||
Description = workflow for v2ex
|
||||
ExecuteFile = main.py
|
||||
|
|
@ -111,7 +111,11 @@ namespace WinAlfred.WorkflowInstaller
|
|||
string winalfred = AppDomain.CurrentDomain.BaseDirectory + "WinAlfred.exe";
|
||||
if (File.Exists(winalfred))
|
||||
{
|
||||
Process.Start(winalfred, "reloadWorkflows");
|
||||
ProcessStartInfo info = new ProcessStartInfo(winalfred, "reloadWorkflows")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
Process.Start(info);
|
||||
MessageBox.Show("You have installed workflow " + plugin.Name + " successfully.");
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Microsoft.VisualBasic.ApplicationServices;
|
||||
using WinAlfred.Commands;
|
||||
using StartupEventArgs = System.Windows.StartupEventArgs;
|
||||
|
||||
namespace WinAlfred
|
||||
|
|
@ -57,12 +58,14 @@ namespace WinAlfred
|
|||
base.OnStartup(e);
|
||||
|
||||
window = new MainWindow();
|
||||
window.ShowApp(e.Args);
|
||||
window.ShowApp();
|
||||
window.ParseArgs(e.Args);
|
||||
}
|
||||
|
||||
public void Activate(string[] commandLine)
|
||||
public void Activate(string[] args)
|
||||
{
|
||||
window.ShowApp(commandLine);
|
||||
window.ShowApp();
|
||||
window.ParseArgs(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ namespace WinAlfred
|
|||
private void InitialTray()
|
||||
{
|
||||
notifyIcon = new NotifyIcon { Text = "WinAlfred", Icon = Properties.Resources.app, Visible = true };
|
||||
notifyIcon.Click += (o, e) => ShowWinAlfred(null);
|
||||
notifyIcon.Click += (o, e) => ShowWinAlfred();
|
||||
System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open");
|
||||
open.Click += (o, e) => ShowWinAlfred(null);
|
||||
open.Click += (o, e) => ShowWinAlfred();
|
||||
System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit");
|
||||
exit.Click += (o, e) => CloseApp();
|
||||
System.Windows.Forms.MenuItem[] childen = { open, exit };
|
||||
|
|
@ -78,7 +78,7 @@ namespace WinAlfred
|
|||
{
|
||||
if (!IsVisible)
|
||||
{
|
||||
ShowWinAlfred(null);
|
||||
ShowWinAlfred();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -132,7 +132,15 @@ namespace WinAlfred
|
|||
Hide();
|
||||
}
|
||||
|
||||
private void ShowWinAlfred(string[] args)
|
||||
private void ShowWinAlfred()
|
||||
{
|
||||
Show();
|
||||
Activate();
|
||||
tbQuery.Focus();
|
||||
tbQuery.SelectAll();
|
||||
}
|
||||
|
||||
public void ParseArgs(string[] args)
|
||||
{
|
||||
if (args != null && args.Length > 0)
|
||||
{
|
||||
|
|
@ -147,15 +155,11 @@ namespace WinAlfred
|
|||
{
|
||||
string query = args[1];
|
||||
tbQuery.Text = query;
|
||||
tbQuery.SelectAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Show();
|
||||
Activate();
|
||||
tbQuery.Focus();
|
||||
tbQuery.SelectAll();
|
||||
}
|
||||
|
||||
private void SetAutoStart(bool IsAtuoRun)
|
||||
|
|
@ -261,9 +265,9 @@ namespace WinAlfred
|
|||
HideWinAlfred();
|
||||
}
|
||||
|
||||
public void ShowApp(string[] args)
|
||||
public void ShowApp()
|
||||
{
|
||||
ShowWinAlfred(args);
|
||||
ShowWinAlfred();
|
||||
}
|
||||
|
||||
public void ShowMsg(string title, string subTitle, string iconPath)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.Plugin.System;
|
||||
|
|
@ -11,7 +12,7 @@ namespace WinAlfred.PluginLoader
|
|||
{
|
||||
public abstract class BasePluginLoader
|
||||
{
|
||||
private static string PluginPath = "Plugins";
|
||||
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
|
||||
private static string PluginConfigName = "plugin.ini";
|
||||
protected static List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
|
||||
public abstract List<PluginPair> LoadPlugin();
|
||||
|
|
@ -70,8 +71,8 @@ namespace WinAlfred.PluginLoader
|
|||
metadata.Version = ini.GetSetting("plugin", "Version");
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
||||
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
|
||||
metadata.ExecuteFilePath = directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||
metadata.PluginDirecotry = directory + "\\";
|
||||
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
|
||||
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace WinAlfred.PluginLoader
|
|||
ChangeQuery = s => window.ChangeQuery(s),
|
||||
CloseApp = window.CloseApp,
|
||||
HideApp = window.HideApp,
|
||||
ShowApp = () => window.ShowApp(null),
|
||||
ShowApp = () => window.ShowApp(),
|
||||
ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath)
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("WinAlfredWPF")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("WinAlfredWPF")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//若要开始生成可本地化的应用程序,请在
|
||||
//<PropertyGroup> 中的 .csproj 文件中
|
||||
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。例如,如果您在源文件中
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(在页面或应用程序资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(在页面、应用程序或任何主题特定资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("WinAlfred")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("WinAlfred")]
|
||||
[assembly: AssemblyCopyright("Copyright © qianlifeng 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//若要开始生成可本地化的应用程序,请在
|
||||
//<PropertyGroup> 中的 .csproj 文件中
|
||||
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。例如,如果您在源文件中
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(在页面或应用程序资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(在页面、应用程序或任何主题特定资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
Loading…
Reference in a new issue