From 3762a7ae45a545183705264f5c380150bf913140 Mon Sep 17 00:00:00 2001 From: WEBER Antoine Date: Thu, 24 Sep 2015 01:05:13 +0200 Subject: [PATCH] trie des saisons --- routes/show.js | 25 +++++++++++++++---------- views/show.jade | 18 ++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/routes/show.js b/routes/show.js index 4d1ff7c..8b68778 100644 --- a/routes/show.js +++ b/routes/show.js @@ -20,13 +20,21 @@ router.get('/:id', function(req, res, next) { var config = require('../config'); var db = config.init_db(); var data = []; + var show; //on fais toute les opération de base a la suite db.serialize(function() { - db.each("SELECT i.id as id, i.title as title, i.duration as second, i.year as year" - + " FROM metadata_items i " - + " WHERE t.metadata_item_id = i.id AND i.parent_id = ? ",req.params.id, function(err, row) { + db.get("SELECT id, title, year" + + " FROM metadata_items " + + " WHERE id = ? " + ,req.params.id, function(err, row) { + shows = row; + }); + + db.each("SELECT episode.id as , episode.title as titre, episode.'index' as episode, season.'index' as saison "+ + "FROM metadata_items episode,metadata_items season,metadata_items show "+ + "WHERE episode.parent_id=season.id AND season.parent_id = show.id AND show.id = ? ",req.params.id, function(err, row) { console.log(err); console.log(row); /*//découpage des hints @@ -40,20 +48,17 @@ router.get('/:id', function(req, res, next) { if(typeof row.info_meta !== 'undefined' && typeof row.info_meta.season !== 'undefined' && typeof row.info_meta.episode !== 'undefined'){ row.season_episode = "S"+addZero(row.info_meta.season)+"E"+addZero(row.info_meta.episode); - }*/ + } - row.duree = formatDuree(row.second); + row.duree = formatDuree(row.second);*/ data.push(row); }, //aprés toute les opération de la base function() { res.render('show',{ - title: 'Episode de '+req.params.id, - channel: { - 'name': 'Episode de '+req.params.id, - 'type': 2 - }, + title: 'Episode de '+show.title, + show: show, videos: data }); }); diff --git a/views/show.jade b/views/show.jade index c52ddae..75e2c62 100644 --- a/views/show.jade +++ b/views/show.jade @@ -1,31 +1,25 @@ extends layout block content - h1= channel.name + h1= show.title table(id="example", class="table table-striped table-bordered", cellspacing="0", width="100%") thead tr th Nom - th Série - th Saison & Episode + th Saison + th Episode th Durée th Année - th Taille tbody each video, i in videos tr td - a(href="/movie/#{video.id}")= video.title - td - if(typeof video.info_meta !== 'undefined' && typeof video.info_meta.show !== 'undefined') - | #{video.info_meta.show} - td - if(typeof video.season_episode !== 'undefined') - | #{video.season_episode} + a(href="/movie/#{video.id}")= video.titre + td= video.saison + td= video.episode td= video.duree td= video.year - td= video.size script. $(document).ready(function() { $('#example').DataTable({