Skip to content

Commit

Permalink
Show version in login page (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Jul 21, 2023
1 parent 7776881 commit c5c7a5f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/version.go
Expand Up @@ -17,6 +17,6 @@ func newVersionCommand() *cobra.Command {

func newVersionCommandHandler() 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)
}
}
3 changes: 3 additions & 0 deletions internal/http/routes/frontend.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/go-shiori/shiori/internal/config"
"github.com/go-shiori/shiori/internal/model"
views "github.com/go-shiori/shiori/internal/view"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -65,11 +66,13 @@ func (r *FrontendRoutes) Setup(e *gin.Engine) {
group.GET("/login", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "login.html", gin.H{
"RootPath": r.cfg.Http.RootPath,
"Version": model.BuildVersion,
})
})
group.GET("/", func(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "index.html", gin.H{
"RootPath": r.cfg.Http.RootPath,
"Version": model.BuildVersion,
})
})
e.StaticFS("/assets", newAssetsFS(r.logger, views.Assets))
Expand Down
6 changes: 3 additions & 3 deletions internal/http/routes/system.go
Expand Up @@ -22,9 +22,9 @@ func (r *SystemRoutes) livenessHandler(c *gin.Context) {
Commit string `json:"commit"`
Date string `json:"date"`
}{
Version: model.Version,
Commit: model.Commit,
Date: model.Date,
Version: model.BuildVersion,
Commit: model.BuildCommit,
Date: model.BuildDate,
})
}

Expand Down
6 changes: 3 additions & 3 deletions internal/model/main.go
Expand Up @@ -2,7 +2,7 @@ package model

// Variables set my the main package coming from ldflags
var (
Version = "dev"
Commit = "none"
Date = "unknown"
BuildVersion = "dev"
BuildCommit = "none"
BuildDate = "unknown"
)
3 changes: 3 additions & 0 deletions internal/view/login.html
Expand Up @@ -50,6 +50,9 @@
</div>
</form>
</div>
<div>
<p>$$.Version$$</p>
</div>
</div>

<script type="module">
Expand Down
6 changes: 3 additions & 3 deletions main.go
Expand Up @@ -24,9 +24,9 @@ var (

func init() {
// Set globally
model.Version = version
model.Commit = commit
model.Date = date
model.BuildVersion = version
model.BuildCommit = commit
model.BuildDate = date
}

func main() {
Expand Down

0 comments on commit c5c7a5f

Please sign in to comment.