2014-01-29 14:44:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Wox.Infrastructure;
|
|
|
|
|
using Wox.Infrastructure.UserSettings;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Plugin.System
|
|
|
|
|
{
|
|
|
|
|
public class WebSearchPlugin : BaseSystemPlugin
|
|
|
|
|
{
|
|
|
|
|
protected override List<Result> QueryInternal(Query query)
|
|
|
|
|
{
|
|
|
|
|
List<Result> results = new List<Result>();
|
|
|
|
|
if (string.IsNullOrEmpty(query.ActionName)) return results;
|
|
|
|
|
|
|
|
|
|
WebSearch webSearch =
|
2014-02-02 08:15:34 +00:00
|
|
|
|
CommonStorage.Instance.UserSetting.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled);
|
2014-01-29 14:44:57 +00:00
|
|
|
|
|
|
|
|
|
if (webSearch != null)
|
|
|
|
|
{
|
|
|
|
|
string keyword = query.ActionParameters.Count > 0 ? query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1) : "";
|
|
|
|
|
results.Add(new Result()
|
|
|
|
|
{
|
2014-02-02 08:15:34 +00:00
|
|
|
|
Title = string.Format("Search {0} for \"{1}\"", webSearch.Title, keyword),
|
2014-01-29 14:44:57 +00:00
|
|
|
|
IcoPath = webSearch.IconPath,
|
2014-02-09 12:55:18 +00:00
|
|
|
|
Action = (c) => Process.Start(webSearch.Url.Replace("{q}", keyword))
|
2014-01-29 14:44:57 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void InitInternal(PluginInitContext context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|