version string in js url (cache)

This commit is contained in:
Meutel 2017-09-05 16:54:25 +02:00
parent 50df43eac6
commit e3afa3a6b5
5 changed files with 19 additions and 18 deletions

View File

@ -6,8 +6,6 @@ Bouquins in Go
* translations * translations
* tests * tests
* UI book: cover in background
* auth downloads * auth downloads
* version string in js url (cache)
* csrf * csrf
* vue.js dev/prod * vue.js dev/prod

View File

@ -16,6 +16,8 @@ import (
) )
const ( const (
Version = "master"
tplBooks = "book.html" tplBooks = "book.html"
tplAuthors = "author.html" tplAuthors = "author.html"
tplSeries = "series.html" tplSeries = "series.html"
@ -43,11 +45,11 @@ const (
// URLAbout url of about page // URLAbout url of about page
URLAbout = "/about/" URLAbout = "/about/"
// URLJs url of js assets // URLJs url of js assets
URLJs = "/js/" URLJs = "/" + Version + "/js/"
// URLCss url of css assets // URLCss url of css assets
URLCss = "/css/" URLCss = "/" + Version + "/css/"
// URLFonts url of fonts assets // URLFonts url of fonts assets
URLFonts = "/fonts/" URLFonts = "/" + Version + "/fonts/"
// URLCalibre url of calibre resources (covers, ebooks files) // URLCalibre url of calibre resources (covers, ebooks files)
URLCalibre = "/calibre/" URLCalibre = "/calibre/"
) )
@ -136,13 +138,14 @@ type SeriesFull struct {
// Model is basic page model // Model is basic page model
type Model struct { type Model struct {
Title string Title string
Page string Page string
Version string
} }
// NewModel constuctor for Model // NewModel constuctor for Model
func NewModel(title, page string) *Model { func NewModel(title, page string) *Model {
return &Model{title, page} return &Model{title, page, Version}
} }
// IndexModel is the model for index page // IndexModel is the model for index page

View File

@ -75,9 +75,9 @@ func initApp() *BouquinsConf {
} }
func assets(calibre string) { func assets(calibre string) {
http.Handle(bouquins.URLJs, http.FileServer(http.Dir("assets"))) http.Handle(bouquins.URLJs, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets"))))
http.Handle(bouquins.URLCss, http.FileServer(http.Dir("assets"))) http.Handle(bouquins.URLCss, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets"))))
http.Handle(bouquins.URLFonts, 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)))) http.Handle(bouquins.URLCalibre, http.StripPrefix(bouquins.URLCalibre, http.FileServer(http.Dir(calibre))))
} }

View File

@ -1,4 +1,4 @@
<script src="/js/vue.js"></script> <script src="/{{ .Version }}/js/vue.js"></script>
<script src="/js/bouquins.js"></script> <script src="/{{ .Version }}/js/bouquins.js"></script>
</body> </body>
</html> </html>

View File

@ -4,11 +4,11 @@
<title>{{ if .Title }}{{ .Title }} | {{ end }}Bouquins</title> <title>{{ if .Title }}{{ .Title }} | {{ end }}Bouquins</title>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/{{ .Version }}/css/bootstrap.min.css">
<link rel="preload" href="/js/vue.js" as="script"> <link rel="preload" href="/{{ .Version }}/js/vue.js" as="script">
<link rel="prefetch" href="/js/vue.js"> <link rel="prefetch" href="/{{ .Version }}/js/vue.js">
<link rel="preload" href="/js/bouquins.js" as="script"> <link rel="preload" href="/{{ .Version }}/js/bouquins.js" as="script">
<link rel="prefetch" href="/js/bouquins.js"> <link rel="prefetch" href="/{{ .Version }}/js/bouquins.js">
</head> </head>
<body> <body>
<nav class="navbar navbar-inverse" id="nav"> <nav class="navbar navbar-inverse" id="nav">