Skip to content

Commit 8026533

Browse files
committed
Added search bar
1 parent 550e1e1 commit 8026533

File tree

18 files changed

+166
-9
lines changed

18 files changed

+166
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN npm install --production
1010

1111
COPY . .
1212

13-
RUN mkdir -p ./public ./data ./data/uploads \
13+
RUN mkdir -p ./public ./data \
1414
&& cd ./client \
1515
&& npm install --production \
1616
&& npm run build \

Dockerfile.multiarch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN apk --no-cache --virtual build-dependencies add python make g++ \
1111

1212
COPY . .
1313

14-
RUN mkdir -p ./public ./data ./data/uploads \
14+
RUN mkdir -p ./public ./data \
1515
&& cd ./client \
1616
&& npm install --production \
1717
&& npm run build \

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ Follow instructions from wiki: [Installation without Docker](https://github.com/
8181
![Homescreen screenshot](./github/_themes.png)
8282

8383
## Usage
84+
### Search bar
85+
> While opening links, module will follow `Open all links in the same tab` setting
86+
#### Supported search engines
87+
| Name | Prefix | Search URL |
88+
|------------|--------|-------------------------------------|
89+
| Disroot | /ds | http://search.disroot.org/search?q= |
90+
| DuckDuckGo | /d | https://duckduckgo.com/?q= |
91+
| Google | /g | https://www.google.com/search?q= |
92+
93+
#### Supported services
94+
| Name | Prefix | Search URL |
95+
|--------------------|--------|-----------------------------------------------|
96+
| IMDb | /im | https://www.imdb.com/find?q= |
97+
| Reddit | /r | -https://www.reddit.com/search?q= |
98+
| The Movie Database | /mv | https://www.themoviedb.org/search?query= |
99+
| Youtube | /yt | https://www.youtube.com/results?search_query= |
100+
84101
### Setting up weather module
85102
1. Obtain API Key from [Weather API](https://www.weatherapi.com/pricing.aspx).
86103
> Free plan allows for 1M calls per month. Flame is making less then 3K API calls per month.

client/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
REACT_APP_VERSION=1.4.4
1+
REACT_APP_VERSION=1.5.0

client/src/components/Home/Home.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import classes from './Home.module.css';
2222
import AppGrid from '../Apps/AppGrid/AppGrid';
2323
import BookmarkGrid from '../Bookmarks/BookmarkGrid/BookmarkGrid';
2424
import WeatherWidget from '../Widgets/WeatherWidget/WeatherWidget';
25+
import SearchBox from '../SearchBox/SearchBox';
2526

2627
// Functions
2728
import { greeter } from './functions/greeter';
@@ -87,6 +88,11 @@ const Home = (props: ComponentProps): JSX.Element => {
8788

8889
return (
8990
<Container>
91+
{searchConfig('hideSearch', 0) !== 1
92+
? <SearchBox />
93+
: <div></div>
94+
}
95+
9096
{searchConfig('hideHeader', 0) !== 1
9197
? (
9298
<header className={classes.Header}>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.SearchBox {
2+
width: 100%;
3+
padding: 10px 0;
4+
color: var(--color-primary);
5+
/* font-size: 20px; */
6+
margin-bottom: 20px;
7+
background-color: transparent;
8+
border: none;
9+
border-bottom: 2px solid var(--color-accent);
10+
opacity: 0.5;
11+
transition: all 0.2s;
12+
}
13+
14+
.SearchBox:focus {
15+
opacity: 1;
16+
outline: none;
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { useRef, useEffect, KeyboardEvent } from 'react';
2+
3+
import classes from './SearchBox.module.css';
4+
import { searchParser } from '../../utility';
5+
6+
const SearchBox = (): JSX.Element => {
7+
const inputRef = useRef<HTMLInputElement>(document.createElement('input'));
8+
9+
useEffect(() => {
10+
inputRef.current.focus();
11+
}, [])
12+
13+
const searchHandler = (e: KeyboardEvent<HTMLInputElement>) => {
14+
if (e.code === 'Enter') {
15+
searchParser(inputRef.current.value);
16+
}
17+
}
18+
19+
return (
20+
<input
21+
ref={inputRef}
22+
type='text'
23+
className={classes.SearchBox}
24+
onKeyDown={(e) => searchHandler(e)}
25+
/>
26+
)
27+
}
28+
29+
export default SearchBox;

client/src/components/Settings/OtherSettings/OtherSettings.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
3434
hideHeader: 0,
3535
hideApps: 0,
3636
hideCategories: 0,
37+
hideSearch: 0,
3738
useOrdering: 'createdAt',
3839
openSameTab: 0
3940
})
@@ -47,6 +48,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
4748
hideHeader: searchConfig('hideHeader', 0),
4849
hideApps: searchConfig('hideApps', 0),
4950
hideCategories: searchConfig('hideCategories', 0),
51+
hideSearch: searchConfig('hideSearch', 0),
5052
useOrdering: searchConfig('useOrdering', 'createdAt'),
5153
openSameTab: searchConfig('openSameTab', 0)
5254
})
@@ -151,6 +153,18 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
151153

152154
{/* MODULES OPTIONS */}
153155
<h2 className={classes.SettingsSection}>Modules</h2>
156+
<InputGroup>
157+
<label htmlFor='hideSearch'>Hide search bar</label>
158+
<select
159+
id='hideSearch'
160+
name='hideSearch'
161+
value={formData.hideSearch}
162+
onChange={(e) => inputChangeHandler(e, true)}
163+
>
164+
<option value={1}>True</option>
165+
<option value={0}>False</option>
166+
</select>
167+
</InputGroup>
154168
<InputGroup>
155169
<label htmlFor='hideHeader'>Hide greeting and date</label>
156170
<select

client/src/interfaces/Forms.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface SettingsForm {
1212
hideHeader: number;
1313
hideApps: number;
1414
hideCategories: number;
15+
hideSearch: number;
1516
useOrdering: string;
1617
openSameTab: number;
1718
}

client/src/interfaces/Query.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface Query {
2+
name: string;
3+
prefix: string;
4+
template: string;
5+
}

0 commit comments

Comments
 (0)