From 05d62da520a24cc6b50a422e24bada525c080075 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 13 Jul 2020 07:57:28 +1000 Subject: [PATCH 01/10] exclude directory path for Web Search plugin --- Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 1da578ad6..3fdb26c93 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -33,6 +33,9 @@ namespace Flow.Launcher.Plugin.WebSearch public List Query(Query query) { + if (FilesFolders.IsLocationPathString(query.Search)) + return new List(); + var searchSourceList = new List(); var results = new List(); From 827a95372228c6b00fe72306a3190099fe1583d6 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Wed, 15 Jul 2020 00:34:09 +0300 Subject: [PATCH 02/10] add PropertyChanged.Fody to Infrastructure project fixes various settings changes requiring a restart to take effect --- .../Flow.Launcher.Infrastructure.csproj | 2 ++ Flow.Launcher.Infrastructure/FodyWeavers.xml | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 Flow.Launcher.Infrastructure/FodyWeavers.xml diff --git a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj index 3a756cd26..410d11536 100644 --- a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj +++ b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj @@ -38,6 +38,7 @@ + @@ -55,6 +56,7 @@ + diff --git a/Flow.Launcher.Infrastructure/FodyWeavers.xml b/Flow.Launcher.Infrastructure/FodyWeavers.xml new file mode 100644 index 000000000..4e68ed1a8 --- /dev/null +++ b/Flow.Launcher.Infrastructure/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From dfcf79c97d8baf4f6a47d26d29413c1dc18c98c7 Mon Sep 17 00:00:00 2001 From: Steven Kalinke Date: Thu, 16 Jul 2020 19:44:11 +1000 Subject: [PATCH 03/10] add chromium edge bookmark loading --- .../Commands/Bookmarks.cs | 4 + .../EdgeBookmarks.cs | 86 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 Plugins/Flow.Launcher.Plugin.BrowserBookmark/EdgeBookmarks.cs diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/Bookmarks.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/Bookmarks.cs index fab372834..7c2db8bf9 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/Bookmarks.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/Bookmarks.cs @@ -21,6 +21,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Commands var chromeBookmarks = new ChromeBookmarks(); var mozBookmarks = new FirefoxBookmarks(); + var edgeBookmarks = new EdgeBookmarks(); //TODO: Let the user select which browser's bookmarks are displayed // Add Firefox bookmarks @@ -29,6 +30,9 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Commands // Add Chrome bookmarks chromeBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x)); + // Add Edge (Chromium) bookmarks + edgeBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x)); + return allbookmarks.Distinct().ToList(); } } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/EdgeBookmarks.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/EdgeBookmarks.cs new file mode 100644 index 000000000..12b80c08a --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/EdgeBookmarks.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; + +namespace Flow.Launcher.Plugin.BrowserBookmark +{ + public class EdgeBookmarks + { + private List bookmarks = new List(); + + public List GetBookmarks() + { + bookmarks.Clear(); + LoadEdgeBookmarks(); + + return bookmarks; + } + + private void ParseEdgeBookmarks(String path, string source) + { + if (!File.Exists(path)) return; + + string all = File.ReadAllText(path); + Regex nameRegex = new Regex("\"name\": \"(?.*?)\""); + MatchCollection nameCollection = nameRegex.Matches(all); + Regex typeRegex = new Regex("\"type\": \"(?.*?)\""); + MatchCollection typeCollection = typeRegex.Matches(all); + Regex urlRegex = new Regex("\"url\": \"(?.*?)\""); + MatchCollection urlCollection = urlRegex.Matches(all); + + List names = (from Match match in nameCollection select match.Groups["name"].Value).ToList(); + List types = (from Match match in typeCollection select match.Groups["type"].Value).ToList(); + List urls = (from Match match in urlCollection select match.Groups["url"].Value).ToList(); + + int urlIndex = 0; + for (int i = 0; i < names.Count; i++) + { + string name = DecodeUnicode(names[i]); + string type = types[i]; + if (type == "url") + { + string url = urls[urlIndex]; + urlIndex++; + + if (url == null) continue; + if (url.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase)) continue; + if (url.StartsWith("vbscript:", StringComparison.OrdinalIgnoreCase)) continue; + + bookmarks.Add(new Bookmark() + { + Name = name, + Url = url, + Source = source + }); + } + } + } + + private void LoadEdgeBookmarks(string path, string name) + { + if (!Directory.Exists(path)) return; + var paths = Directory.GetDirectories(path); + + foreach (var profile in paths) + { + if (File.Exists(Path.Combine(profile, "Bookmarks"))) + ParseEdgeBookmarks(Path.Combine(profile, "Bookmarks"), name + (Path.GetFileName(profile) == "Default" ? "" : (" (" + Path.GetFileName(profile) + ")"))); + } + } + + private void LoadEdgeBookmarks() + { + String platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + LoadEdgeBookmarks(Path.Combine(platformPath, @"Microsoft\Edge\User Data"), "Microsoft Edge"); + LoadEdgeBookmarks(Path.Combine(platformPath, @"Microsoft\Edge SxS\User Data"), "Microsoft Edge Canary"); + } + + private String DecodeUnicode(String dataStr) + { + Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})"); + return reg.Replace(dataStr, m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString()); + } + } +} \ No newline at end of file From 163bf64f893373a8117d2f876134a798014d3513 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 16 Jul 2020 21:47:02 +1000 Subject: [PATCH 04/10] BrowserBookmark version bump --- Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json index a61e8d697..8676a3e5b 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/plugin.json @@ -4,7 +4,7 @@ "Name": "Browser Bookmarks", "Description": "Search your browser bookmarks", "Author": "qianlifeng, Ioannis G.", - "Version": "1.1", + "Version": "1.2.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.browserBookmark.dll", From 62a245f04936ec38e40414d8ca20ec814fa98593 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Thu, 16 Jul 2020 22:38:09 +0300 Subject: [PATCH 05/10] remove success message boxes --- Flow.Launcher/CustomQueryHotkeySetting.xaml.cs | 2 -- .../SearchSourceSetting.xaml.cs | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index bf5c7d769..d036c008c 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -57,7 +57,6 @@ namespace Flow.Launcher App.API.ChangeQuery(pluginHotkey.ActionKeyword); Application.Current.MainWindow.Visibility = Visibility.Visible; }); - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success")); } else { @@ -76,7 +75,6 @@ namespace Flow.Launcher App.API.ChangeQuery(updateCustomHotkey.ActionKeyword); Application.Current.MainWindow.Visibility = Visibility.Visible; }); - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success")); } Close(); diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs index c82fe97c0..9ecdda23f 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs @@ -83,8 +83,6 @@ namespace Flow.Launcher.Plugin.WebSearch _searchSources.Add(_searchSource); - var info = _api.GetTranslation("success"); - MessageBox.Show(info); Close(); } else @@ -106,8 +104,6 @@ namespace Flow.Launcher.Plugin.WebSearch var index = _searchSources.IndexOf(_oldSearchSource); _searchSources[index] = _searchSource; - var info = _api.GetTranslation("success"); - MessageBox.Show(info); Close(); } else From b505a32693296cd922df9ad0f6958ec1ed65bb63 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Thu, 16 Jul 2020 23:12:54 +0300 Subject: [PATCH 06/10] UI: use NoWrap for browser-path text boxes --- .../Views/SettingsControl.xaml | 2 +- Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml index 0aea8f04e..a87841b16 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml @@ -31,7 +31,7 @@