This commit is contained in:
Meutel 2014-06-29 01:21:17 +02:00
parent 00c02da766
commit f0fba98124
9 changed files with 67 additions and 43 deletions

View File

@ -6,6 +6,7 @@ var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var sqlite3 = require('sqlite3').verbose();
var _ = require('underscore');
var i18n = require('i18next');
var home = require('./routes/home');
var author = require('./routes/author');
@ -13,6 +14,11 @@ var book = require('./routes/book');
var tag = require('./routes/tag');
var serie = require('./routes/serie');
i18n.init({
saveMissing: false,
debug: true
});
var app = express();
// view engine setup
@ -40,7 +46,12 @@ app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(i18n.handle);
i18n.registerAppHelper(app);
app.use(express.static(path.join(__dirname, 'public')));
app.use('/locales',express.static(path.join(__dirname, 'locales')));
app.use('/calibre', express.static(app.locals.calibre_path));
app.use('/', home);

View File

@ -14,7 +14,8 @@
"jade": "~1.3.0",
"sqlite3": "~2.2.0",
"underscore": "~1.6.0",
"hashmap": "~1.1.0"
"hashmap": "~1.1.0",
"i18next": "*"
},
"scripts": {
"start": "node ./bin/www"

View File

@ -35,7 +35,7 @@ $.extend(ItemsCol.prototype,{
},
});
var HomePage = function() {
this.books= new ItemsCol('book', ['Titre', 'Auteur(s)', 'Serie'], [
this.books= new ItemsCol('book', [$.t('bouquins.cols.booktitle'), $.t('bouquins.cols.bookauthors'), $.t('bouquins.cols.bookserie')], [
function(elt) {
return link(elt.title, '/book/'+elt.id, 'glyphicon-book');
},
@ -53,11 +53,11 @@ var HomePage = function() {
return link(content, '/serie/'+elt.series_id, 'glyphicon-list');
}
]);
this.authors= new ItemsCol('author', ['Nom', 'Livres'], [
this.authors= new ItemsCol('author', [$.t('bouquins.cols.authorname'), $.t('bouquins.cols.authorbooks')], [
function(elt){ return link(elt.name, '/author/'+elt.id,'glyphicon-user'); },
function(elt) { return elt.count; }
]);
this.series= new ItemsCol('serie', ['Nom', 'Auteur(s)', 'Livres'], [
this.series= new ItemsCol('serie', [$.t('bouquins.cols.seriename'), $.t('bouquins.cols.serieauthors'), $.t('bouquins.cols.seriebooks')], [
function(elt) { return link(elt.name, '/serie/'+elt.id, 'glyphicon-list'); },
function(elt) {
var links='';
@ -105,6 +105,10 @@ var HomePage = function() {
if (home.current)
home.current.load();
});
$.each([this.authors,this.books,this.series],function(i,itemsCol) {
if (window.location.hash == '#'+itemsCol.id+'s')
itemsCol.load();
});
};
$.extend(HomePage.prototype,{
current: null,
@ -155,12 +159,6 @@ $.extend(HomePage.prototype,{
});
},
});
var home = new HomePage();
$.each([home.authors,home.books,home.series],function(i,itemsCol) {
if (window.location.hash == '#'+itemsCol.id+'s')
itemsCol.load();
});
/**
* Make link.
*/

6
public/js/i18next.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -3,9 +3,9 @@ extends layout
block content
ol.breadcrumb
li
a(href="/") Home
a(href="/")= t('bouquins.nav.home')
li
a(href="/#authors") Auteurs
a(href="/#authors")= t('bouquins.nav.authors')
li.active= title
div.container
div.page-header
@ -14,7 +14,7 @@ block content
= ' '+name
h2
span.glyphicon.glyphicon-book
| Livres
= ' '+t('bouquins.author.books')
ul
each book in books
li
@ -27,14 +27,14 @@ block content
if series
h2
span.glyphicon.glyphicon-list
| Series
= ' '+t('bouquins.author.series')
ul
each serie in series
li: a(href='/serie/'+serie.id)= ' '+serie.name
if coauthors
h2
span.glyphicon.glyphicon-user
| Co-Auteur(s)
= ' '+t('bouquins.author.coauthors')
ul
each author in coauthors
li: a(href='/author/'+author.id)= author.name

View File

@ -3,9 +3,9 @@ extends layout
block content
ol.breadcrumb
li
a(href="/") Home
a(href="/")= t('bouquins.nav.home')
li
a(href="/#books") Livres
a(href="/#books")= t('bouquins.nav.books')
li.active= title
div.container
div.page-header
@ -14,33 +14,33 @@ block content
= ' '+title+' '
a.btn.btn-success(href='/calibre/'+path+'/'+data_name+'.'+format.toLowerCase())
span.glyphicon.glyphicon-download-alt
= ' Telecharger ' + format
= ' '+t('bouquins.book.download')+' ' + format
div.row
div.col-md-5
h2
span.glyphicon.glyphicon-user
| Auteur(s)
= ' '+t('bouquins.book.authors')
ul.list-unstyled
each author in authors
li: a(href='/author/'+author.id)= author.name
if series_name
h2
span.glyphicon.glyphicon-list
| Serie
= ' '+t('bouquins.book.serie')
div
a(href='/serie/'+series_id)= series_name + ' '
span.badge= series_index
h2
span.glyphicon.glyphicon-globe
| Langue
= ' '+t('bouquins.book.language')
div= lang_code
h2
span.glyphicon.glyphicon-tags
| Etiquette(s)
= ' '+t('bouquins.book.tags')
div
each tag in tags
span.label.label-info= tag.name
|
div.col-md-7
if has_cover == 1
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt="Pas de couverture")
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt=t('bouquins.book.nocover'))

View File

@ -2,16 +2,16 @@ extends layout
block content
div.jumbotron
h1= title
p Naviguez dans la bibliothèque.
h1= t('bouquins.homeTitle')
p= t('bouquins.homeGreetings')
p
a#book.btn.btn-primary.btn-lg(href="#books",role="button") Livres
a#book.btn.btn-primary.btn-lg(href="#books",role="button")= t('bouquins.books')
 
a#author.btn.btn-primary.btn-lg(href="#authors",role="button") Auteurs
a#author.btn.btn-primary.btn-lg(href="#authors",role="button")= t('bouquins.authors')
 
a#serie.btn.btn-primary.btn-lg(href="#series",role="button") Series
a#serie.btn.btn-primary.btn-lg(href="#series",role="button")= t('bouquins.series')
 
a#recent.btn.btn-warning.btn-lg(href="#books",role="button") Derniers ajouts
a#recent.btn.btn-warning.btn-lg(href="#books",role="button")= t('bouquins.recent')
div#blkitems.container-fluid.hidden
a#itemsanchor
div.btn-group
@ -21,17 +21,19 @@ block content
button.btn.btn-default.initial(type="button",value=c)= c
- }
ul.pager
li.previous.disabled: a.prev Précédent
li.next.disabled: a.next Suivant
li.previous.disabled: a.prev= t('bouquins.previous')
li.next.disabled: a.next= t('bouquins.next')
table#items.table.table-striped
tr: td.disabled Vide
tr: td.disabled= t('bouquins.empty')
ul.pager
li.previous.disabled: a.prev Précédent
li.next.disabled: a.next Suivant
li.previous.disabled: a.prev= t('bouquins.previous')
li.next.disabled: a.next= t('bouquins.next')
div.btn-group.center-block
each p in [10,20,50,100]
button.btn.btn-default.perpage(type="button",value=p)= p
script(src="js/jquery.min.js")
script(src="js/bootstrap.min.js")
script(src="js/purl.js")
script(src="js/home.js")
script
| $(function() {
| $.i18n.init().done(function() {
| home = new HomePage();
| });
| });

View File

@ -1,10 +1,16 @@
doctype html
html(lang="fr")
- var lang = i18n.lng()
html(lang=lang)
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible",content="IE=edge")
meta(name="viewport",content="width=device-width, initial-scale=1")
title= title
link(rel='stylesheet', href='/css/bootstrap.min.css')
script(src="/js/jquery.min.js")
script(src="/js/bootstrap.min.js")
script(src="/js/i18next.min.js")
script(src="/js/purl.js")
script(src="/js/home.js")
body
block content

View File

@ -3,9 +3,9 @@ extends layout
block content
ol.breadcrumb
li
a(href="/") Home
a(href="/")= t('bouquins.nav.home')
li
a(href="/#series") Series
a(href="/#series")= t('bouquins.nav.series')
li.active= title
div.container
div.page-header
@ -14,7 +14,7 @@ block content
= ' '+name
h2
span.glyphicon.glyphicon-book
| Livres
= ' '+t('bouquins.serie.books')
ul
each book in books
li
@ -24,7 +24,7 @@ block content
if authors.length > 0
h2
span.glyphicon.glyphicon-user
| Auteur(s)
= ' '+t('bouquins.serie.authors')
ul
each author in authors
li: a(href='/author/'+author.id)= author.name