From e3afa3a6b557e5758f8f98671c8ed418cd893343 Mon Sep 17 00:00:00 2001 From: Meutel Date: Tue, 5 Sep 2017 16:54:25 +0200 Subject: [PATCH] version string in js url (cache) --- README.md | 2 -- bouquins/bouquins.go | 15 +++++++++------ main.go | 6 +++--- templates/footer.html | 4 ++-- templates/header.html | 10 +++++----- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 517e13b..dfe8fa3 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Bouquins in Go * translations * tests -* UI book: cover in background * auth downloads -* version string in js url (cache) * csrf * vue.js dev/prod diff --git a/bouquins/bouquins.go b/bouquins/bouquins.go index 90fe39a..66b2ab3 100644 --- a/bouquins/bouquins.go +++ b/bouquins/bouquins.go @@ -16,6 +16,8 @@ import ( ) const ( + Version = "master" + tplBooks = "book.html" tplAuthors = "author.html" tplSeries = "series.html" @@ -43,11 +45,11 @@ const ( // URLAbout url of about page URLAbout = "/about/" // URLJs url of js assets - URLJs = "/js/" + URLJs = "/" + Version + "/js/" // URLCss url of css assets - URLCss = "/css/" + URLCss = "/" + Version + "/css/" // URLFonts url of fonts assets - URLFonts = "/fonts/" + URLFonts = "/" + Version + "/fonts/" // URLCalibre url of calibre resources (covers, ebooks files) URLCalibre = "/calibre/" ) @@ -136,13 +138,14 @@ type SeriesFull struct { // Model is basic page model type Model struct { - Title string - Page string + Title string + Page string + Version string } // NewModel constuctor for Model func NewModel(title, page string) *Model { - return &Model{title, page} + return &Model{title, page, Version} } // IndexModel is the model for index page diff --git a/main.go b/main.go index 48cf80e..8ca7ce8 100644 --- a/main.go +++ b/main.go @@ -75,9 +75,9 @@ func initApp() *BouquinsConf { } func assets(calibre string) { - http.Handle(bouquins.URLJs, http.FileServer(http.Dir("assets"))) - http.Handle(bouquins.URLCss, http.FileServer(http.Dir("assets"))) - http.Handle(bouquins.URLFonts, http.FileServer(http.Dir("assets"))) + http.Handle(bouquins.URLJs, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets")))) + http.Handle(bouquins.URLCss, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets")))) + http.Handle(bouquins.URLFonts, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets")))) http.Handle(bouquins.URLCalibre, http.StripPrefix(bouquins.URLCalibre, http.FileServer(http.Dir(calibre)))) } diff --git a/templates/footer.html b/templates/footer.html index 0655e9e..a8a3271 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,4 +1,4 @@ - - + + diff --git a/templates/header.html b/templates/header.html index fc2d93b..c4af0bf 100644 --- a/templates/header.html +++ b/templates/header.html @@ -4,11 +4,11 @@ {{ if .Title }}{{ .Title }} | {{ end }}Bouquins - - - - - + + + + +