Show version in login page

This commit is contained in:
Felipe M 2023-07-20 08:40:04 +02:00
parent 454f21789d
commit 33c1c3805d
No known key found for this signature in database
GPG key ID: CCFBC5637D4000A8
6 changed files with 17 additions and 11 deletions

View file

@ -17,6 +17,6 @@ func newVersionCommand() *cobra.Command {
func newVersionCommandHandler() func(cmd *cobra.Command, args []string) { func newVersionCommandHandler() func(cmd *cobra.Command, args []string) {
return func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) {
cmd.Printf("Shiori version %s (build %s) at %s\n", model.Version, model.Commit, model.Date) cmd.Printf("Shiori version %s (build %s) at %s\n", model.BuildVersion, model.BuildCommit, model.BuildDate)
} }
} }

View file

@ -10,6 +10,7 @@ import (
"github.com/gin-contrib/static" "github.com/gin-contrib/static"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-shiori/shiori/internal/config" "github.com/go-shiori/shiori/internal/config"
"github.com/go-shiori/shiori/internal/model"
views "github.com/go-shiori/shiori/internal/view" views "github.com/go-shiori/shiori/internal/view"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -65,11 +66,13 @@ func (r *FrontendRoutes) Setup(e *gin.Engine) {
group.GET("/login", func(ctx *gin.Context) { group.GET("/login", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "login.html", gin.H{ ctx.HTML(http.StatusOK, "login.html", gin.H{
"RootPath": r.cfg.Http.RootPath, "RootPath": r.cfg.Http.RootPath,
"Version": model.BuildVersion,
}) })
}) })
group.GET("/", func(ctx *gin.Context) { group.GET("/", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "index.html", gin.H{ ctx.HTML(http.StatusOK, "index.html", gin.H{
"RootPath": r.cfg.Http.RootPath, "RootPath": r.cfg.Http.RootPath,
"Version": model.BuildVersion,
}) })
}) })
e.StaticFS("/assets", newAssetsFS(r.logger, views.Assets)) e.StaticFS("/assets", newAssetsFS(r.logger, views.Assets))

View file

@ -22,9 +22,9 @@ func (r *SystemRoutes) livenessHandler(c *gin.Context) {
Commit string `json:"commit"` Commit string `json:"commit"`
Date string `json:"date"` Date string `json:"date"`
}{ }{
Version: model.Version, Version: model.BuildVersion,
Commit: model.Commit, Commit: model.BuildCommit,
Date: model.Date, Date: model.BuildDate,
}) })
} }

View file

@ -2,7 +2,7 @@ package model
// Variables set my the main package coming from ldflags // Variables set my the main package coming from ldflags
var ( var (
Version = "dev" BuildVersion = "dev"
Commit = "none" BuildCommit = "none"
Date = "unknown" BuildDate = "unknown"
) )

View file

@ -15,7 +15,7 @@
<link rel="icon" type="image/x-icon" href="assets/res/favicon.ico"> <link rel="icon" type="image/x-icon" href="assets/res/favicon.ico">
<link href="assets/css/source-sans-pro.min.css" rel="stylesheet"> <link href="assets/css/source-sans-pro.min.css" rel="stylesheet">
<link href="assets/css/fontawesome.min.css" rel="stylesheet">w <link href="assets/css/fontawesome.min.css" rel="stylesheet">
<link href="assets/css/stylesheet.css" rel="stylesheet"> <link href="assets/css/stylesheet.css" rel="stylesheet">
<script src="assets/js/vue.min.js"></script> <script src="assets/js/vue.min.js"></script>
@ -50,6 +50,9 @@
</div> </div>
</form> </form>
</div> </div>
<div>
<p>$$.Version$$</p>
</div>
</div> </div>
<script type="module"> <script type="module">

View file

@ -24,9 +24,9 @@ var (
func init() { func init() {
// Set globally // Set globally
model.Version = version model.BuildVersion = version
model.Commit = commit model.BuildCommit = commit
model.Date = date model.BuildDate = date
} }
func main() { func main() {