Skip to content
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

v1.6 Release #66

Merged
merged 2 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_VERSION=1.5.2
REACT_APP_VERSION=1.6.0
35 changes: 15 additions & 20 deletions client/src/components/Settings/OtherSettings/OtherSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';

// Typescript
import { GlobalState, NewNotification, SettingsForm } from '../../../interfaces';
import { GlobalState, NewNotification, Query, SettingsForm } from '../../../interfaces';

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

// Utils
import { searchConfig } from '../../../utility';
import { queries } from '../../../utility/searchQueries.json';

interface ComponentProps {
createNotification: (notification: NewNotification) => void;
Expand Down Expand Up @@ -144,6 +145,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value='orderId'>Custom order</option>
</select>
</InputGroup>
<InputGroup>
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
<select
id='defaultSearchProvider'
name='defaultSearchProvider'
value={formData.defaultSearchProvider}
onChange={(e) => inputChangeHandler(e)}
>
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</option>))}
</select>
</InputGroup>
<InputGroup>
<label htmlFor='searchSameTab'>Open search results in the same tab</label>
<select
Expand Down Expand Up @@ -180,6 +192,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option>
</select>
</InputGroup>

{/* MODULES OPTIONS */}
<h2 className={classes.SettingsSection}>Modules</h2>
<InputGroup>
Expand All @@ -194,24 +207,6 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option>
</select>
</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>
<label htmlFor='hideHeader'>Hide greeting and date</label>
<select
Expand Down Expand Up @@ -266,4 +261,4 @@ const actions = {
sortCategories
}

export default connect(mapStateToProps, actions)(OtherSettings);
export default connect(mapStateToProps, actions)(OtherSettings);
3 changes: 1 addition & 2 deletions client/src/utility/searchParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const searchParser = (searchQuery: string): boolean => {

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

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

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

return false;
}
}
12 changes: 8 additions & 4 deletions client/src/utility/urlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ export const urlParser = (url: string): string[] => {
let parsedUrl: string;
let displayUrl: string;

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

// Create simplified url to display as text
displayUrl = url
if (/steam:\/\//.test(url)) {
displayUrl = 'Run Steam App';
} else {
displayUrl = url
.replace(/https?:\/\//, '')
.replace('www.', '')
.replace(/\/$/, '');

}

return [displayUrl, parsedUrl]
}
4 changes: 4 additions & 0 deletions controllers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Config = require('../models/Config');
const { Op } = require('sequelize');
const File = require('../utils/File');
const { join } = require('path');
const fs = require('fs');

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

// Copy file to docker volume
fs.copyFileSync(join(__dirname, '../public/flame.css'), join(__dirname, '../data/flame.css'));

res.status(200).json({
success: true,
data: {}
Expand Down
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Socket = require('./Socket');
const Sockets = require('./Sockets');
const associateModels = require('./models/associateModels');
const initConfig = require('./utils/initConfig');
const findCss = require('./utils/findCss');
const Logger = require('./utils/Logger');
const logger = new Logger();

Expand All @@ -16,6 +17,7 @@ const PORT = process.env.PORT || 5005;
await connectDB();
await associateModels();
await initConfig();
findCss();

// Create server for Express API and WebSockets
const server = http.createServer();
Expand Down
22 changes: 22 additions & 0 deletions utils/findCss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const { join } = require('path');
const Logger = require('./Logger');
const logger = new Logger();

// Check if flame.css exists in mounted docker volume. Create new file if not
const findCss = () => {
const srcPath = join(__dirname, '../data/flame.css');
const destPath = join(__dirname, '../public/flame.css');

if (fs.existsSync(srcPath)) {
fs.copyFileSync(srcPath, destPath);
logger.log('Custom CSS file found');
return;
}

logger.log('Creating empty CSS file');
fs.writeFileSync(destPath, '');

}

module.exports = findCss;