1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-07 14:35:26 +02:00

Added checking favicon before uploading function, removed passing locals to views

This commit is contained in:
slaveeks 2022-07-07 11:08:35 +03:00
parent 2712378370
commit f1fa35564c
7 changed files with 20 additions and 21 deletions

View file

@ -24,6 +24,8 @@ app.set('views', path.join(__dirname, './', 'views'));
app.set('view engine', 'twig');
require('./utils/twig');
// Check if favicon is not empty
if (favicon) {
// Upload favicon by url, it's path on server is '/temp/favicon.{format}'
downloadFavicon(favicon).then((res) => {
app.locals.favicon = res;
@ -33,6 +35,9 @@ downloadFavicon(favicon).then((res) => {
console.log(err);
console.log('Favicon has not uploaded');
});
} else {
console.log('Favicon is empty');
}
app.use(morgan('dev'));
app.use(express.json());

View file

@ -36,7 +36,6 @@ router.get('*', verifyToken, async (req: Request, res: Response) => {
page,
pageParent,
config: req.app.locals.config,
favicon: req.app.locals.favicon,
});
}
}

View file

@ -28,7 +28,6 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Password not set',
csrfToken: req.csrfToken(),
favicon: req.app.locals.favicon,
});
return;
@ -39,7 +38,6 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Wrong password',
csrfToken: req.csrfToken(),
favicon: req.app.locals.favicon,
});
return;
@ -62,7 +60,6 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Password not set',
csrfToken: req.csrfToken(),
favicon: req.app.locals.favicon
});
return;

View file

@ -10,8 +10,7 @@ router.get('/', verifyToken, async (req: Request, res: Response) => {
if (config.startPage) {
return res.redirect(config.startPage);
}
res.render('pages/index', { isAuthorized: res.locals.isAuthorized,
favicon: req.app.locals.favicon });
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
});
export default router;

View file

@ -45,7 +45,6 @@ router.get('/page/edit/:id', verifyToken, allowEdit, async (req: Request, res: R
page,
parentsChildrenOrdered,
pagesAvailable,
favicon: req.app.locals.favicon,
});
} catch (error) {
res.status(404);
@ -67,8 +66,6 @@ router.get('/page/:id', verifyToken, async (req: Request, res: Response, next: N
res.render('pages/page', {
page,
pageParent,
config: req.app.locals.config,
favicon: req.app.locals.favicon,
});
} catch (error) {
res.status(404);

View file

@ -10,6 +10,8 @@
<meta property="og:site_name" content="{{ config.title }}" />
<meta name="description" property="og:description" content="{{ config.description }}">
</head>
<script>
</script>
<body class="landing-body">
{% include "components/header.twig" %}
<div class="landing-loader" id="frame-loader">