simple page for single author/book/serie

This commit is contained in:
Meutel 2014-06-18 22:51:41 +02:00
parent 1dc5e529be
commit 07f30c6767
7 changed files with 44 additions and 4 deletions

View File

@ -38,7 +38,7 @@ function loadItems() {
$.each( data, function(i, elt ) {
var item = "<tr id='" + elt.id + "'>";
$.each(cols, function(icol, col) {
item+="<td>"+elt[col]+"</td>";
item+="<td><a href=\""+url+"/"+elt.id+"\">"+elt[col]+"</a></td>";
});
item += "</tr>";
items.push(item);

View File

@ -21,7 +21,15 @@ router.get('/', function(req, res) {
/* Single author */
router.get('/:id', function(req, res) {
req.db.get('SELECT * FROM authors WHERE id = ?', req.params.id, function(err, row) {
res.json(row);
res.format({
html: function(){
row.title = row.name;
res.render('author', row);
},
json: function(){
res.json(row);
}
});
});
});

View File

@ -21,7 +21,14 @@ router.get('/', function(req, res) {
/* Single book */
router.get('/:id', function(req, res) {
req.db.get('SELECT * FROM books WHERE id = ?', req.params.id, function(err, row) {
res.json(row);
res.format({
html: function(){
res.render('book', row);
},
json: function(){
res.json(row);
}
});
});
});

View File

@ -21,7 +21,15 @@ router.get('/', function(req, res) {
/* Single serie */
router.get('/:id', function(req, res) {
req.db.get('SELECT * FROM series WHERE id = ?', req.params.id, function(err, row) {
res.json(row);
res.format({
html: function(){
row.title = row.name;
res.render('serie', row);
},
json: function(){
res.json(row);
}
});
});
});

5
views/author.jade Normal file
View File

@ -0,0 +1,5 @@
extends layout
block content
h1 Auteur
h2= name

7
views/book.jade Normal file
View File

@ -0,0 +1,7 @@
extends layout
block content
h1 Titre
h2= title
h1 Auteur
h2= author_sort

5
views/serie.jade Normal file
View File

@ -0,0 +1,5 @@
extend layout
block content
h1 Serie
h2= name