This commit is contained in:
WEBER Antoine 2015-10-13 22:48:14 +02:00
commit 248723b698
9 changed files with 111 additions and 10 deletions

1
app.js
View File

@ -52,6 +52,7 @@ app.use('/channel', require('./routes/channel'));
app.use('/movie', require('./routes/movie'));
app.use('/show_list', require('./routes/show_list'));
app.use('/show', require('./routes/show'));
app.use('/divers', require('./routes/divers'));
// catch 404 and forward to error handler
app.use(function(req, res, next) {

69
routes/divers.js Normal file
View File

@ -0,0 +1,69 @@
var express = require('express');
var router = express.Router();
function secondsToString(seconds) {
seconds = Math.round(seconds);
var years = Math.floor(seconds / 31536000);
var max =2;
var current = 0;
var str = "";
if (years && current<max) {
str+= years + 'y ';
current++;
}
var days = Math.floor((seconds %= 31536000) / 86400);
if (days && current<max) {
str+= days + 'd ';
current++;
}
var hours = Math.floor((seconds %= 86400) / 3600);
if (hours && current<max) {
str+= hours + 'h ';
current++;
}
var minutes = Math.floor((seconds %= 3600) / 60);
if (minutes && current<max) {
str+= minutes + 'm ';
current++;
}
var seconds = seconds % 60;
if (seconds && current<max) {
str+= seconds + 's ';
current++;
}
return str;
}
/* GET home page. */
router.get('/', function(req, res, next) {
var config = res.locals.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 id, name, section_type as type"
+ " FROM library_sections ORDER BY name ASC", function(err, row) {
data.push(row);
},
//aprés toute les opération de la base
function() {*/
res.render('divers', { title: 'Divers',/*channels: data,*/ presentation: config.presentation, uptime: secondsToString(process.uptime()) });
/*});
});
db.close();*/
});
module.exports = router;

View File

@ -16,7 +16,7 @@ function addZero(v) {
};
/* GET home page. */
router.get('/:id', function(req, res, next) {
router.get('/:id/:incoming_chan', function(req, res, next) {
var config = res.locals.config;
var db = config.init_db();
var data = [];
@ -58,7 +58,9 @@ router.get('/:id', function(req, res, next) {
}
res.render('show',{
title: titre,
videos: data
videos: data,
channel_id: req.params.incoming_chan,
show_id: req.params.id
});
});

View File

@ -20,7 +20,7 @@ router.get('/:id', function(req, res, next) {
//aprés toute les opération de la base
function(){
console.log(shows);
res.render('show_list', { title: 'Liste des séries',shows: shows });
res.render('show_list', { title: 'Liste des séries',shows: shows, channel_id: req.params.id });
});
});

View File

@ -13,7 +13,7 @@ block content
each video, i in videos
tr
td
a(href="/movie/#{video.id}")= video.title
a(href="/movie/#{video.id}") #{video.title}&nbsp;
td= video.duree
td= video.year
script.

21
views/divers.jade Normal file
View File

@ -0,0 +1,21 @@
extends layout
block content
h1= title
| Ce serveur http est open-source
br
br
| Venez participer au developpement ici:
br
br
a(href="https://github.com/TwanoO67/plex-web-downloader") GitHub
br
br
| Le serveur tourne depuis #{uptime}
br
br

View File

@ -3,26 +3,30 @@ extends layout
block content
h1= movie.title
a(href="#",onclick="window.history.back();") Retour à la liste
br
br
label Note
p= movie.rating
label Télécharger
br
each file, i in movie.file
a(href="/file/#{file.id}/#{file.filename}") #{file.size} #{file.filename}
a(href="/file/#{file.id}/#{file.filename}") #{file.size} #{file.filename}
br
br
label Résumé
p= movie.summary
br
br
label Genre
each tag, i in movie.tags_genre
if(tag!='')
span= tag
| &nbsp;
br
br
label Acteurs
each tag, i in movie.tags_star
if(tag!='')

View File

@ -3,6 +3,10 @@ extends layout
block content
h1= title
a(href="/show_list/#{channel_id}") Retour à la liste des séries
br
br
table(id="example", class="table table-striped table-bordered", cellspacing="0", width="100%")
thead
tr
@ -13,7 +17,7 @@ block content
each video, i in videos
tr
td
a(href="/movie/#{video.id}")= video.titre
a(href="/movie/#{video.id}") #{video.titre}&nbsp;
td= video.season_episode
td= video.duree
script.

View File

@ -12,7 +12,7 @@ block content
each show, i in shows
tr
td
a(href="/show/#{show.id}")= show.title
a(href="/show/#{show.id}/#{channel_id}")= show.title
td= show.year
script.
$(document).ready(function() {