Remove Plugins

This commit is contained in:
qianlifeng 2014-03-23 10:41:10 +08:00
parent 7dda2df54b
commit fc07979966
17 changed files with 0 additions and 483 deletions

View File

@ -1,113 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
//From:http://blog.csdn.net/zhoufoxcn/article/details/6404236
namespace Wox.Plugin.Fanyi
{
public class HttpRequest
{
private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, string userAgent, CookieCollection cookies)
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("url");
}
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";
request.UserAgent = DefaultUserAgent;
if (!string.IsNullOrEmpty(userAgent))
{
request.UserAgent = userAgent;
}
if (timeout.HasValue)
{
request.Timeout = timeout.Value;
}
if (cookies != null)
{
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
}
return request.GetResponse() as HttpWebResponse;
}
public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters, int? timeout, string userAgent, Encoding requestEncoding, CookieCollection cookies)
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("url");
}
if (requestEncoding == null)
{
throw new ArgumentNullException("requestEncoding");
}
HttpWebRequest request = null;
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
else
{
request = WebRequest.Create(url) as HttpWebRequest;
}
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
if (!string.IsNullOrEmpty(userAgent))
{
request.UserAgent = userAgent;
}
else
{
request.UserAgent = DefaultUserAgent;
}
if (timeout.HasValue)
{
request.Timeout = timeout.Value;
}
if (cookies != null)
{
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
}
if (!(parameters == null || parameters.Count == 0))
{
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (string key in parameters.Keys)
{
if (i > 0)
{
buffer.AppendFormat("&{0}={1}", key, parameters[key]);
}
else
{
buffer.AppendFormat("{0}={1}", key, parameters[key]);
}
i++;
}
byte[] data = requestEncoding.GetBytes(buffer.ToString());
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
return request.GetResponse() as HttpWebResponse;
}
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,100 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using Newtonsoft.Json;
namespace Wox.Plugin.Fanyi
{
public class TranslateResult
{
public string from { get; set; }
public string to { get; set; }
public List<SrcDst> trans_result { get; set; }
}
public class SrcDst
{
public string src { get; set; }
public string dst { get; set; }
}
public class Main : IPlugin
{
private string translateURL = "http://openapi.baidu.com/public/2.0/bmt/translate";
private string baiduKey = "SnPcDY3iH5jDbklRewkG2D2v";
private static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (query.ActionParameters.Count == 0)
{
results.Add(new Result()
{
Title = "Start to translate between Chinese and English",
SubTitle = "Powered by baidu api",
IcoPath = "Images\\translate.png"
});
return results;
}
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("from", "auto");
data.Add("to", "auto");
data.Add("q", query.RawQuery.Substring(3));
data.Add("client_id", baiduKey);
HttpWebResponse response = HttpRequest.CreatePostHttpResponse(translateURL, data, null, null, Encoding.UTF8, null);
Stream s = response.GetResponseStream();
if (s != null)
{
StreamReader reader = new StreamReader(s, Encoding.UTF8);
string json = reader.ReadToEnd();
TranslateResult o = JsonConvert.DeserializeObject<TranslateResult>(json);
foreach (SrcDst srcDst in o.trans_result)
{
string dst = srcDst.dst;
results.Add(new Result()
{
Title = dst,
SubTitle = "Copy to clipboard",
IcoPath = "Images\\translate.png",
Action = (c) =>
{
Clipboard.SetText(dst);
context.ShowMsg("translation has been copyed to your clipboard.", "",
AssemblyDirectory + "\\Images\\translate.png");
return true;
}
});
}
}
return results;
}
public void Init(PluginInitContext context)
{
this.context = context;
}
private PluginInitContext context { get; set; }
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.Plugin.Fanyi")]
[assembly: AssemblyDescription("https://github.com/qianlifeng/Wox")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wox.Plugin.Fanyi")]
[assembly: AssemblyCopyright("The MIT License (MIT)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("5b55da55-94f5-4248-af75-5eb40409a8ca")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{353769D3-D11C-4D86-BD06-AC8C1D68642B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Fanyi</RootNamespace>
<AssemblyName>Wox.Plugin.Fanyi</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.Fanyi\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Fanyi\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack">
<HintPath>..\..\packages\HtmlAgilityPack.1.4.6\lib\Net20\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HttpRequest.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Images\translate.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net35" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
</packages>

View File

@ -1,11 +0,0 @@
{
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6A",
"ActionKeyword":"fy",
"Name":"Baidu Translator",
"Description":"Translate Chinese and English",
"Author":"qianlifeng",
"Version":"1.0",
"Language":"csharp",
"Website":"http://www.getwox.com",
"ExecuteFileName":"Wox.Plugin.Fanyi.dll"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,29 +0,0 @@
#encoding=utf8
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://www.gewara.com/movie/searchMovie.xhtml')
bs = BeautifulSoup(r.text)
results = []
for i in bs.select(".ui_left .ui_media"):
res = {}
score = safeSelectText(i,".grade sub") + safeSelectText(i,".grade sup")
res["Title"] = safeSelectText(i,".title a") + " / " + score
res["SubTitle"] = i.select(".ui_text p")[1].text
res["ActionName"] = "openUrl"
res["IcoPath"] = "Images\\movies.png"
res["ActionPara"] = "http://www.gewara.com" + i.select(".title a")[0]["href"]
results.append(res)
return json.dumps(results)
def openUrl(context,url):
webbrowser.open(url)
if __name__ == "__main__":
print query("movie geo")

View File

@ -1,11 +0,0 @@
{
"ID":"D2D2C23B084D411DB66FE0C79D6C2A7D",
"ActionKeyword":"hotmovie",
"Name":"近期热映电影",
"Description":"近期热映电影,powered by 格瓦拉",
"Author":"qianlifeng",
"Version":"1.0",
"Language":"python",
"Website":"http://www.getwox.com",
"ExecuteFileName":"main.py"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,36 +0,0 @@
#encoding=utf8
from __future__ import unicode_literals
import psutil
import json
def signalResult(process):
res = {}
res["Title"] = process.name
res["SubTitle"] = process.pid
res["ActionName"] = "killProcess"
res["IcoPath"] = "Images\\app.png"
res["ActionPara"] = process.pid
return res
def query(key):
name = key.split(" ")[1]
results = []
for i in psutil.get_process_list():
try:
if name:
if name.lower() in i.name.lower():
results.append(signalResult(i))
else:
results.append(signalResult(i))
except:
pass
return json.dumps(results)
def killProcess(context,pid):
p = psutil.Process(int(pid))
if p:
p.kill()
if __name__ == "__main__":
print killProcess(10008)

View File

@ -1,12 +0,0 @@
{
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6G",
"ActionKeyword":"kill",
"Name":"Wox.Plugin.kill",
"Description":"kill running program",
"Author":"qianlifeng",
"Version":"1.0",
"Language":"python",
"Website":"http://www.getwox.com",
"ExecuteFileName":"main.py"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,34 +0,0 @@
#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(context,url):
webbrowser.open(url)
if __name__ == "__main__":
print query("movie geo")

View File

@ -1,12 +0,0 @@
{
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6H",
"ActionKeyword":"v2ex",
"Name":"Wox.Plugin.v2ex",
"Description":"v2ex viewer",
"Author":"qianlifeng",
"Version":"1.0",
"Language":"python",
"Website":"http://www.getwox.com",
"ExecuteFileName":"main.py"
}