diff --git a/pages/about.go b/pages/about.go index 962e0a6..e7ce9bd 100644 --- a/pages/about.go +++ b/pages/about.go @@ -39,6 +39,7 @@ func HandleAbout(c *fiber.Ctx) error { return c.Render("about", fiber.Map{ "title": "About this instance", + "branch": utils.Branch, "privacyInformation": privacyInfoArray, }) } diff --git a/pages/dirview.go b/pages/dirview.go index 31cebf7..baf4c7f 100644 --- a/pages/dirview.go +++ b/pages/dirview.go @@ -88,6 +88,7 @@ func DirView(c *fiber.Ctx) error { dirArray = append(dirArray, Scrape) return c.Render("dir", fiber.Map{ "title": "Directory " + c.Params("+") + " | " + c.Params("user") + "/" + c.Params("repo"), + "branch": utils.Branch, "dir": dirArray, "files": dirFilesArray, "readme": string(readmeOutput), diff --git a/pages/explore.go b/pages/explore.go index a425673..0606011 100644 --- a/pages/explore.go +++ b/pages/explore.go @@ -36,7 +36,8 @@ func HandleExplore(c *fiber.Ctx) error { } return c.Render("explore", fiber.Map{ - "title": "Explore", - "repos": trendingReposArray, + "title": "Explore", + "branch": utils.Branch, + "repos": trendingReposArray, }) } diff --git a/pages/fileview.go b/pages/fileview.go index 514003e..0f46016 100644 --- a/pages/fileview.go +++ b/pages/fileview.go @@ -3,14 +3,14 @@ package pages import ( "bufio" "bytes" + "codeberg.org/gothub/gothub/utils" "context" - "html/template" - htmlfmt "github.com/alecthomas/chroma/v2/formatters/html" "github.com/alecthomas/chroma/v2/lexers" "github.com/alecthomas/chroma/v2/styles" "github.com/carlmjohnson/requests" "github.com/gofiber/fiber/v2" + "html/template" ) // FileView is the file view page @@ -57,11 +57,12 @@ func FileView(c *fiber.Ctx) error { writer.Flush() cssw.Flush() return c.Render("file", fiber.Map{ - "title": c.Params("+") + " | " + c.Params("user") + "/" + c.Params("repo"), - "file": template.HTML(buf.String()), - "css": template.CSS(cssbuf.String()), - "fullname": c.Params("user") + "/" + c.Params("repo"), - "name": c.Params("+"), - "branch": c.Params("branch"), + "title": c.Params("+") + " | " + c.Params("user") + "/" + c.Params("repo"), + "branch": utils.Branch, + "file": template.HTML(buf.String()), + "css": template.CSS(cssbuf.String()), + "fullname": c.Params("user") + "/" + c.Params("repo"), + "name": c.Params("+"), + "fileBranch": c.Params("branch"), }) } diff --git a/pages/gist.go b/pages/gist.go index 71d755b..350800c 100644 --- a/pages/gist.go +++ b/pages/gist.go @@ -3,6 +3,7 @@ package pages import ( "bufio" "bytes" + "codeberg.org/gothub/gothub/utils" "context" htmlfmt "github.com/alecthomas/chroma/v2/formatters/html" "github.com/alecthomas/chroma/v2/lexers" @@ -131,8 +132,9 @@ func HandleGist(c *fiber.Ctx) error { gistArray = append(gistArray, Scrape) return c.Render("gist", fiber.Map{ - "title": "Repository " + c.Params("user") + "/" + c.Params("gistID"), - "gist": gistArray, - "files": gistFilesArray, + "title": "Repository " + c.Params("user") + "/" + c.Params("gistID"), + "branch": utils.Branch, + "gist": gistArray, + "files": gistFilesArray, }) } diff --git a/pages/index.go b/pages/index.go index d3c5fab..6796c61 100644 --- a/pages/index.go +++ b/pages/index.go @@ -11,6 +11,7 @@ import ( func HandleIndex(c *fiber.Ctx) error { return c.Render("index", fiber.Map{ "host": c.Hostname(), + "branch": utils.Branch, "version": utils.Version(), "fiberversion": fiber.Version, "goversion": runtime.Version(), diff --git a/pages/repo.go b/pages/repo.go index 858397c..c7dc8d6 100644 --- a/pages/repo.go +++ b/pages/repo.go @@ -121,6 +121,7 @@ func HandleRepo(c *fiber.Ctx) error { repoArray = append(repoArray, Scrape) return c.Render("repo", fiber.Map{ "title": c.Params("user") + "/" + repoUrl + branchExists, + "branch": utils.Branch, "repo": repoArray, "files": repoFilesArray, "readme": readmeOutput, diff --git a/pages/user.go b/pages/user.go index bff5636..a96b2ce 100644 --- a/pages/user.go +++ b/pages/user.go @@ -181,7 +181,8 @@ func HandleUser(c *fiber.Ctx) error { userArray = append(userArray, Scrape) return c.Render("user", fiber.Map{ - "title": c.Params("user"), - "user": userArray, + "title": c.Params("user"), + "branch": utils.Branch, + "user": userArray, }) } diff --git a/serve/serve.go b/serve/serve.go index 4b2fc6c..fa39b43 100644 --- a/serve/serve.go +++ b/serve/serve.go @@ -47,8 +47,9 @@ func Serve(port string) { } _, link := regexp.MatchString(`\/.*\ `, err.Error()) err = ctx.Status(code).Render("error", fiber.Map{ - "error": err, - "link": link, + "error": err, + "link": link, + "branch": utils.Branch, }) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") @@ -73,7 +74,8 @@ func Serve(port string) { Expiration: 5 * time.Minute, LimitReached: func(c *fiber.Ctx) error { return c.Status(429).Render("ratelimit_gt", fiber.Map{ - "Title": "Rate limit exceeded", + "Title": "Rate limit exceeded", + "branch": utils.Branch, }) }, }) diff --git a/utils/version.go b/utils/version.go index a45512a..39b6090 100644 --- a/utils/version.go +++ b/utils/version.go @@ -4,6 +4,8 @@ import ( "runtime/debug" ) +var Branch = "Alpha" + // Version returns the git commit hash of the current build. Taken from https://git.vern.cc/pjals/bestofbot. func Version() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/views/file.html b/views/file.html index 7f178a4..75be538 100644 --- a/views/file.html +++ b/views/file.html @@ -11,7 +11,7 @@ }
- Back to {{.fullname}}
diff --git a/views/header.html b/views/header.html index 57dd5d3..8d28837 100644 --- a/views/header.html +++ b/views/header.html @@ -20,7 +20,7 @@ height="30" width="30" alt="" - >GotHub (alpha)GotHub ({{.branch}})