WIP: /books endpoint
This commit is contained in:
parent
0ea056a2ac
commit
b021a2a1c7
@ -140,6 +140,11 @@ func NewIndexModel(title string, count int64) *IndexModel {
|
||||
}
|
||||
}
|
||||
|
||||
type BookModel struct {
|
||||
BouquinsModel
|
||||
*BookFull
|
||||
}
|
||||
|
||||
func (app *Bouquins) render(res http.ResponseWriter, tpl string, model interface{}) {
|
||||
err := app.Template.ExecuteTemplate(res, tpl, model)
|
||||
if err != nil {
|
||||
@ -182,7 +187,16 @@ func (app *Bouquins) IndexPage(res http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
func (app *Bouquins) BooksPage(res http.ResponseWriter, req *http.Request) {
|
||||
app.render(res, TPL_BOOKS, nil)
|
||||
book, err := app.BookFull(123)
|
||||
if err != nil {
|
||||
// FIXME 500
|
||||
log.Fatalln(err)
|
||||
}
|
||||
model := &BookModel{
|
||||
*NewBouquinsModel(book.Title),
|
||||
book,
|
||||
}
|
||||
app.render(res, TPL_BOOKS, model)
|
||||
}
|
||||
func (app *Bouquins) AuthorsPage(res http.ResponseWriter, req *http.Request) {
|
||||
app.render(res, TPL_AUTHORS, nil)
|
||||
|
@ -203,6 +203,13 @@ func (app *Bouquins) AuthorsAdv(limit, offset int, sort, order string) ([]*Autho
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (app *Bouquins) BookFull(id int64) (*BookFull, error) {
|
||||
b := new(BookFull)
|
||||
b.Id = id
|
||||
b.Title = "test"
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (app *Bouquins) BooksAdv(limit, offset int, sort, order string) ([]*BookAdv, error) {
|
||||
if limit == 0 {
|
||||
limit = DEF_LIM
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="col-xs-12 col-md-9">
|
||||
<h1>
|
||||
<span class="glyphicon glyphicon-book"></span>
|
||||
{{ .Book.Title }}
|
||||
{{ .Title }}
|
||||
</h1>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-3 text-right">
|
||||
@ -36,12 +36,12 @@
|
||||
<span class="glyphicon glyphicon-list"></span> Serie
|
||||
</h2>
|
||||
<div v-if="book.series">
|
||||
<a :href="'series.html?id='+book.series.id">{{ .Book.Series.Name }}</a>
|
||||
<span class="badge">{{ .Book.Series.Idx }}</span>
|
||||
<a :href="'series.html?id='+book.series.id">{{ .Series.Name }}</a>
|
||||
<span class="badge">{{ .Series.Idx }}</span>
|
||||
</div>
|
||||
|
||||
<h2><span class="glyphicon glyphicon-globe"></span> Langue</h2>
|
||||
<ul><li>{{/* .Book.Lang.toUpperCase() */}}</li></ul>
|
||||
<ul><li>{{/* .Lang.toUpperCase() */}}</li></ul>
|
||||
|
||||
<h2 v-if="book.tags">
|
||||
<span class="glyphicon glyphicon-tags"></span> Tags
|
||||
@ -54,8 +54,8 @@
|
||||
|
||||
<h2>Détails</h2>
|
||||
<ul>
|
||||
<li v-if="book.pubdate"><strong>Date de publication</strong> {{ .Book.Pubdate }}</li>
|
||||
<li v-if="book.publisher"><strong>Editeur</strong> {{ .Book.Publisher }}</li>
|
||||
<li v-if="book.pubdate"><strong>Date de publication</strong> {{ .Pubdate }}</li>
|
||||
<li v-if="book.publisher"><strong>Editeur</strong> {{ .Publisher }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user