diff --git a/README.md b/README.md index 3f68188..517e13b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ Bouquins in Go ## TODO -* About * translations * tests * UI book: cover in background diff --git a/bouquins/bouquins.go b/bouquins/bouquins.go index df9aa4c..a422ce8 100644 --- a/bouquins/bouquins.go +++ b/bouquins/bouquins.go @@ -21,6 +21,7 @@ const ( TPL_SERIES = "series.html" TPL_INDEX = "index.html" TPL_SEARCH = "search.html" + TPL_ABOUT = "about.html" PARAM_LIST = "list" PARAM_ORDER = "order" @@ -38,6 +39,7 @@ const ( URL_AUTHORS = "/authors/" URL_SERIES = "/series/" URL_SEARCH = "/search/" + URL_ABOUT = "/about/" URL_JS = "/js/" URL_CSS = "/css/" URL_FONTS = "/fonts/" @@ -134,12 +136,13 @@ type SeriesFull struct { } type BouquinsModel struct { - Title string `json:"title,omitempty"` + Title string + Page string } // Constructor BouquinsModel -func NewBouquinsModel(title string) *BouquinsModel { - return &BouquinsModel{title} +func NewBouquinsModel(title, page string) *BouquinsModel { + return &BouquinsModel{title, page} } type IndexModel struct { @@ -149,7 +152,7 @@ type IndexModel struct { // Constructor IndexModel func NewIndexModel(title string, count int64) *IndexModel { - return &IndexModel{*NewBouquinsModel(title), count} + return &IndexModel{*NewBouquinsModel(title, "index"), count} } type SearchModel struct { @@ -157,7 +160,7 @@ type SearchModel struct { } func NewSearchModel() *SearchModel { - return &SearchModel{*NewBouquinsModel("Recherche")} + return &SearchModel{*NewBouquinsModel("Recherche", "search")} } type ResultsModel struct { @@ -320,7 +323,7 @@ func (app *Bouquins) BookPage(idParam string, res http.ResponseWriter, req *http if err != nil { return nil } - return app.render(res, TPL_BOOKS, &BookModel{*NewBouquinsModel(book.Title), book}) + return app.render(res, TPL_BOOKS, &BookModel{*NewBouquinsModel(book.Title, "book"), book}) } func (app *Bouquins) BooksPage(res http.ResponseWriter, req *http.Request) { var err error @@ -359,7 +362,7 @@ func (app *Bouquins) AuthorPage(idParam string, res http.ResponseWriter, req *ht if err != nil { return err } - return app.render(res, TPL_AUTHORS, &AuthorModel{*NewBouquinsModel(author.Name), author}) + return app.render(res, TPL_AUTHORS, &AuthorModel{*NewBouquinsModel(author.Name, "author"), author}) } func (app *Bouquins) AuthorsPage(res http.ResponseWriter, req *http.Request) { var err error @@ -398,7 +401,7 @@ func (app *Bouquins) SeriePage(idParam string, res http.ResponseWriter, req *htt if err != nil { return err } - return app.render(res, TPL_SERIES, &SeriesModel{*NewBouquinsModel(series.Name), series}) + return app.render(res, TPL_SERIES, &SeriesModel{*NewBouquinsModel(series.Name, "series"), series}) } func (app *Bouquins) SeriesPage(res http.ResponseWriter, req *http.Request) { var err error @@ -425,3 +428,9 @@ func (app *Bouquins) SearchPage(res http.ResponseWriter, req *http.Request) { log.Println(err) } } +func (app *Bouquins) AboutPage(res http.ResponseWriter, req *http.Request) { + err := app.render(res, TPL_ABOUT, NewBouquinsModel("A propos", "about")) + if err != nil { + log.Println(err) + } +} diff --git a/main.go b/main.go index ffc058c..98f0b10 100644 --- a/main.go +++ b/main.go @@ -89,6 +89,7 @@ func router(app *Bouquins) { http.HandleFunc(URL_AUTHORS, app.AuthorsPage) http.HandleFunc(URL_SERIES, app.SeriesPage) http.HandleFunc(URL_SEARCH, app.SearchPage) + http.HandleFunc(URL_ABOUT, app.AboutPage) } func main() { diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000..cbb76eb --- /dev/null +++ b/templates/about.html @@ -0,0 +1,6 @@ +{{ template "header.html" . }} +
bouquins est une interface web pour le gestionnaire de livres numériques calibre. Cette version utilise le langage Go, le framework bootstap et le framework Vue.js.
+Ce logiciel est open-source et distribué sous license BSD. Le code source est disponible ici: https://git.meutel.net/meutel/go-bouquins. +