amelioration page auteur
This commit is contained in:
parent
cff3738dc9
commit
a190aab20d
@ -57,6 +57,7 @@ $('#serie').click(function() {
|
||||
});
|
||||
$.each(['book','author','serie'], function (i, elt) {
|
||||
$('#'+elt).click(function() {
|
||||
window.location.hash=elt='s';
|
||||
url = '/'+elt;
|
||||
loadItems();
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var paginate = require('../util/paginate');
|
||||
var HashMap = require('hashmap').HashMap;
|
||||
|
||||
/* All authors */
|
||||
router.get('/', function(req, res) {
|
||||
@ -24,9 +25,11 @@ router.get('/:id', function(req, res) {
|
||||
var author;
|
||||
var books = new Array();
|
||||
var authors = new Array();
|
||||
var series = new HashMap();
|
||||
var respond = function() {
|
||||
author.books = books;
|
||||
author.coauthors = authors;
|
||||
if (books.length>0) author.books = books;
|
||||
if (series.count()>0) author.series = series.values();
|
||||
if (authors.length>0) author.coauthors = authors;
|
||||
res.format({
|
||||
html: function(){
|
||||
author.title = author.name;
|
||||
@ -46,29 +49,41 @@ router.get('/:id', function(req, res) {
|
||||
' LEFT OUTER JOIN series ON books_series_link.series = series.id'+
|
||||
' WHERE books_authors_link.author = ?'+
|
||||
' ORDER BY author_id', req.params.id,
|
||||
function(err, row) {
|
||||
books.push(row);
|
||||
booksIds.push(row.id);
|
||||
function(err, book) {
|
||||
books.push(book);
|
||||
if (book.series_id) {
|
||||
book.serie = { id: book.series_id, name: book.series_name};
|
||||
series.set(''+book.serie.id, book.serie);
|
||||
}
|
||||
delete book.series_id;
|
||||
delete book.series_name;
|
||||
booksIds.push(book.id);
|
||||
},
|
||||
function(err) {
|
||||
if (err) console.log(err);
|
||||
if (!err && books.length>0) {
|
||||
var autQuery = 'SELECT authors.id AS id,authors.name AS name'+
|
||||
' FROM authors LEFT OUTER JOIN books_authors_link ON authors.id = books_authors_link.author'+
|
||||
' WHERE books_authors_link.book IN (';
|
||||
for (var i=0; i<booksIds.length-1; i++) autQuery+='?, ';
|
||||
autQuery+='?)';
|
||||
autQuery+='?) ORDER BY id';
|
||||
req.db.each(autQuery, booksIds,
|
||||
function(err, autRow) {
|
||||
if (autRow.id == req.params.id)
|
||||
author = autRow;
|
||||
else
|
||||
else {
|
||||
if (authors.length == 0 || authors[authors.length-1].id != autRow.id)
|
||||
authors.push(autRow);
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
if (err) console.log(err);
|
||||
respond();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
respond();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -20,11 +20,18 @@ block content
|
||||
li
|
||||
a(href='/book/'+book.id)
|
||||
= book.title+' '
|
||||
if book.series_name
|
||||
if book.serie
|
||||
span.glyphicon.glyphicon-list
|
||||
a(href='/serie/'+book.series_id)
|
||||
= ' '+book.series_name+' ('+book.series_index+')'
|
||||
if coauthors.length > 0
|
||||
a(href='/serie/'+book.serie.id)
|
||||
= ' '+book.serie.name+' ('+book.series_index+')'
|
||||
if series
|
||||
h2
|
||||
span.glyphicon.glyphicon-list
|
||||
| Series
|
||||
ul
|
||||
each serie in series
|
||||
li: a(href='/serie/'+serie.id)= ' '+serie.name
|
||||
if coauthors
|
||||
h2
|
||||
span.glyphicon.glyphicon-user
|
||||
| Co-Auteur(s)
|
||||
|
Loading…
Reference in New Issue
Block a user