2019-10-06 09:55:57 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Wox.Infrastructure;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Plugin.BrowserBookmark.Commands
|
|
|
|
|
{
|
|
|
|
|
internal static class Bookmarks
|
|
|
|
|
{
|
|
|
|
|
internal static bool MatchProgram(Bookmark bookmark, string queryString)
|
|
|
|
|
{
|
2019-10-17 18:37:09 +08:00
|
|
|
|
if (StringMatcher.FuzzySearch(queryString, bookmark.Name).IsSearchPrecisionScoreMet()) return true;
|
|
|
|
|
if (StringMatcher.FuzzySearch(queryString, bookmark.PinyinName).IsSearchPrecisionScoreMet()) return true;
|
|
|
|
|
if (StringMatcher.FuzzySearch(queryString, bookmark.Url).IsSearchPrecisionScoreMet()) return true;
|
2019-10-06 09:55:57 +08:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static List<Bookmark> LoadAllBookmarks()
|
|
|
|
|
{
|
|
|
|
|
var allbookmarks = new List<Bookmark>();
|
|
|
|
|
|
|
|
|
|
var chromeBookmarks = new ChromeBookmarks();
|
|
|
|
|
var mozBookmarks = new FirefoxBookmarks();
|
|
|
|
|
|
|
|
|
|
//TODO: Let the user select which browser's bookmarks are displayed
|
|
|
|
|
// Add Firefox bookmarks
|
|
|
|
|
mozBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x));
|
|
|
|
|
|
|
|
|
|
// Add Chrome bookmarks
|
|
|
|
|
chromeBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x));
|
|
|
|
|
|
|
|
|
|
return allbookmarks.Distinct().ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|