-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[PT Run][New Plugin] Web Search #14882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
616ead6
[PT Run][New Plugin] Web Search
sibber5 d139edc
[PT Run][Web Search] Added plugin files to WXS and YML
sibber5 9fec024
[PT Run][Web Search] Added docs
sibber5 c6ba014
[PT Run][Web Search] Added new option + minor modifications
sibber5 a6db326
[PT Run][Web Search] Fixed a bug + minor refactoring
sibber5 981de95
[PT Run][Web Search] Updated docs and changed icons
sibber5 8276a5d
[PT Run][Web Search] Fixed capitalization for spell check + fixed icons
sibber5 c797b6d
[PT Run][Web Search] Fixed renaming
sibber5 17a2877
adding cyberrex to name
crutkas 31117f4
[PT Run][Web Search] Fixed typo in doc screenshot
sibber5 8f2107e
Merge branch 'feature/run_websearch' of https://github.com/cyberrex5/…
sibber5 313c1fd
[PT Run][Web Search] Fixed plugin not working with Opera browser + mi…
sibber5 f1c7592
Merge branch 'main' into feature/run_websearch
sibber5 3d5c7bd
Fixed merge and typo
sibber5 fee554a
[PT Run][Web Search] Removed globalization error suppression + change…
sibber5 c501a76
Merge branch 'microsoft:main' into feature/run_websearch
sibber5 ececa49
[PT Run][Web Search] Added LocProject.json + minor modifications
sibber5 cd74c21
Merge branch 'feature/run_websearch' of https://github.com/cyberrex5/…
sibber5 dda2b8e
[PT Run][Web Search] Using plugin icon to not confuse with uri plugin…
sibber5 da6ab81
Added Firefox to spell-check expect.txt
sibber5 489fc14
[PT Run][Web Search] Fixed bug with opera + changed default setting's…
sibber5 a4451b7
Added sourceid to spell-check expect.txt
sibber5 ce8a864
Merge branch 'main' into feature/run_websearch
sibber5 fb5a251
Merge branch 'main' into feature/run_websearch
sibber5 1b9bd15
[PT Run][WebSearch] Changed action word
sibber5 bdb07ef
Making Web plugin a dependency for launcher like other plugins
crutkas 1133b18
[PT Run][Web Search] Now using JsonDocument + better way of getting b…
sibber5 2976c1b
Merge branch 'feature/run_websearch' of https://github.com/cyberrex5/…
sibber5 edca4f2
[PT Run][Web Search] Fixed bug
sibber5 2e7d19e
adding in DLL to signing for release.yml build
crutkas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## Web Search Plugin | ||
| The Web Search Plugin, as the name suggests, is used to perform a web search - in the default search engine in the default browser - on the query that has been entered by the user. | ||
|
|
||
|  | ||
|
|
||
| ## Default Browser Icon | ||
| - The icon for each web search result is that of the default browser set by the user. | ||
| - It, and the browser path, are obtained from the user registry and updated each time the theme of PT Run is changed. | ||
|
|
||
| ## Score | ||
| - The web search result always has a score of 0 which indicates that it would show up after each of the other plugins, other than the indexer plugin and possibly the uri plugin which both have a score of 0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
.../Community.PowerToys.Run.Plugin.WebSearch/Community.PowerToys.Run.Plugin.WebSearch.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
| <Import Project="..\..\..\..\Version.props" /> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| <ProjectGuid>{9F94B303-5E21-4364-9362-64426F8DB932}</ProjectGuid> | ||
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <RootNamespace>Community.PowerToys.Run.Plugin.WebSearch</RootNamespace> | ||
| <AssemblyName>Community.PowerToys.Run.Plugin.WebSearch</AssemblyName> | ||
| <Version>$(Version).0</Version> | ||
| <useWPF>true</useWPF> | ||
| <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
| <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
| <Platforms>x64</Platforms> | ||
| <NeutralLanguage>en-US</NeutralLanguage> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <DebugSymbols>true</DebugSymbols> | ||
| <OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\WebSearch\</OutputPath> | ||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| <DebugType>full</DebugType> | ||
| <PlatformTarget>x64</PlatformTarget> | ||
| <LangVersion>7.3</LangVersion> | ||
| <ErrorReport>prompt</ErrorReport> | ||
| <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
| <WarningLevel>4</WarningLevel> | ||
| <Optimize>false</Optimize> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\WebSearch\</OutputPath> | ||
| <DefineConstants>TRACE</DefineConstants> | ||
| <Optimize>true</Optimize> | ||
| <DebugType>pdbonly</DebugType> | ||
| <PlatformTarget>x64</PlatformTarget> | ||
| <LangVersion>7.3</LangVersion> | ||
| <ErrorReport>prompt</ErrorReport> | ||
| <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
| <WarningLevel>4</WarningLevel> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs"> | ||
| <Link>GlobalSuppressions.cs</Link> | ||
| </Compile> | ||
| <AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json"> | ||
| <Link>StyleCop.json</Link> | ||
| </AdditionalFiles> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj"> | ||
| <Private>false</Private> | ||
| </ProjectReference> | ||
| <ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj"> | ||
| <Private>false</Private> | ||
| </ProjectReference> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="plugin.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" /> | ||
| <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| <PackageReference Include="System.Runtime" Version="4.3.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Update="Properties\Resources.Designer.cs"> | ||
| <DesignTime>True</DesignTime> | ||
| <AutoGen>True</AutoGen> | ||
| <DependentUpon>Resources.resx</DependentUpon> | ||
| </Compile> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <EmbeddedResource Update="Properties\Resources.resx"> | ||
| <Generator>PublicResXFileCodeGenerator</Generator> | ||
| <LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
| </EmbeddedResource> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Update="Images\WebSearch.dark.png"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| <None Update="Images\WebSearch.light.png"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
82 changes: 82 additions & 0 deletions
82
src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.WebSearch/ExtraStringMethods.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Copyright (c) Microsoft Corporation | ||
| // The Microsoft Corporation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Community.PowerToys.Run.Plugin.WebSearch | ||
| { | ||
| public static class ExtraStringMethods | ||
| { | ||
| /// <summary>Gets a specific value from a JSON string.</summary> | ||
| /// <param name="json">The string representing the JSON.</param> | ||
| /// <param name="value">The string value to return (e.g. to get json.foo.bar pass `new string[] {"foo", "bar"}`).</param> | ||
| /// <returns>The string value if found. <paramref name="null"/> if not.</returns> | ||
| public static string GetJSONStringValue(string json, string[] value) | ||
| { | ||
| if (json is null) | ||
| { | ||
| throw new ArgumentNullException(nameof(json)); | ||
| } | ||
|
|
||
| if (value is null) | ||
| { | ||
| throw new ArgumentNullException(nameof(value)); | ||
| } | ||
|
|
||
| if (value.Length == 0) | ||
| { | ||
| throw new ArgumentException($"{nameof(value)} cannot be empty.", nameof(value)); | ||
| } | ||
|
|
||
| int startIndex = 0; | ||
| for (int i = 0; i < value.Length; ++i) | ||
| { | ||
| string val = $"\"{value[i]}\""; | ||
|
|
||
| int valIndex = json.IndexOf(val, startIndex, StringComparison.Ordinal); | ||
| if (valIndex == -1) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| startIndex = valIndex + val.Length + 1; | ||
| } | ||
|
|
||
| int valStartIndex = json.IndexOf("\"", startIndex, StringComparison.Ordinal); | ||
| if (valStartIndex == -1) | ||
| { | ||
| throw new ArgumentException($"The specified value is not of type string.", nameof(value)); | ||
| } | ||
|
|
||
| ++valStartIndex; | ||
| return json.Substring(valStartIndex, json.IndexOf("\"", valStartIndex + 1, StringComparison.Ordinal) - valStartIndex); | ||
| } | ||
|
|
||
| /// <summary>Gets the index of the nth occurrence of the specified character in the string.</summary> | ||
| /// <returns>The zero-based index of <paramref name="val"/> if found, or -1 if not.</returns> | ||
| public static int GetStrNthIndex(string s, char val, int n) | ||
| { | ||
| if (s is null) | ||
| { | ||
| throw new ArgumentNullException(nameof(s)); | ||
| } | ||
|
|
||
| int count = 1; | ||
| for (int i = 0; i < s.Length; ++i) | ||
| { | ||
| if (s[i] == val) | ||
| { | ||
| if (n == count) | ||
| { | ||
| return i; | ||
| } | ||
|
|
||
| ++count; | ||
| } | ||
| } | ||
|
|
||
| return -1; | ||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+1.28 KB
...cher/Plugins/Community.PowerToys.Run.Plugin.WebSearch/Images/WebSearch.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.19 KB
...her/Plugins/Community.PowerToys.Run.Plugin.WebSearch/Images/WebSearch.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.WebSearch/LocProject.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "Projects": [ | ||
| { | ||
| "LanguageSet": "Azure_Languages", | ||
| "LocItems": [ | ||
| { | ||
| "SourceFile": "src\\modules\\launcher\\Plugins\\Community.PowerToys.Run.Plugin.WebSearch\\Properties\\Resources.resx", | ||
| "CopyOption": "LangIDOnName", | ||
| "OutputPath": "src\\modules\\launcher\\Plugins\\Community.PowerToys.Run.Plugin.WebSearch\\Properties" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we need these extra methods that work with strings?