removed dead code serveOrShowAsset()
This commit is contained in:
parent
0142c168ae
commit
8e34abd357
1 changed files with 10 additions and 37 deletions
|
@ -1,42 +1,7 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const SERVE = 'SERVE';
|
|
||||||
const SHOW = 'SHOW';
|
|
||||||
const SHOWLITE = 'SHOWLITE';
|
|
||||||
// const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
// const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||||
|
|
||||||
function createOpenGraphInfo ({ claimId, name, fileExt }) {
|
|
||||||
return {
|
|
||||||
embedUrl : `https://spee.ch/embed/${claimId}/${name}`,
|
|
||||||
showUrl : `https://spee.ch/${claimId}/${name}`,
|
|
||||||
source : `https://spee.ch/${claimId}/${name}.${fileExt}`,
|
|
||||||
directFileUrl: `https://spee.ch/${claimId}/${name}.${fileExt}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
serveOrShowAsset (method, fileInfo, claimInfo, shortId, res) {
|
|
||||||
// add file extension to the file info
|
|
||||||
if (fileInfo.fileName) {
|
|
||||||
claimInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.') + 1);
|
|
||||||
} else {
|
|
||||||
claimInfo['fileExt'] = null;
|
|
||||||
}
|
|
||||||
// serve or show
|
|
||||||
switch (method) {
|
|
||||||
case SERVE:
|
|
||||||
module.exports.serveFile(fileInfo, claimInfo, shortId, res);
|
|
||||||
return fileInfo;
|
|
||||||
case SHOWLITE:
|
|
||||||
module.exports.showFileLite(fileInfo, claimInfo, shortId, res);
|
|
||||||
return fileInfo;
|
|
||||||
case SHOW:
|
|
||||||
module.exports.showFile(fileInfo, claimInfo, shortId, res);
|
|
||||||
return fileInfo;
|
|
||||||
default:
|
|
||||||
logger.error('I did not recognize that method');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
serveFile ({ filePath }, { claimId, name, contentType }, res) {
|
serveFile ({ filePath }, { claimId, name, contentType }, res) {
|
||||||
logger.verbose(`serving ${name}#${claimId}`);
|
logger.verbose(`serving ${name}#${claimId}`);
|
||||||
// set response options
|
// set response options
|
||||||
|
@ -56,11 +21,19 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showFile (claimInfo, shortId, res) {
|
showFile (claimInfo, shortId, res) {
|
||||||
const openGraphInfo = createOpenGraphInfo(claimInfo);
|
const openGraphInfo = module.exports.createOpenGraphInfo(claimInfo);
|
||||||
res.status(200).render('show', { layout: 'show', claimInfo, shortId, openGraphInfo });
|
res.status(200).render('show', { layout: 'show', claimInfo, shortId, openGraphInfo });
|
||||||
},
|
},
|
||||||
showFileLite (claimInfo, shortId, res) {
|
showFileLite (claimInfo, shortId, res) {
|
||||||
const openGraphInfo = createOpenGraphInfo(claimInfo);
|
const openGraphInfo = module.exports.createOpenGraphInfo(claimInfo);
|
||||||
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId, openGraphInfo });
|
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId, openGraphInfo });
|
||||||
},
|
},
|
||||||
|
createOpenGraphInfo ({ claimId, name, fileExt }) {
|
||||||
|
return {
|
||||||
|
embedUrl : `https://spee.ch/embed/${claimId}/${name}`,
|
||||||
|
showUrl : `https://spee.ch/${claimId}/${name}`,
|
||||||
|
source : `https://spee.ch/${claimId}/${name}.${fileExt}`,
|
||||||
|
directFileUrl: `https://spee.ch/${claimId}/${name}.${fileExt}`,
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue