F #3951: Add favicon & html title (#596)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2021-01-07 18:00:13 +01:00
1 parent 439dec4f93
commit b3e9ffe679
11 files changed
+40 -26

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@@ -8,8 +8,11 @@ const thunk = require('redux-thunk').default
const { ServerStyleSheets } = require('@material-ui/core/styles')
const rootReducer = require('client/reducers')
const { getConfig } = require('server/utils/yml')
const { availableLanguages, defaultWebpackMode, defaultAppName, defaultApps } = require('server/utils/constants/defaults')
const { parse } = require('path')
const {
availableLanguages, defaultWebpackMode, defaultApps
} = require('server/utils/constants/defaults')
const { APP_URL, STATIC_FILES_URL } = require('client/constants')
const { capitalize } = require('client/utils')
// settings
const appConfig = getConfig()
@@ -27,44 +30,55 @@ const router = Router()
router.get('*', (req, res) => {
let app = 'dev'
let title = 'fireedge'
const context = {}
let store = ''
let component = ''
let css = ''
let storeRender = ''
let chunks = ''
const appName = defaultAppName? `/${defaultAppName}` : ''
if (env && (!env.NODE_ENV || (env.NODE_ENV && env.NODE_ENV !== defaultWebpackMode))) {
const apps = Object.keys(defaultApps)
const parseUrl = req.url.split(/\//gi).filter(sub => sub && sub.length > 0)
parseUrl.forEach(element => {
if(element && apps.includes(element)){
app = element
return
}
});
chunks = `<script src='${appName}/client/1.bundle.${app}.js'></script>`
const composeEnhancer =
// eslint-disable-next-line no-underscore-dangle
(root && root.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
store = createStore(rootReducer(), composeEnhancer(applyMiddleware(thunk)))
storeRender = `<script id="preloadState">window.__PRELOADED_STATE__ = ${JSON.stringify(
store.getState()
).replace(/</g, '\\u003c')}</script>`
// eslint-disable-next-line global-require
if (env && (!env.NODE_ENV || (env.NODE_ENV && env.NODE_ENV !== defaultWebpackMode))) {
const App = require('../../../client/app').default
const sheets = new ServerStyleSheets()
const composeEnhancer = (root && root.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
const apps = Object.keys(defaultApps)
const parseUrl = req.url.split(/\//gi).filter(sub => sub && sub.length > 0)
parseUrl.forEach(element => {
if (element && apps.includes(element)) {
app = element
title = element
}
})
chunks = `<script src='${APP_URL}/client/1.bundle.${app}.js'></script>`
store = createStore(rootReducer(), composeEnhancer(applyMiddleware(thunk)))
storeRender = `<script id="preloadState">window.__PRELOADED_STATE__ = ${
JSON.stringify(store.getState()).replace(/</g, '\\u003c')
}</script>`
component = renderToString(
sheets.collect(<App location={req.url} context={context} store={store} />)
sheets.collect(
<App location={req.url} context={context} store={store} />
)
)
css = `<style id="jss-server-side">${sheets.toString()}</style>`
}
const html = `
<!DOCTYPE html>
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel='shortcut icon' type='image/png' href='/client/assets/favicon.png' />
<title>${capitalize(title)} by OpenNebula</title>
<link rel="icon" type="image/png" href="${STATIC_FILES_URL}/favicon/${app}/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="${STATIC_FILES_URL}/favicon/${app}/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="${STATIC_FILES_URL}/favicon/${app}/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="${STATIC_FILES_URL}/favicon/${app}/favicon-16x16.png">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
${css}
@@ -73,7 +87,7 @@ router.get('*', (req, res) => {
<div id="root">${component}</div>
${storeRender}
<script>${`langs = ${JSON.stringify(scriptLanguages)}`}</script>
<script src='${appName}/client/bundle.${app}.js'></script>
<script src='${APP_URL}/client/bundle.${app}.js'></script>
${chunks}
</body>
</html>