build the handlebars template and serve/show route fork
This commit is contained in:
parent
5cd3c6ef9d
commit
d4560905ed
5 changed files with 54 additions and 4 deletions
|
@ -32,7 +32,17 @@ function serveFile ({ fileName, fileType, filePath }, res) {
|
||||||
res.status(200).sendFile(filePath, options);
|
res.status(200).sendFile(filePath, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function servePage ({ fileName, fileType, filePath }, res) {
|
||||||
|
logger.info(`serving show page for ${fileName}`);
|
||||||
|
// set default options
|
||||||
|
let showOptions;
|
||||||
|
|
||||||
|
// send file
|
||||||
|
res.status(200).render('show', showOptions);
|
||||||
|
}
|
||||||
|
|
||||||
function sendAnalyticsAndLog (headers, ip, originalUrl) {
|
function sendAnalyticsAndLog (headers, ip, originalUrl) {
|
||||||
|
logger.verbose('headers', headers);
|
||||||
// google analytics
|
// google analytics
|
||||||
sendGoogleAnalytics('serve', headers, ip, originalUrl);
|
sendGoogleAnalytics('serve', headers, ip, originalUrl);
|
||||||
// logging
|
// logging
|
||||||
|
@ -52,8 +62,15 @@ module.exports = (app) => {
|
||||||
res.status(307).render('noClaims');
|
res.status(307).render('noClaims');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postToStats('serve', originalUrl, ip, 'success');
|
// serve the file or the show route
|
||||||
serveFile(fileInfo, res);
|
const mimetypes = headers['accept'].split(',');
|
||||||
|
if (mimetypes.includes('text/html')) {
|
||||||
|
postToStats('show', originalUrl, ip, 'success');
|
||||||
|
servePage(fileInfo, res);
|
||||||
|
} else {
|
||||||
|
postToStats('serve', originalUrl, ip, 'success');
|
||||||
|
serveFile(fileInfo, res);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||||
|
@ -71,8 +88,15 @@ module.exports = (app) => {
|
||||||
res.status(307).render('noClaims');
|
res.status(307).render('noClaims');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postToStats('serve', originalUrl, ip, 'success');
|
// serve the file or the show route
|
||||||
serveFile(fileInfo, res);
|
const mimetypes = headers['accept'].split(',');
|
||||||
|
if (mimetypes.includes('text/html')) {
|
||||||
|
postToStats('show', originalUrl, ip, 'success');
|
||||||
|
servePage(fileInfo, res);
|
||||||
|
} else {
|
||||||
|
postToStats('serve', originalUrl, ip, 'success');
|
||||||
|
serveFile(fileInfo, res);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||||
|
|
4
views/partials/asset.handlebars
Normal file
4
views/partials/asset.handlebars
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="panel">
|
||||||
|
<p> asset goes here </p>
|
||||||
|
|
||||||
|
</div>
|
4
views/partials/assetLinks.handlebars
Normal file
4
views/partials/assetLinks.handlebars
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="panel">
|
||||||
|
<h2>links</h2>
|
||||||
|
<p>links go here</p>
|
||||||
|
</div>
|
4
views/partials/assetMetadata.handlebars
Normal file
4
views/partials/assetMetadata.handlebars
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="panel">
|
||||||
|
<h2>metadata</h2>
|
||||||
|
<p>metadata goes here</p>
|
||||||
|
</div>
|
14
views/show.handlebars
Normal file
14
views/show.handlebars
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<div class="wrapper">
|
||||||
|
{{> topBar}}
|
||||||
|
<div class="main">
|
||||||
|
{{> asset}}
|
||||||
|
</div>
|
||||||
|
<div class="sidebar">
|
||||||
|
{{> assetLinks}}
|
||||||
|
{{> assetMetadata}}
|
||||||
|
</div>
|
||||||
|
{{> footer}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/socket.io/socket.io.js"></script>
|
||||||
|
<script src="/siofu/client.js"></script>
|
Loading…
Add table
Reference in a new issue