ajout page de channel

This commit is contained in:
Antoine WEBER 2015-09-15 10:41:00 +02:00
parent eeefc2e23c
commit cdf738cb40
2 changed files with 65 additions and 0 deletions

43
routes/channel.js Normal file
View File

@ -0,0 +1,43 @@
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 = [];
//on fais toute les opération de base a la suite
db.serialize(function() {
//db.run("CREATE TABLE if not exists user_info (info TEXT)");
//var stmt = db.prepare("INSERT INTO user_info VALUES (?)");
//for (var i = 0; i < 10; i++) {
// stmt.run("Ipsum " + i);
//}
//stmt.finalize();
db.each("SELECT i.id as id, i.title as title, p.file as file, i.duration as second, i.year as year"
+ " FROM metadata_items i, media_parts p "
+ " WHERE p.media_item_id=i.id AND i.library_section_id = ? "
+ " ORDER BY i.title ASC",req.params.id, function(err, row) {
var tab = row.file.split('/');
var tab2 = tab[tab.length -1].split('\\');
var filename = tab2[tab2.length -1];
if(row.title != ''){
row.filename = filename;
data.push(row);
}
},
//aprés toute les opération de la base
function() {
res.render('channel', { title: 'Liste des vidéos',videos: data });
});
});
db.close();
});
module.exports = router;

22
views/channel.jade Normal file
View File

@ -0,0 +1,22 @@
extends layout
block content
h1= title
table(id="example", class="table table-striped table-bordered", cellspacing="0", width="100%")
thead
tr
th Nom
th Durée
th Année
tbody
each video, i in videos
tr
td
a(href="/file/#{video.id}/#{video.filename}")= video.title
td= video.second
td= video.year
script.
$(document).ready(function() {
$('#example').DataTable();
});