build the handlebars template and serve/show route fork

This commit is contained in:
bill bittner 2017-07-05 12:23:55 -07:00
parent 5cd3c6ef9d
commit d4560905ed
5 changed files with 54 additions and 4 deletions

View file

@ -32,7 +32,17 @@ function serveFile ({ fileName, fileType, filePath }, res) {
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) {
logger.verbose('headers', headers);
// google analytics
sendGoogleAnalytics('serve', headers, ip, originalUrl);
// logging
@ -52,8 +62,15 @@ module.exports = (app) => {
res.status(307).render('noClaims');
return;
}
postToStats('serve', originalUrl, ip, 'success');
serveFile(fileInfo, res);
// serve the file or the show route
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 => {
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
@ -71,8 +88,15 @@ module.exports = (app) => {
res.status(307).render('noClaims');
return;
}
postToStats('serve', originalUrl, ip, 'success');
serveFile(fileInfo, res);
// serve the file or the show route
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 => {
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);

View file

@ -0,0 +1,4 @@
<div class="panel">
<p> asset goes here </p>
</div>

View file

@ -0,0 +1,4 @@
<div class="panel">
<h2>links</h2>
<p>links go here</p>
</div>

View file

@ -0,0 +1,4 @@
<div class="panel">
<h2>metadata</h2>
<p>metadata goes here</p>
</div>

14
views/show.handlebars Normal file
View 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>