Show if a new version is available in the menu bar

This commit is contained in:
Justin Hawkins 2022-06-05 12:04:47 +09:30
parent dab54bdeaa
commit 8c8a57433e
3 changed files with 18 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import (
"golang.org/x/mod/semver"
)
const Tag = "v0.0.17"
const Tag = "v0.0.18"
var versionInfo struct {
Local struct {
@ -40,7 +40,14 @@ func UpgradeAvailable() (bool, string) {
return true, versionInfo.Remote.Tag
}
return false, ""
}
func UpgradeAvailableString() string {
upgrade, ver := UpgradeAvailable()
if upgrade {
return ver
}
return ""
}
func UpdateVersionInfo() {

View File

@ -34,10 +34,17 @@
</div>
<div class="top-bar-right">
<ul class="menu">
{{ if newVersion }}
<li>
<div><a href="https://github.com/tardisx/linkwallet/releases/tag/{{ newVersion }}">{{ newVersion }} available</a></div>
</li>
{{ end }}
<li class="menu-text">
{{ version }}
</li>
<li>
<a href="https://github.com/tardisx/linkwallet">
{{ version }}
<img src="/assets/image/GitHub-Mark-32px.png" />
<img src="/assets/image/GitHub-Mark-32px.png" width="16px" height="16px"/>
</a>
</li>
<!-- <li><input type="search" placeholder="Search"></li>

View File

@ -51,7 +51,7 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
}
// templ := template.Must(template.New("").Funcs(template.FuncMap{"dict": dictHelper}).ParseFS(templateFiles, "templates/*.html"))
templ := template.Must(template.New("").Funcs(template.FuncMap{"nicetime": niceTime, "niceURL": niceURL, "join": strings.Join, "version": version.Is}).ParseFS(templateFiles, "templates/*.html"))
templ := template.Must(template.New("").Funcs(template.FuncMap{"nicetime": niceTime, "niceURL": niceURL, "join": strings.Join, "version": version.Is, "newVersion": version.UpgradeAvailableString}).ParseFS(templateFiles, "templates/*.html"))
config, err := cmm.LoadConfig()
if err != nil {