Merge branch 'master' of github.com:meutel/bouquins
This commit is contained in:
commit
dbb562386c
@ -42,6 +42,7 @@ var db = new sqlite3.Database(dbPath);
|
|||||||
|
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
req.db = db;
|
req.db = db;
|
||||||
|
req.locals = app.locals;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
{
|
{
|
||||||
"calibre_path": "./public/calibre",
|
"calibre_path": "./public/calibre",
|
||||||
"calibre_db_path": "./public/calibre/metadata.db",
|
"calibre_db_path": "./public/calibre/metadata.db",
|
||||||
"trust proxy": true
|
"trust proxy": true,
|
||||||
|
"book_details_custom": [
|
||||||
|
{
|
||||||
|
"name": "a_lire",
|
||||||
|
"query": "SELECT custom_columns.name AS label, custom_column_2.value AS value FROM custom_column_2 LEFT OUTER JOIN custom_columns ON custom_columns.id = 2 WHERE custom_column_2.book = ?",
|
||||||
|
"type": "bool"
|
||||||
|
}, {
|
||||||
|
"name": "phy",
|
||||||
|
"query": "SELECT custom_columns.name AS label, custom_column_3.value AS value FROM custom_column_3 LEFT OUTER JOIN custom_columns ON custom_columns.id = 3 WHERE custom_column_3.book = ?",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,12 @@
|
|||||||
"serie": "Serie",
|
"serie": "Serie",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"tags": "Tag(s)",
|
"tags": "Tag(s)",
|
||||||
"nocover": "No cover"
|
"nocover": "No cover",
|
||||||
|
"details": "Details",
|
||||||
|
"detail": {
|
||||||
|
"pubdate": "Publication date",
|
||||||
|
"pubname": "Publisher"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"books": "Books",
|
"books": "Books",
|
||||||
|
@ -33,7 +33,12 @@
|
|||||||
"serie": "Série",
|
"serie": "Série",
|
||||||
"language": "Langue",
|
"language": "Langue",
|
||||||
"tags": "Tag(s)",
|
"tags": "Tag(s)",
|
||||||
"nocover": "Pas de couverture"
|
"nocover": "Pas de couverture",
|
||||||
|
"details": "Détails",
|
||||||
|
"detail": {
|
||||||
|
"pubdate": "Date de publication",
|
||||||
|
"pubname": "Editeur"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"books": "Livres",
|
"books": "Livres",
|
||||||
|
@ -150,12 +150,14 @@ router.post('/', function(req,res) {
|
|||||||
|
|
||||||
/* Single book */
|
/* Single book */
|
||||||
router.get('/:id', function(req, res) {
|
router.get('/:id', function(req, res) {
|
||||||
var book, authors, tags;
|
var book, authors, tags, details;
|
||||||
var queries = 3;
|
var queries = 3;
|
||||||
|
if (req.locals.book_details_custom) queries+=req.locals.book_details_custom.length;
|
||||||
var callback = function() {
|
var callback = function() {
|
||||||
if (queries == 0) {
|
if (queries == 0) {
|
||||||
book.authors = authors;
|
book.authors = authors;
|
||||||
book.tags = tags;
|
book.tags = tags;
|
||||||
|
book.custom = custom;
|
||||||
res.format({
|
res.format({
|
||||||
html: function(){
|
html: function(){
|
||||||
res.render('book', book);
|
res.render('book', book);
|
||||||
@ -169,12 +171,14 @@ router.get('/:id', function(req, res) {
|
|||||||
// book
|
// book
|
||||||
req.db.get('SELECT books.id AS id,title,timestamp,pubdate,series_index,isbn,lccn,path,uuid,has_cover,' +
|
req.db.get('SELECT books.id AS id,title,timestamp,pubdate,series_index,isbn,lccn,path,uuid,has_cover,' +
|
||||||
'languages.lang_code,format,uncompressed_size,data.name AS data_name,series.name AS series_name,' +
|
'languages.lang_code,format,uncompressed_size,data.name AS data_name,series.name AS series_name,' +
|
||||||
'series.id AS series_id FROM books ' +
|
'series.id AS series_id, publishers.name AS pubname FROM books ' +
|
||||||
' LEFT OUTER JOIN books_languages_link ON books_languages_link.book = books.id ' +
|
' LEFT OUTER JOIN books_languages_link ON books_languages_link.book = books.id ' +
|
||||||
' LEFT OUTER JOIN languages ON languages.id = books_languages_link.lang_code ' +
|
' LEFT OUTER JOIN languages ON languages.id = books_languages_link.lang_code ' +
|
||||||
' LEFT OUTER JOIN data ON data.book = books.id ' +
|
' LEFT OUTER JOIN data ON data.book = books.id ' +
|
||||||
' LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book ' +
|
' LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book ' +
|
||||||
' LEFT OUTER JOIN series ON series.id = books_series_link.series ' +
|
' LEFT OUTER JOIN series ON series.id = books_series_link.series ' +
|
||||||
|
' LEFT OUTER JOIN books_publishers_link ON books.id = books_publishers_link.book ' +
|
||||||
|
' LEFT OUTER JOIN publishers ON publishers.id = books_publishers_link.publisher ' +
|
||||||
' WHERE books.id = ?', req.params.id,
|
' WHERE books.id = ?', req.params.id,
|
||||||
function(err, row) {
|
function(err, row) {
|
||||||
if (err) console.log('ERR book: '+err);
|
if (err) console.log('ERR book: '+err);
|
||||||
@ -207,6 +211,24 @@ router.get('/:id', function(req, res) {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
// details
|
||||||
|
custom = new Array();
|
||||||
|
if (req.locals.book_details_custom) {
|
||||||
|
_.each(req.locals.book_details_custom, function(detail) {
|
||||||
|
req.db.each(detail.query, req.params.id,
|
||||||
|
function(err, row) {
|
||||||
|
row.name = detail.name;
|
||||||
|
row.type = detail.type;
|
||||||
|
custom.push(row);
|
||||||
|
},
|
||||||
|
function(err) {
|
||||||
|
if (err) console.log('ERR tags: '+err);
|
||||||
|
queries--;
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
16
sample.config.json
Normal file
16
sample.config.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"calibre_path": "./public/calibre",
|
||||||
|
"calibre_db_path": "./public/calibre/metadata.db",
|
||||||
|
"trust proxy": true,
|
||||||
|
"book_details_custom": [
|
||||||
|
{
|
||||||
|
"name": "a_lire",
|
||||||
|
"query": "SELECT custom_columns.name AS label, custom_column_2.value AS value FROM custom_column_2 LEFT OUTER JOIN custom_columns ON custom_columns.id = 2 WHERE custom_column_2.book = ?",
|
||||||
|
"type": "bool"
|
||||||
|
}, {
|
||||||
|
"name": "phy",
|
||||||
|
"query": "SELECT custom_columns.name AS label, custom_column_3.value AS value FROM custom_column_3 LEFT OUTER JOIN custom_columns ON custom_columns.id = 3 WHERE custom_column_3.book = ?",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -12,9 +12,10 @@ block content
|
|||||||
h1
|
h1
|
||||||
span.glyphicon.glyphicon-book
|
span.glyphicon.glyphicon-book
|
||||||
| #{title}
|
| #{title}
|
||||||
a.btn.btn-success(href='/calibre/'+path+'/'+data_name+'.'+format.toLowerCase())
|
if format
|
||||||
span.glyphicon.glyphicon-download-alt
|
a.btn.btn-success(href='/calibre/'+path+'/'+data_name+'.'+format.toLowerCase())
|
||||||
| #{t('bouquins.book.download')} #{format}
|
span.glyphicon.glyphicon-download-alt
|
||||||
|
| #{t('bouquins.book.download')} #{format}
|
||||||
div.row
|
div.row
|
||||||
div.col-md-5
|
div.col-md-5
|
||||||
h2
|
h2
|
||||||
@ -41,6 +42,31 @@ block content
|
|||||||
each tag in tags
|
each tag in tags
|
||||||
span.label.label-info= tag.name
|
span.label.label-info= tag.name
|
||||||
|
|
|
|
||||||
|
h2 #{t('bouquins.book.details')}
|
||||||
|
ul
|
||||||
|
if pubdate
|
||||||
|
li
|
||||||
|
strong #{t('bouquins.book.detail.pubdate')}
|
||||||
|
| #{new Date(pubdate).getMonth()}-#{new Date(pubdate).getFullYear()}
|
||||||
|
if pubname
|
||||||
|
li
|
||||||
|
strong #{t('bouquins.book.detail.pubname')}
|
||||||
|
| #{pubname}
|
||||||
|
if custom
|
||||||
|
each item in custom
|
||||||
|
li
|
||||||
|
if item.label
|
||||||
|
strong #{item.label}
|
||||||
|
else
|
||||||
|
strong #{t('bouquins.book.detail.'+item.name)}
|
||||||
|
case item.type
|
||||||
|
when "bool"
|
||||||
|
if item.value == 1
|
||||||
|
span.glyphicon.glyphicon-ok
|
||||||
|
else
|
||||||
|
span.glyphicon.glyphicon-remove
|
||||||
|
default
|
||||||
|
| #{item.value}
|
||||||
div.col-md-7
|
div.col-md-7
|
||||||
if has_cover == 1
|
if has_cover == 1
|
||||||
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt=t('bouquins.book.nocover'))
|
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt=t('bouquins.book.nocover'))
|
||||||
|
Loading…
Reference in New Issue
Block a user