Skip to content

Commit f93659b

Browse files
authored
Merge pull request pawelmalak#66 from pawelmalak/feature
v1.6 Release
2 parents f1c48e8 + 88785aa commit f93659b

File tree

7 files changed

+53
-27
lines changed

7 files changed

+53
-27
lines changed

client/.env

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

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { connect } from 'react-redux';
55
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';
66

77
// Typescript
8-
import { GlobalState, NewNotification, SettingsForm } from '../../../interfaces';
8+
import { GlobalState, NewNotification, Query, SettingsForm } from '../../../interfaces';
99

1010
// UI
1111
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
@@ -16,6 +16,7 @@ import classes from './OtherSettings.module.css';
1616

1717
// Utils
1818
import { searchConfig } from '../../../utility';
19+
import { queries } from '../../../utility/searchQueries.json';
1920

2021
interface ComponentProps {
2122
createNotification: (notification: NewNotification) => void;
@@ -144,6 +145,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
144145
<option value='orderId'>Custom order</option>
145146
</select>
146147
</InputGroup>
148+
<InputGroup>
149+
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
150+
<select
151+
id='defaultSearchProvider'
152+
name='defaultSearchProvider'
153+
value={formData.defaultSearchProvider}
154+
onChange={(e) => inputChangeHandler(e)}
155+
>
156+
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</option>))}
157+
</select>
158+
</InputGroup>
147159
<InputGroup>
148160
<label htmlFor='searchSameTab'>Open search results in the same tab</label>
149161
<select
@@ -180,6 +192,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
180192
<option value={0}>False</option>
181193
</select>
182194
</InputGroup>
195+
183196
{/* MODULES OPTIONS */}
184197
<h2 className={classes.SettingsSection}>Modules</h2>
185198
<InputGroup>
@@ -194,24 +207,6 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
194207
<option value={0}>False</option>
195208
</select>
196209
</InputGroup>
197-
<InputGroup>
198-
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
199-
<select
200-
id='defaultSearchProvider'
201-
name='defaultSearchProvider'
202-
value={formData.defaultSearchProvider}
203-
onChange={(e) => inputChangeHandler(e)}
204-
>
205-
<option value='d'>DuckDuckGo</option>
206-
<option value='g'>Google</option>
207-
<option value='s'>Disroot</option>
208-
<option value='yt'>YouTube</option>
209-
<option value='r'>Reddit</option>
210-
<option value='im'>IMDb</option>
211-
<option value='mv'>The Movie Database</option>
212-
<option value='sp'>Spotify</option>
213-
</select>
214-
</InputGroup>
215210
<InputGroup>
216211
<label htmlFor='hideHeader'>Hide greeting and date</label>
217212
<select
@@ -266,4 +261,4 @@ const actions = {
266261
sortCategories
267262
}
268263

269-
export default connect(mapStateToProps, actions)(OtherSettings);
264+
export default connect(mapStateToProps, actions)(OtherSettings);

client/src/utility/searchParser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const searchParser = (searchQuery: string): boolean => {
1010

1111
const query = queries.find((q: Query) => q.prefix === prefix);
1212

13-
console.log("QUERY IS " + query);
1413
if (query) {
1514
const sameTab = searchConfig('searchSameTab', false);
1615

@@ -24,4 +23,4 @@ export const searchParser = (searchQuery: string): boolean => {
2423
}
2524

2625
return false;
27-
}
26+
}

client/src/utility/urlParser.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ export const urlParser = (url: string): string[] => {
22
let parsedUrl: string;
33
let displayUrl: string;
44

5-
if (/https?:\/\//.test(url)) {
6-
// Url starts with http[s]:// -> leave it as it is
5+
if (/(https?|steam):\/\//.test(url)) {
6+
// Url starts with http[s]:// or steam:// -> leave it as it is
77
parsedUrl = url;
88
} else {
99
// No protocol -> apply http:// prefix
1010
parsedUrl = `http://${url}`;
1111
}
1212

1313
// Create simplified url to display as text
14-
displayUrl = url
14+
if (/steam:\/\//.test(url)) {
15+
displayUrl = 'Run Steam App';
16+
} else {
17+
displayUrl = url
1518
.replace(/https?:\/\//, '')
1619
.replace('www.', '')
1720
.replace(/\/$/, '');
18-
21+
}
22+
1923
return [displayUrl, parsedUrl]
2024
}

controllers/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Config = require('../models/Config');
44
const { Op } = require('sequelize');
55
const File = require('../utils/File');
66
const { join } = require('path');
7+
const fs = require('fs');
78

89
// @desc Insert new key:value pair
910
// @route POST /api/config
@@ -151,6 +152,9 @@ exports.updateCss = asyncWrapper(async (req, res, next) => {
151152
const file = new File(join(__dirname, '../public/flame.css'));
152153
file.write(req.body.styles);
153154

155+
// Copy file to docker volume
156+
fs.copyFileSync(join(__dirname, '../public/flame.css'), join(__dirname, '../data/flame.css'));
157+
154158
res.status(200).json({
155159
success: true,
156160
data: {}

server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Socket = require('./Socket');
77
const Sockets = require('./Sockets');
88
const associateModels = require('./models/associateModels');
99
const initConfig = require('./utils/initConfig');
10+
const findCss = require('./utils/findCss');
1011
const Logger = require('./utils/Logger');
1112
const logger = new Logger();
1213

@@ -16,6 +17,7 @@ const PORT = process.env.PORT || 5005;
1617
await connectDB();
1718
await associateModels();
1819
await initConfig();
20+
findCss();
1921

2022
// Create server for Express API and WebSockets
2123
const server = http.createServer();

utils/findCss.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const { join } = require('path');
3+
const Logger = require('./Logger');
4+
const logger = new Logger();
5+
6+
// Check if flame.css exists in mounted docker volume. Create new file if not
7+
const findCss = () => {
8+
const srcPath = join(__dirname, '../data/flame.css');
9+
const destPath = join(__dirname, '../public/flame.css');
10+
11+
if (fs.existsSync(srcPath)) {
12+
fs.copyFileSync(srcPath, destPath);
13+
logger.log('Custom CSS file found');
14+
return;
15+
}
16+
17+
logger.log('Creating empty CSS file');
18+
fs.writeFileSync(destPath, '');
19+
20+
}
21+
22+
module.exports = findCss;

0 commit comments

Comments
 (0)