simple page for single author/book/serie
This commit is contained in:
parent
1dc5e529be
commit
07f30c6767
@ -38,7 +38,7 @@ function loadItems() {
|
|||||||
$.each( data, function(i, elt ) {
|
$.each( data, function(i, elt ) {
|
||||||
var item = "<tr id='" + elt.id + "'>";
|
var item = "<tr id='" + elt.id + "'>";
|
||||||
$.each(cols, function(icol, col) {
|
$.each(cols, function(icol, col) {
|
||||||
item+="<td>"+elt[col]+"</td>";
|
item+="<td><a href=\""+url+"/"+elt.id+"\">"+elt[col]+"</a></td>";
|
||||||
});
|
});
|
||||||
item += "</tr>";
|
item += "</tr>";
|
||||||
items.push(item);
|
items.push(item);
|
||||||
|
@ -21,7 +21,15 @@ router.get('/', function(req, res) {
|
|||||||
/* Single author */
|
/* Single author */
|
||||||
router.get('/:id', function(req, res) {
|
router.get('/:id', function(req, res) {
|
||||||
req.db.get('SELECT * FROM authors WHERE id = ?', req.params.id, function(err, row) {
|
req.db.get('SELECT * FROM authors WHERE id = ?', req.params.id, function(err, row) {
|
||||||
|
res.format({
|
||||||
|
html: function(){
|
||||||
|
row.title = row.name;
|
||||||
|
res.render('author', row);
|
||||||
|
},
|
||||||
|
json: function(){
|
||||||
res.json(row);
|
res.json(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,7 +21,14 @@ router.get('/', function(req, res) {
|
|||||||
/* Single book */
|
/* Single book */
|
||||||
router.get('/:id', function(req, res) {
|
router.get('/:id', function(req, res) {
|
||||||
req.db.get('SELECT * FROM books WHERE id = ?', req.params.id, function(err, row) {
|
req.db.get('SELECT * FROM books WHERE id = ?', req.params.id, function(err, row) {
|
||||||
|
res.format({
|
||||||
|
html: function(){
|
||||||
|
res.render('book', row);
|
||||||
|
},
|
||||||
|
json: function(){
|
||||||
res.json(row);
|
res.json(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,7 +21,15 @@ router.get('/', function(req, res) {
|
|||||||
/* Single serie */
|
/* Single serie */
|
||||||
router.get('/:id', function(req, res) {
|
router.get('/:id', function(req, res) {
|
||||||
req.db.get('SELECT * FROM series WHERE id = ?', req.params.id, function(err, row) {
|
req.db.get('SELECT * FROM series WHERE id = ?', req.params.id, function(err, row) {
|
||||||
|
res.format({
|
||||||
|
html: function(){
|
||||||
|
row.title = row.name;
|
||||||
|
res.render('serie', row);
|
||||||
|
},
|
||||||
|
json: function(){
|
||||||
res.json(row);
|
res.json(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
5
views/author.jade
Normal file
5
views/author.jade
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
h1 Auteur
|
||||||
|
h2= name
|
7
views/book.jade
Normal file
7
views/book.jade
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
h1 Titre
|
||||||
|
h2= title
|
||||||
|
h1 Auteur
|
||||||
|
h2= author_sort
|
5
views/serie.jade
Normal file
5
views/serie.jade
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extend layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
h1 Serie
|
||||||
|
h2= name
|
Loading…
Reference in New Issue
Block a user