mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
Merge pull request #61 from jjack/master
Adding a default search provider option, with DuckDuckGo as the default
This commit is contained in:
commit
f1c48e8a15
4 changed files with 33 additions and 7 deletions
|
@ -35,6 +35,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
hideApps: 0,
|
hideApps: 0,
|
||||||
hideCategories: 0,
|
hideCategories: 0,
|
||||||
hideSearch: 0,
|
hideSearch: 0,
|
||||||
|
defaultSearchProvider: 'd',
|
||||||
useOrdering: 'createdAt',
|
useOrdering: 'createdAt',
|
||||||
appsSameTab: 0,
|
appsSameTab: 0,
|
||||||
bookmarksSameTab: 0,
|
bookmarksSameTab: 0,
|
||||||
|
@ -51,6 +52,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
hideApps: searchConfig('hideApps', 0),
|
hideApps: searchConfig('hideApps', 0),
|
||||||
hideCategories: searchConfig('hideCategories', 0),
|
hideCategories: searchConfig('hideCategories', 0),
|
||||||
hideSearch: searchConfig('hideSearch', 0),
|
hideSearch: searchConfig('hideSearch', 0),
|
||||||
|
defaultSearchProvider: searchConfig('defaultSearchProvider', 'd'),
|
||||||
useOrdering: searchConfig('useOrdering', 'createdAt'),
|
useOrdering: searchConfig('useOrdering', 'createdAt'),
|
||||||
appsSameTab: searchConfig('appsSameTab', 0),
|
appsSameTab: searchConfig('appsSameTab', 0),
|
||||||
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
|
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
|
||||||
|
@ -192,6 +194,24 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
<option value={0}>False</option>
|
<option value={0}>False</option>
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
|
||||||
|
<select
|
||||||
|
id='defaultSearchProvider'
|
||||||
|
name='defaultSearchProvider'
|
||||||
|
value={formData.defaultSearchProvider}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
>
|
||||||
|
<option value='d'>DuckDuckGo</option>
|
||||||
|
<option value='g'>Google</option>
|
||||||
|
<option value='s'>Disroot</option>
|
||||||
|
<option value='yt'>YouTube</option>
|
||||||
|
<option value='r'>Reddit</option>
|
||||||
|
<option value='im'>IMDb</option>
|
||||||
|
<option value='mv'>The Movie Database</option>
|
||||||
|
<option value='sp'>Spotify</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor='hideHeader'>Hide greeting and date</label>
|
<label htmlFor='hideHeader'>Hide greeting and date</label>
|
||||||
<select
|
<select
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface SettingsForm {
|
||||||
hideApps: number;
|
hideApps: number;
|
||||||
hideCategories: number;
|
hideCategories: number;
|
||||||
hideSearch: number;
|
hideSearch: number;
|
||||||
|
defaultSearchProvider: string;
|
||||||
useOrdering: string;
|
useOrdering: string;
|
||||||
appsSameTab: number;
|
appsSameTab: number;
|
||||||
bookmarksSameTab: number;
|
bookmarksSameTab: number;
|
||||||
|
|
|
@ -4,12 +4,13 @@ import { Query } from '../interfaces';
|
||||||
import { searchConfig } from '.';
|
import { searchConfig } from '.';
|
||||||
|
|
||||||
export const searchParser = (searchQuery: string): boolean => {
|
export const searchParser = (searchQuery: string): boolean => {
|
||||||
const space = searchQuery.indexOf(' ');
|
const splitQuery = searchQuery.match(/^\/([a-z]+)[ ](.+)$/i);
|
||||||
const prefix = searchQuery.slice(1, space);
|
const prefix = splitQuery ? splitQuery[1] : searchConfig('defaultSearchProvider', 'd');
|
||||||
const search = encodeURIComponent(searchQuery.slice(space + 1));
|
const search = splitQuery ? encodeURIComponent(splitQuery[2]) : encodeURIComponent(searchQuery);
|
||||||
|
|
||||||
const query = queries.find((q: Query) => q.prefix === prefix);
|
const query = queries.find((q: Query) => q.prefix === prefix);
|
||||||
|
|
||||||
|
console.log("QUERY IS " + query);
|
||||||
if (query) {
|
if (query) {
|
||||||
const sameTab = searchConfig('searchSameTab', false);
|
const sameTab = searchConfig('searchSameTab', false);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@
|
||||||
{
|
{
|
||||||
"key": "hideSearch",
|
"key": "hideSearch",
|
||||||
"value": false
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "defaultSearchProvider",
|
||||||
|
"value": "d"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue