diff --git a/.gitignore b/.gitignore
index 83cab31..fc926cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
config.js
+nodes_modules
nodes_modules/*
diff --git a/app.js b/app.js
index 3ad1022..8636034 100644
--- a/app.js
+++ b/app.js
@@ -8,6 +8,7 @@ var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var file = require('./routes/file');
+var channel = require('./routes/channel');
var app = express();
@@ -26,6 +27,7 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', users);
app.use('/file', file);
+app.use('/channel', channel);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
diff --git a/routes/index.js b/routes/index.js
index d5e09bf..1ecfa0c 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -7,25 +7,7 @@ router.get('/', function(req, res, next) {
var config = require('../config');
var db = config.init_db();
- var html = "
"
- +""
- +""
- +""
- +""
- +""
-
-
- +"
liste des fichiers
"
- + '
'
- + ' '
- + '
'
- + '
Nom
'
- + '
Durée
'
- + '
Année
'
- + '
'
- + ' '
- + ' ';
-
+ var data = [];
//on fais toute les opération de base a la suite
db.serialize(function() {
@@ -36,28 +18,18 @@ router.get('/', function(req, res, next) {
//}
//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 ORDER BY i.title ASC", function(err, row) {
- var tab = row.file.split('/');
- var tab2 = tab[tab.length -1].split('\\');
- var filename = tab2[tab2.length -1];
- if(row.title != '')
- html += "
";
+ db.each("SELECT id, name"
+ + " FROM library_sections ORDER BY name ASC", function(err, row) {
+ data.push(row);
},
//aprés toute les opération de la base
function() {
- // All done fetching records, render response
- html += "
";
- res.end(html);
+ res.render('index', { title: 'Liste des channel',channels: data });
});
});
db.close();
- //res.render('index', { title: 'Express' });
});
module.exports = router;
diff --git a/views/index.jade b/views/index.jade
index 3d63b9a..50b248f 100644
--- a/views/index.jade
+++ b/views/index.jade
@@ -2,4 +2,8 @@ extends layout
block content
h1= title
- p Welcome to #{title}
+
+ ul
+ each channel, i in channels
+ li
+ a(href="/channel/#{channel.id}")= channel.name
diff --git a/views/layout.jade b/views/layout.jade
index 15af079..a01e47d 100644
--- a/views/layout.jade
+++ b/views/layout.jade
@@ -2,6 +2,11 @@ doctype html
html
head
title= title
- link(rel='stylesheet', href='/stylesheets/style.css')
+ meta(charset='UTF8')
+ link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css')
+ link(rel='stylesheet', href='//cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css')
+ script(type='text/javascript', src='//code.jquery.com/jquery-1.11.3.min.js')
+ script(type='text/javascript', src='//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js')
+ script(type='text/javascript', src='//cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js')
body
block content