From feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 11 Dec 2016 21:50:51 +0100 Subject: First version with PostgreSQL --- server/controllers/client.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'server/controllers/client.js') diff --git a/server/controllers/client.js b/server/controllers/client.js index 572db6133..a5fac5626 100644 --- a/server/controllers/client.js +++ b/server/controllers/client.js @@ -3,13 +3,12 @@ const parallel = require('async/parallel') const express = require('express') const fs = require('fs') -const mongoose = require('mongoose') const path = require('path') const validator = require('express-validator').validator const constants = require('../initializers/constants') +const db = require('../initializers/database') -const Video = mongoose.model('Video') const router = express.Router() const opengraphComment = '' @@ -45,14 +44,14 @@ function addOpenGraphTags (htmlStringPage, video) { if (video.isOwned()) { basePreviewUrlHttp = constants.CONFIG.WEBSERVER.URL } else { - basePreviewUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podHost + basePreviewUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.Author.Pod.host } // We fetch the remote preview (bigger than the thumbnail) // This should not overhead the remote server since social websites put in a cache the OpenGraph tags // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example) const previewUrl = basePreviewUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName() - const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' + video._id + const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' + video.id const metaTags = { 'og:type': 'video', @@ -86,7 +85,7 @@ function generateWatchHtmlPage (req, res, next) { const videoId = req.params.id // Let Angular application handle errors - if (!validator.isMongoId(videoId)) return res.sendFile(indexPath) + if (!validator.isUUID(videoId, 4)) return res.sendFile(indexPath) parallel({ file: function (callback) { @@ -94,7 +93,7 @@ function generateWatchHtmlPage (req, res, next) { }, video: function (callback) { - Video.load(videoId, callback) + db.Video.loadAndPopulateAuthorAndPod(videoId, callback) } }, function (err, results) { if (err) return next(err) -- cgit v1.2.3 From 7920c273a204e2469416a30b752b12ccd3160102 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 24 Dec 2016 16:59:17 +0100 Subject: Move tags in another table --- server/controllers/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/controllers/client.js') diff --git a/server/controllers/client.js b/server/controllers/client.js index a5fac5626..8c242af07 100644 --- a/server/controllers/client.js +++ b/server/controllers/client.js @@ -93,7 +93,7 @@ function generateWatchHtmlPage (req, res, next) { }, video: function (callback) { - db.Video.loadAndPopulateAuthorAndPod(videoId, callback) + db.Video.loadAndPopulateAuthorAndPodAndTags(videoId, callback) } }, function (err, results) { if (err) return next(err) -- cgit v1.2.3