Skip to content

Commit

Permalink
Add a file for the version.
Browse files Browse the repository at this point in the history
Also show the version number at the bottom of each page in the UI.
  • Loading branch information
bsiegert committed Sep 28, 2024
1 parent 4293083 commit 4774e1b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v2024.9
5 changes: 5 additions & 0 deletions bulktracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ var (
dbPath = flag.String("db_path", "BulkTracker.db", "The path to the SQLite database file.")
)

//go:embed VERSION
var version string

func init() {
flag.StringVar(&templates.BasePath, "base_path", "/", "The path under which to serve the UI, e.g. '/bulktracker/'.")

templates.Version = version
}

//go:embed images mock static robots.txt
Expand Down
7 changes: 7 additions & 0 deletions templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
</div>
</div>
<div style="background: #f0f0f0; padding-top: .5em; margin-top: 1em">
<div class="container">
<div class="row">
<p class="text-muted">Version {{.}}</p>
</div>
</div>
</div>
</body>
</html>
5 changes: 4 additions & 1 deletion templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var emb embed.FS
// main.
var BasePath = "/"

// Varsion is the current version string for this app. It is set from the main package.
var Version string

// bp is a shim type that avoids allocations in common templates.
type bp struct{}

Expand All @@ -60,7 +63,7 @@ func PageHeader(w io.Writer) {
}

func PageFooter(w io.Writer) {
t.ExecuteTemplate(w, "footer.html", nil)
t.ExecuteTemplate(w, "footer.html", &Version)
}

func PkgResults(w io.Writer) {
Expand Down

0 comments on commit 4774e1b

Please sign in to comment.