From 188608818c1f7fe72c65e324c4c119a3c542083a Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sun, 20 Aug 2017 17:45:29 -0700 Subject: [PATCH] added title and description to db.Claim upsert and show page --- controllers/publishController.js | 16 +++++++++------- routes/serve-routes.js | 8 +++++++- views/partials/assetInfo.handlebars | 8 ++++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/controllers/publishController.js b/controllers/publishController.js index f6e84fac..431c3020 100644 --- a/controllers/publishController.js +++ b/controllers/publishController.js @@ -24,15 +24,17 @@ module.exports = { publishResults = result; logger.info(`Successfully published ${fileName}`, publishResults); fileRecord = { - name : publishParams.name, - claimId : publishResults.claim_id, - address : publishParams.claim_address, - outpoint: `${publishResults.txid}:${publishResults.nout}`, - height : 0, + name : publishParams.name, + claimId : publishResults.claim_id, + title : publishParams.metadata.title, + description: publishParams.metadata.description, + address : publishParams.claim_address, + outpoint : `${publishResults.txid}:${publishResults.nout}`, + height : 0, fileName, - filePath: publishParams.file_path, + filePath : publishParams.file_path, fileType, - nsfw : publishParams.metadata.nsfw, + nsfw : publishParams.metadata.nsfw, }; upsertCriteria = { name : publishParams.name, diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 487eb875..cfbab943 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -1,5 +1,5 @@ const logger = require('winston'); -const { serveFile, showFile, showFileLite, getShortIdFromClaimId } = require('../helpers/serveHelpers.js'); +const { serveFile, showFile, showFileLite, getShortIdFromClaimId, resolveAgainstClaimTable } = require('../helpers/serveHelpers.js'); const { getAssetByChannel, getAssetByShortId, getAssetByClaimId, getAssetByName } = require('../controllers/serveController.js'); const { handleRequestError } = require('../helpers/errorHandlers.js'); const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js'); @@ -48,6 +48,12 @@ function serveOrShowAsset (fileInfo, extension, method, headers, originalUrl, ip return getShortIdFromClaimId(fileInfo.claimId, fileInfo.height, fileInfo.name) .then(shortId => { fileInfo['shortId'] = shortId; + return resolveAgainstClaimTable(fileInfo.name, fileInfo.claimId); + }) + .then(resolveResult => { + logger.debug('resolve result', resolveResult); + fileInfo['title'] = resolveResult.title; + fileInfo['description'] = resolveResult.description; showFile(fileInfo, res); postToStats('show', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); return fileInfo; diff --git a/views/partials/assetInfo.handlebars b/views/partials/assetInfo.handlebars index ef223e89..6dd0a0e6 100644 --- a/views/partials/assetInfo.handlebars +++ b/views/partials/assetInfo.handlebars @@ -1,6 +1,6 @@
-

Name

-

{{fileInfo.name}} +

Title

+

{{fileInfo.title}}

{{/ifConditional}} +
+

Description

+

{{fileInfo.description}} +

Metadata