diff --git a/public/js/home.js b/public/js/home.js index 458031f..1fdb687 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -38,7 +38,7 @@ function loadItems() { $.each( data, function(i, elt ) { var item = ""; $.each(cols, function(icol, col) { - item+=""+elt[col]+""; + item+=""+elt[col]+""; }); item += ""; items.push(item); diff --git a/routes/author.js b/routes/author.js index 96db625..42ca92e 100644 --- a/routes/author.js +++ b/routes/author.js @@ -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); + } + }); }); }); diff --git a/routes/book.js b/routes/book.js index ab04e9f..f51faa6 100644 --- a/routes/book.js +++ b/routes/book.js @@ -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); + } + }); }); }); diff --git a/routes/serie.js b/routes/serie.js index f07917d..9b7eab6 100644 --- a/routes/serie.js +++ b/routes/serie.js @@ -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); + } + }); }); }); diff --git a/views/author.jade b/views/author.jade new file mode 100644 index 0000000..e9fd12b --- /dev/null +++ b/views/author.jade @@ -0,0 +1,5 @@ +extends layout + +block content + h1 Auteur + h2= name diff --git a/views/book.jade b/views/book.jade new file mode 100644 index 0000000..5430576 --- /dev/null +++ b/views/book.jade @@ -0,0 +1,7 @@ +extends layout + +block content + h1 Titre + h2= title + h1 Auteur + h2= author_sort diff --git a/views/serie.jade b/views/serie.jade new file mode 100644 index 0000000..0aff7a6 --- /dev/null +++ b/views/serie.jade @@ -0,0 +1,5 @@ +extend layout + +block content + h1 Serie + h2= name