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:
parent
2712378370
commit
f1fa35564c
7 changed files with 20 additions and 21 deletions
|
@ -24,15 +24,20 @@ app.set('views', path.join(__dirname, './', 'views'));
|
|||
app.set('view engine', 'twig');
|
||||
require('./utils/twig');
|
||||
|
||||
// Upload favicon by url, it's path on server is '/temp/favicon.{format}'
|
||||
downloadFavicon(favicon).then((res) => {
|
||||
// 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;
|
||||
console.log('Favicon successfully uploaded');
|
||||
})
|
||||
})
|
||||
.catch( (err) => {
|
||||
console.log(err);
|
||||
console.log('Favicon has not uploaded');
|
||||
});
|
||||
} else {
|
||||
console.log('Favicon is empty');
|
||||
}
|
||||
|
||||
app.use(morgan('dev'));
|
||||
app.use(express.json());
|
||||
|
|
|
@ -36,7 +36,6 @@ router.get('*', verifyToken, async (req: Request, res: Response) => {
|
|||
page,
|
||||
pageParent,
|
||||
config: req.app.locals.config,
|
||||
favicon: req.app.locals.favicon,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue