Convert Id to ID

This commit is contained in:
Las Zenow 2016-07-30 07:59:30 -04:00
parent f12114c296
commit 52b9882be9
17 changed files with 76 additions and 78 deletions

View file

@ -29,7 +29,7 @@ func deleteHandler(h handler) {
if id == "" { if id == "" {
continue continue
} }
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
h.sess.Notify("Book not found!", "The book with id '"+id+"' is not there", "error") h.sess.Notify("Book not found!", "The book with id '"+id+"' is not there", "error")
continue continue
@ -59,7 +59,7 @@ func editHandler(h handler) {
notFound(h) notFound(h)
return return
} }
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
notFound(h) notFound(h)
return return
@ -199,7 +199,7 @@ func storeHandler(h handler) {
if id == "" { if id == "" {
continue continue
} }
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
h.sess.Notify("Book not found!", "The book with id '"+id+"' is not there", "error") h.sess.Notify("Book not found!", "The book with id '"+id+"' is not there", "error")
continue continue

View file

@ -32,7 +32,7 @@ const (
func coverHandler(h handler) { func coverHandler(h handler) {
vars := mux.Vars(h.r) vars := mux.Vars(h.r)
book, err := h.db.GetBookId(vars["id"]) book, err := h.db.GetBookID(vars["id"])
if err != nil { if err != nil {
notFound(h) notFound(h)
return return
@ -49,7 +49,7 @@ func coverHandler(h handler) {
if vars["size"] == "small" { if vars["size"] == "small" {
file = coverSmallFile file = coverSmallFile
} }
f, err := h.store.Get(book.Id, file) f, err := h.store.Get(book.ID, file)
if err != nil { if err != nil {
log.Error("Error while opening image: ", err) log.Error("Error while opening image: ", err)
notFound(h) notFound(h)

View file

@ -5,8 +5,9 @@ import (
"time" "time"
) )
// Book metadata
type Book struct { type Book struct {
Id string ID string
Title string Title string
Authors []string `sql:"authors" pg:",array"` Authors []string `sql:"authors" pg:",array"`
Contributor string Contributor string
@ -42,6 +43,8 @@ func (db *pgDB) GetBooks(query string, length int, start int) (books []Book, num
// TODO: func (db *pgDB) GetBooksIter() Iter { // TODO: func (db *pgDB) GetBooksIter() Iter {
// GetNewBooks returns a list of books in the incoming queue and the number of books
// in the queue
func (db *pgDB) GetNewBooks(query string, length int, start int) (books []Book, num int, err error) { func (db *pgDB) GetNewBooks(query string, length int, start int) (books []Book, num int, err error) {
return db.getBooks(false, query, length, start) return db.getBooks(false, query, length, start)
} }
@ -81,7 +84,8 @@ func (db *pgDB) getBooks(active bool, query string, length int, start int) (book
return books, num, err return books, num, err
} }
func (db *pgDB) GetBookId(id string) (Book, error) { // GetBookID returns a the book with the specified id
func (db *pgDB) GetBookID(id string) (Book, error) {
var book Book var book Book
err := db.sql.Model(&book). err := db.sql.Model(&book).
Where("id = ?", id). Where("id = ?", id).
@ -89,6 +93,7 @@ func (db *pgDB) GetBookId(id string) (Book, error) {
return book, err return book, err
} }
// DeleteBook removes the book with id from the database
func (db *pgDB) DeleteBook(id string) error { func (db *pgDB) DeleteBook(id string) error {
_, err := db.sql.Model(&Book{}). _, err := db.sql.Model(&Book{}).
Where("id = ?", id). Where("id = ?", id).
@ -96,6 +101,7 @@ func (db *pgDB) DeleteBook(id string) error {
return err return err
} }
// UpdateBook metadata
func (db *pgDB) UpdateBook(id string, data map[string]interface{}) error { func (db *pgDB) UpdateBook(id string, data map[string]interface{}) error {
setCondition := "" setCondition := ""
params := []interface{}{} params := []interface{}{}
@ -125,11 +131,7 @@ func (db *pgDB) UpdateBook(id string, data map[string]interface{}) error {
return err return err
} }
func (db *pgDB) FlagBadQuality(id string, user string) error { // ActiveBook activates the book
// TODO: delete me
return nil
}
func (db *pgDB) ActiveBook(id string) error { func (db *pgDB) ActiveBook(id string) error {
uploadDate := time.Now() uploadDate := time.Now()
_, err := db.sql.Model(&Book{}). _, err := db.sql.Model(&Book{}).
@ -139,6 +141,7 @@ func (db *pgDB) ActiveBook(id string) error {
return err return err
} }
// IsBookActive checks if the book is active
func (db *pgDB) IsBookActive(id string) bool { func (db *pgDB) IsBookActive(id string) bool {
var active []bool var active []bool
err := db.sql.Model(&Book{}). err := db.sql.Model(&Book{}).

View file

@ -3,7 +3,7 @@ package database
import "testing" import "testing"
var book = Book{ var book = Book{
Id: "r_m-IOzzIbA6QK5w", ID: "r_m-IOzzIbA6QK5w",
Title: "some title", Title: "some title",
Authors: []string{"Alice", "Bob"}, Authors: []string{"Alice", "Bob"},
} }
@ -28,7 +28,7 @@ func TestAddAndDeleteBook(t *testing.T) {
t.Error("Book title don't match : '", books[0].Title, "' <=> '", book.Title, "'") t.Error("Book title don't match : '", books[0].Title, "' <=> '", book.Title, "'")
} }
err = db.DeleteBook(books[0].Id) err = db.DeleteBook(books[0].ID)
if err != nil { if err != nil {
t.Fatal("db.DeleteBook() return an error: ", err) t.Fatal("db.DeleteBook() return an error: ", err)
} }
@ -47,16 +47,16 @@ func TestActiveBook(t *testing.T) {
testAddBook(t, db) testAddBook(t, db)
books, _, _ := db.GetNewBooks("", 1, 0) books, _, _ := db.GetNewBooks("", 1, 0)
id := books[0].Id id := books[0].ID
err := db.ActiveBook(id) err := db.ActiveBook(id)
if err != nil { if err != nil {
t.Fatal("db.ActiveBook(", id, ") return an error: ", err) t.Fatal("db.ActiveBook(", id, ") return an error: ", err)
} }
b, err := db.GetBookId(id) b, err := db.GetBookID(id)
if err != nil { if err != nil {
t.Fatal("db.GetBookId(", id, ") return an error: ", err) t.Fatal("db.GetBookID(", id, ") return an error: ", err)
} }
if !b.Active { if !b.Active {
t.Error("Book is not activated") t.Error("Book is not activated")
@ -92,7 +92,7 @@ func TestUpdateBook(t *testing.T) {
testAddBook(t, db) testAddBook(t, db)
newTitle := "other title" newTitle := "other title"
err := db.UpdateBook(book.Id, map[string]interface{}{ err := db.UpdateBook(book.ID, map[string]interface{}{
"title": newTitle, "title": newTitle,
}) })
if err != nil { if err != nil {

View file

@ -9,10 +9,9 @@ type DB interface {
AddBook(book Book) error AddBook(book Book) error
GetBooks(query string, length int, start int) (books []Book, num int, err error) GetBooks(query string, length int, start int) (books []Book, num int, err error)
GetNewBooks(query string, length int, start int) (books []Book, num int, err error) GetNewBooks(query string, length int, start int) (books []Book, num int, err error)
GetBookId(id string) (Book, error) GetBookID(id string) (Book, error)
DeleteBook(id string) error DeleteBook(id string) error
UpdateBook(id string, data map[string]interface{}) error UpdateBook(id string, data map[string]interface{}) error
FlagBadQuality(id string, user string) error
ActiveBook(id string) error ActiveBook(id string) error
IsBookActive(id string) bool IsBookActive(id string) bool
AddUser(name string, pass string) error AddUser(name string, pass string) error

View file

@ -24,8 +24,8 @@ func (db *roDB) GetNewBooks(query string, length int, start int) (books []Book,
return db.db.GetNewBooks(query, length, start) return db.db.GetNewBooks(query, length, start)
} }
func (db *roDB) GetBookId(id string) (Book, error) { func (db *roDB) GetBookID(id string) (Book, error) {
return db.db.GetBookId(id) return db.db.GetBookID(id)
} }
func (db *roDB) DeleteBook(id string) error { func (db *roDB) DeleteBook(id string) error {
@ -36,10 +36,6 @@ func (db *roDB) UpdateBook(id string, data map[string]interface{}) error {
return errors.New("RO database") return errors.New("RO database")
} }
func (db *roDB) FlagBadQuality(id string, user string) error {
return errors.New("RO database")
}
func (db *roDB) ActiveBook(id string) error { func (db *roDB) ActiveBook(id string) error {
return errors.New("RO database") return errors.New("RO database")
} }

View file

@ -183,7 +183,7 @@ func openReadEpub(h handler) (*epubgo.Epub, database.Book) {
if id == "" { if id == "" {
return nil, book return nil, book
} }
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
return nil, book return nil, book
} }
@ -193,7 +193,7 @@ func openReadEpub(h handler) (*epubgo.Epub, database.Book) {
} }
} }
f, err := h.store.Get(book.Id, epubFile) f, err := h.store.Get(book.ID, epubFile)
if err != nil { if err != nil {
return nil, book return nil, book
} }
@ -228,7 +228,7 @@ func contentHandler(h handler) {
} }
func openEpubFile(h handler, id string, file string) error { func openEpubFile(h handler, id string, file string) error {
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
return err return err
} }

View file

@ -202,11 +202,11 @@ func bookJsonRaw(book database.Book) map[string]interface{} {
cover := "" cover := ""
coverSmall := "" coverSmall := ""
if book.Cover { if book.Cover {
cover = "/cover/" + book.Id + "/big/" + book.Title + ".jpg" cover = "/cover/" + book.ID + "/big/" + book.Title + ".jpg"
coverSmall = "/cover/" + book.Id + "/small/" + book.Title + ".jpg" coverSmall = "/cover/" + book.ID + "/small/" + book.Title + ".jpg"
} }
return map[string]interface{}{ return map[string]interface{}{
"id": book.Id, "id": book.ID,
"title": book.Title, "title": book.Title,
"authors": book.Authors, "authors": book.Authors,
"contributor": book.Contributor, "contributor": book.Contributor,
@ -219,7 +219,7 @@ func bookJsonRaw(book database.Book) map[string]interface{} {
"size": book.FileSize, "size": book.FileSize,
"cover": cover, "cover": cover,
"cover_small": coverSmall, "cover_small": coverSmall,
"download": "/download/" + book.Id + "/" + book.Title + ".epub", "download": "/download/" + book.ID + "/" + book.Title + ".epub",
"read": "/read/" + book.Id, "read": "/read/" + book.ID,
} }
} }

View file

@ -59,7 +59,7 @@ func bookHandler(h handler) {
id := mux.Vars(h.r)["id"] id := mux.Vars(h.r)["id"]
var data bookData var data bookData
data.S = GetStatus(h) data.S = GetStatus(h)
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
notFound(h) notFound(h)
return return
@ -78,7 +78,7 @@ func bookHandler(h handler) {
func downloadHandler(h handler) { func downloadHandler(h handler) {
id := mux.Vars(h.r)["id"] id := mux.Vars(h.r)["id"]
book, err := h.db.GetBookId(id) book, err := h.db.GetBookID(id)
if err != nil { if err != nil {
notFound(h) notFound(h)
return return
@ -91,7 +91,7 @@ func downloadHandler(h handler) {
} }
} }
f, err := h.store.Get(book.Id, epubFile) f, err := h.store.Get(book.ID, epubFile)
if err != nil { if err != nil {
notFound(h) notFound(h)
return return

View file

@ -48,22 +48,22 @@ func processFile(req uploadRequest, db database.DB, store storage.Store) {
defer epub.Close() defer epub.Close()
book := parser.EpubMetadata(epub) book := parser.EpubMetadata(epub)
book.Id = genId() book.ID = genID()
req.file.Seek(0, 0) req.file.Seek(0, 0)
size, err := store.Store(book.Id, req.file, epubFile) size, err := store.Store(book.ID, req.file, epubFile)
if err != nil { if err != nil {
log.Error("Error storing book (", book.Id, "): ", err) log.Error("Error storing book (", book.ID, "): ", err)
return return
} }
book.FileSize = int(size) book.FileSize = int(size)
book.Cover = GetCover(epub, book.Id, store) book.Cover = GetCover(epub, book.ID, store)
err = db.AddBook(book) err = db.AddBook(book)
log.Error(":", book.Lang, ":") log.Error(":", book.Lang, ":")
if err != nil { if err != nil {
log.Error("Error storing metadata (", book.Id, "): ", err) log.Error("Error storing metadata (", book.ID, "): ", err)
return return
} }
log.Info("File uploaded: ", req.filename) log.Info("File uploaded: ", req.filename)
@ -119,7 +119,7 @@ func openMultipartEpub(file multipart.File) (*epubgo.Epub, error) {
return epubgo.Load(reader, int64(len(buff))) return epubgo.Load(reader, int64(len(buff)))
} }
func genId() string { func genID() string {
b := make([]byte, 12) b := make([]byte, 12)
rand.Read(b) rand.Read(b)
return base64.URLEncoding.EncodeToString(b) return base64.URLEncoding.EncodeToString(b)

View file

@ -4,13 +4,13 @@
{{with .Book}} {{with .Book}}
<script> <script>
function delBook(){ function delBook(){
var div = document.getElementById('delete'); var div = document.getElementByID('delete');
div.innerHTML = div.innerHTML =
'<div class="alert alert-error fade in"> \ '<div class="alert alert-error fade in"> \
<a class="close" data-dismiss="alert">×</a> \ <a class="close" data-dismiss="alert">×</a> \
<h4 class="alert-heading">Do you really want to delete it?</h4> \ <h4 class="alert-heading">Do you really want to delete it?</h4> \
<p>Remove a book is permanent, you won\'t be able to get it back</p> \ <p>Remove a book is permanent, you won\'t be able to get it back</p> \
<a class="btn btn-danger" href="/delete/{{.Id}}/">Remove it</a> \ <a class="btn btn-danger" href="/delete/{{.ID}}/">Remove it</a> \
<a class="btn" href="#" data-dismiss="alert">Cancel</a> \ <a class="btn" href="#" data-dismiss="alert">Cancel</a> \
</div>'; </div>';
} }
@ -25,7 +25,7 @@ function delBook(){
<div class="row"> <div class="row">
{{if .Cover}} {{if .Cover}}
<div class="span4"> <div class="span4">
<img src="/cover/{{.Id}}/big/{{.Title}}.jpg" alt="{{.Title}}" class="pull-right" /> <img src="/cover/{{.ID}}/big/{{.Title}}.jpg" alt="{{.Title}}" class="pull-right" />
</div> </div>
{{end}} {{end}}
@ -45,15 +45,15 @@ function delBook(){
<div class="span3"> <div class="span3">
<div class="row"> <div class="row">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a href="/download/{{.Id}}/{{.Title}}.epub" class="btn btn-large btn-inverse"><i class="icon-download-alt icon-white"></i> download</a> <a href="/download/{{.ID}}/{{.Title}}.epub" class="btn btn-large btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
<a href="/read/{{.Id}}" class="btn btn-large btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a> <a href="/read/{{.ID}}" class="btn btn-large btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
</div> </div>
</div> </div>
{{if eq $role "admin" "moderator"}} {{if eq $role "admin" "moderator"}}
<div class="row"><p></p></div> <div class="row"><p></p></div>
<div class="row"> <div class="row">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a href="/edit/{{.Id}}" class="btn btn-primary"><i class="icon-pencil"></i> Edit</a> <a href="/edit/{{.ID}}" class="btn btn-primary"><i class="icon-pencil"></i> Edit</a>
<a href="#" onClick="delBook();" class="btn btn-danger"><i class="icon-trash"></i> Delete</a> <a href="#" onClick="delBook();" class="btn btn-danger"><i class="icon-trash"></i> Delete</a>
</div> </div>
</div> </div>

View file

@ -4,12 +4,12 @@
<div class="row"> <div class="row">
{{if .Cover}} {{if .Cover}}
<div class="span4"> <div class="span4">
<img src="/cover/{{.Id}}/big/{{.Title}}.jpg" alt="{{.Title}}" class="pull-right" /> <img src="/cover/{{.ID}}/big/{{.Title}}.jpg" alt="{{.Title}}" class="pull-right" />
</div> </div>
{{end}} {{end}}
<div class="span8"> <div class="span8">
<form class="form-horizontal" method="POST" action="/save/{{.Id}}"> <form class="form-horizontal" method="POST" action="/save/{{.ID}}">
<fieldset> <fieldset>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="title">Title</label> <label class="control-label" for="title">Title</label>
@ -68,7 +68,7 @@
</div> </div>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary">Save</button>
<a href="/book/{{.Id}}" class="btn">Cancel</a> <a href="/book/{{.ID}}" class="btn">Cancel</a>
</div> </div>
</fieldset> </fieldset>
</form> </form>

View file

@ -25,8 +25,8 @@
{{range .}} {{range .}}
<li class="span2"> <li class="span2">
<div class="thumbnail centered" style="border:none;"> <div class="thumbnail centered" style="border:none;">
<a href="/book/{{.Id}}"> <a href="/book/{{.ID}}">
{{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.Id}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}} {{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}}
<p><strong>{{.Title}}</strong></p> <p><strong>{{.Title}}</strong></p>
</a> </a>
</div> </div>
@ -43,8 +43,8 @@
{{range .}} {{range .}}
<li class="span2"> <li class="span2">
<div class="thumbnail centered" style="border:none;"> <div class="thumbnail centered" style="border:none;">
<a href="/book/{{.Id}}"> <a href="/book/{{.ID}}">
{{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.Id}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}} {{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}}
<p><strong>{{.Title}}</strong></p> <p><strong>{{.Title}}</strong></p>
</a> </a>
</div> </div>
@ -61,8 +61,8 @@
{{range .}} {{range .}}
<li class="span2"> <li class="span2">
<div class="thumbnail centered" style="border:none;"> <div class="thumbnail centered" style="border:none;">
<a href="/book/{{.Id}}"> <a href="/book/{{.ID}}">
{{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.Id}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}} {{if .Cover}}<div class="down"><img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" /></div>{{end}}
<p><strong>{{.Title}}</strong></p> <p><strong>{{.Title}}</strong></p>
</a> </a>
</div> </div>

View file

@ -6,8 +6,8 @@
{{if .Books}} {{if .Books}}
<div class="centered btn-group"> <div class="centered btn-group">
<a href="/store/{{range .Books}}{{.B.Id}}/{{end}}" class="btn btn-large btn-success"><i class="icon-ok"></i> Save All</a> <a href="/store/{{range .Books}}{{.B.ID}}/{{end}}" class="btn btn-large btn-success"><i class="icon-ok"></i> Save All</a>
<a href="/delete/{{range .Books}}{{.B.Id}}/{{end}}" class="btn btn-large btn-danger"><i class="icon-remove"></i> Delete All</a> <a href="/delete/{{range .Books}}{{.B.ID}}/{{end}}" class="btn btn-large btn-danger"><i class="icon-remove"></i> Delete All</a>
</div> </div>
{{end}} {{end}}
<p class="centered">Found {{.Found}} books.<br /></p> <p class="centered">Found {{.Found}} books.<br /></p>
@ -30,7 +30,7 @@
{{with .B}} {{with .B}}
<div class="row"> <div class="row">
<div class="span1"> <div class="span1">
<p class="pull-right">{{if .Cover}}<img src="/cover/{{.Id}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</p> <p class="pull-right">{{if .Cover}}<img src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</p>
</div> </div>
<div class="span9"> <div class="span9">
<p><a href="/search/?q=title:{{.Title}}"><strong>{{.Title}}</strong></a> <small>({{$titleFound}})</small><br /> <p><a href="/search/?q=title:{{.Title}}"><strong>{{.Title}}</strong></a> <small>({{$titleFound}})</small><br />
@ -45,14 +45,14 @@
</div> </div>
<div class="span2"> <div class="span2">
<div class="row btn-group pull-right"> <div class="row btn-group pull-right">
<a href="/store/{{.Id}}/" class="btn btn-success"><i class="icon-ok"></i> Save</a> <a href="/store/{{.ID}}/" class="btn btn-success"><i class="icon-ok"></i> Save</a>
<a href="/edit/{{.Id}}" class="btn btn-primary"><i class="icon-pencil"></i> Edit</a> <a href="/edit/{{.ID}}" class="btn btn-primary"><i class="icon-pencil"></i> Edit</a>
<a href="/delete/{{.Id}}/" class="btn btn-danger"><i class="icon-remove"></i> Delete</a> <a href="/delete/{{.ID}}/" class="btn btn-danger"><i class="icon-remove"></i> Delete</a>
</div> </div>
<div class="row"><p></p></div> <div class="row"><p></p></div>
<div class="row btn-group pull-right"> <div class="row btn-group pull-right">
<a href="/download/{{.Id}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a> <a href="/download/{{.ID}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
<a href="/read/{{.Id}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a> <a href="/read/{{.ID}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
</div> </div>
</div> </div>
</div> </div>
@ -72,8 +72,8 @@
</ul> </ul>
{{if .Books}} {{if .Books}}
<div class="centered btn-group"> <div class="centered btn-group">
<a href="/store/{{range .Books}}{{.B.Id}}/{{end}}" class="btn btn-large btn-success"><i class="icon-ok"></i> Save All</a> <a href="/store/{{range .Books}}{{.B.ID}}/{{end}}" class="btn btn-large btn-success"><i class="icon-ok"></i> Save All</a>
<a href="/delete/{{range .Books}}{{.B.Id}}/{{end}}" class="btn btn-large btn-danger"><i class="icon-remove"></i> Delete All</a> <a href="/delete/{{range .Books}}{{.B.ID}}/{{end}}" class="btn btn-large btn-danger"><i class="icon-remove"></i> Delete All</a>
</div> </div>
{{end}} {{end}}

View file

@ -21,22 +21,22 @@
{{range .}} {{range .}}
<div class="row"> <div class="row">
<div class="span1"> <div class="span1">
<p class="pull-right"><a href="/book/{{.Id}}">{{if .Cover}}<img class="img-rounded" src="/cover/{{.Id}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</a></p> <p class="pull-right"><a href="/book/{{.ID}}">{{if .Cover}}<img class="img-rounded" src="/cover/{{.ID}}/small/{{.Title}}.jpg" alt="{{.Title}}" />{{end}}</a></p>
</div> </div>
<div class="span10 well"> <div class="span10 well">
<div class="row"> <div class="row">
<div class="span7"> <div class="span7">
<p> <p>
<span class="muted">[{{if .Lang}}{{.Lang}}{{end}}]</span> <span class="muted">[{{if .Lang}}{{.Lang}}{{end}}]</span>
<a href="/book/{{.Id}}"><strong>{{.Title}}</strong></a> <a href="/book/{{.ID}}"><strong>{{.Title}}</strong></a>
<span class="muted">{{if .Publisher}}{{.Publisher}}{{end}}</span><br /> <span class="muted">{{if .Publisher}}{{.Publisher}}{{end}}</span><br />
{{range .Authors}}{{.}}, {{end}} {{range .Authors}}{{.}}, {{end}}
</p> </p>
</div> </div>
<div class="span3"> <div class="span3">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a href="/download/{{.Id}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a> <a href="/download/{{.ID}}/{{.Title}}.epub" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
<a href="/read/{{.Id}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a> <a href="/read/{{.ID}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -58,7 +58,7 @@
{{range .Books}} {{range .Books}}
<entry> <entry>
<title>{{html .Title}}</title> <title>{{html .Title}}</title>
<id>{{$baseurl}}/book/{{.Id}}</id> <id>{{$baseurl}}/book/{{.ID}}</id>
<updated>{{$updated}}</updated> <updated>{{$updated}}</updated>
{{range .Authors}} {{range .Authors}}
@ -89,11 +89,11 @@
{{end}} {{end}}
<summary>{{html .Description}}</summary> <summary>{{html .Description}}</summary>
<link type="image/jpeg" href="/cover/{{.Id}}/big/cover.jpg" rel="http://opds-spec.org/image"/> <link type="image/jpeg" href="/cover/{{.ID}}/big/cover.jpg" rel="http://opds-spec.org/image"/>
<link type="image/jpg" href="/cover/{{.Id}}/small/thumbnail.jpg" rel="http://opds-spec.org/image/thumbnail" /> <link type="image/jpg" href="/cover/{{.ID}}/small/thumbnail.jpg" rel="http://opds-spec.org/image/thumbnail" />
<link rel="http://opds-spec.org/acquisition" <link rel="http://opds-spec.org/acquisition"
href="/download/{{.Id}}/{{urlquery .Title}}.epub" href="/download/{{.ID}}/{{urlquery .Title}}.epub"
type="application/epub+zip" /> type="application/epub+zip" />
</entry> </entry>
{{end}} {{end}}

View file

@ -16,11 +16,11 @@
<item> <item>
<title>{{.Title}} - {{index .Authors 0}}</title> <title>{{.Title}} - {{index .Authors 0}}</title>
<description>{{.Description}}</description> <description>{{.Description}}</description>
<link>{{$baseURL}}/book/{{.Id}}</link> <link>{{$baseURL}}/book/{{.ID}}</link>
{{if .Isbn}} {{if .Isbn}}
<guid isPermaLink="false">ISBN: {{.Isbn}}</guid> <guid isPermaLink="false">ISBN: {{.Isbn}}</guid>
{{end}} {{end}}
<enclosure url="{{$baseURL}}/download/{{.Id}}/{{.Title}}.epub" length="{{.FileSize}}" type="application/epub+zip" /> <enclosure url="{{$baseURL}}/download/{{.ID}}/{{.Title}}.epub" length="{{.FileSize}}" type="application/epub+zip" />
{{range .Authors}} {{range .Authors}}
{{if .}} {{if .}}
<category>{{.}}</category> <category>{{.}}</category>