From 9e9737902f2b0ee089e7645ea3a06fb81670dd06 Mon Sep 17 00:00:00 2001 From: Antoine WEBER Date: Tue, 15 Sep 2015 18:34:50 +0200 Subject: [PATCH] ajout de la page de presentation --- app.js | 13 +++++++------ routes/file.js | 10 ---------- routes/movie.js | 29 +++++++++++++++++++++++++++++ views/channel.jade | 2 +- views/movie.jade | 29 +++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 routes/movie.js create mode 100644 views/movie.jade diff --git a/app.js b/app.js index 8636034..f33c838 100644 --- a/app.js +++ b/app.js @@ -5,10 +5,10 @@ var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); -var routes = require('./routes/index'); +/*var routes = require('./routes/index'); var users = require('./routes/users'); var file = require('./routes/file'); -var channel = require('./routes/channel'); +var channel = require('./routes/channel');*/ var app = express(); @@ -24,10 +24,11 @@ app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); -app.use('/', routes); -app.use('/users', users); -app.use('/file', file); -app.use('/channel', channel); +app.use('/', require('./routes/index')); +app.use('/users', require('./routes/users')); +app.use('/file', require('./routes/file')); +app.use('/channel', require('./routes/channel')); +app.use('/movie', require('./routes/movie')); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/routes/file.js b/routes/file.js index 42de058..b5ecc9a 100644 --- a/routes/file.js +++ b/routes/file.js @@ -42,16 +42,6 @@ router.get('/:id/:filename', function (req, res, next) { db.close(); - - - - - - - - - - }) module.exports = router; diff --git a/routes/movie.js b/routes/movie.js new file mode 100644 index 0000000..749713d --- /dev/null +++ b/routes/movie.js @@ -0,0 +1,29 @@ +var express = require('express'); +var router = express.Router(); + +/* GET home page. */ +router.get('/:id', function(req, res, next) { + + var config = require('../config'); + var db = config.init_db(); + + var data; + + db.get("SELECT id,title,original_title,studio,rating,summary,duration,tags_genre,tags_star,year FROM metadata_items WHERE id = ?",req.params.id, function(err, row) { + + row.tags_genre = row.tags_genre.split('|'); + row.tags_star = row.tags_star.split('|'); + row.rating = Math.round(row.rating,2); + data = row; + + res.render('movie', { title: 'Détail vidéo',movie: data }); + + }); + + db.close(); + + + +}); + +module.exports = router; diff --git a/views/channel.jade b/views/channel.jade index da63217..c14d960 100644 --- a/views/channel.jade +++ b/views/channel.jade @@ -15,7 +15,7 @@ block content each video, i in videos tr td - a(href="/file/#{video.id}/#{video.filename}")= video.title + a(href="/movie/#{video.id}")= video.title if(channel.type == 2) td if(typeof video.info_meta !== 'undefined' && typeof video.info_meta.show !== 'undefined') diff --git a/views/movie.jade b/views/movie.jade new file mode 100644 index 0000000..a90dcd6 --- /dev/null +++ b/views/movie.jade @@ -0,0 +1,29 @@ +extends layout + +block content + h1= movie.title + + label Note + p= movie.rating + + label Télécharger + a(href="/file/#{movie.id}/#{movie.title}")= movie.title + br + + label Résumé + p= movie.summary + br + + label Genre + each tag, i in movie.tags_genre + if(tag!='') + span= tag + |   + br + + label Acteurs + each tag, i in movie.tags_star + if(tag!='') + span= tag + |   + br