Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show version in login page #652

Merged
merged 3 commits into from Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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