From 85465406cec147bc89faa9c44316f2abe42108f0 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Wed, 27 Dec 2023 13:31:00 -0600 Subject: [PATCH] Working middleware/route to handle module requests from 'go get' --- Makefile | 2 +- input.go | 3 +++ routes.go | 10 +++++++--- templates/repo_detail.html | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 templates/repo_detail.html diff --git a/Makefile b/Makefile index 913ad9f..39556b7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION?=`hg log -r . -T "{latesttag}{sub('^-0-.*', '', '-{latesttagdistance}-{node|short}')}" || echo 0.1.0` +VERSION?=`git describe 2>/dev/null || git rev-parse --short HEAD` GO?=go GOFLAGS?= LDFLAGS+=-X main.Version=$(VERSION) diff --git a/input.go b/input.go index 73cc735..fc7d7cc 100644 --- a/input.go +++ b/input.go @@ -76,6 +76,9 @@ func (l *LoginForm) Validate(c echo.Context) error { var RepoTypes = []string{ "git", "hg", + "bzr", + "fossil", + "svn", } // RepoForm ... diff --git a/routes.go b/routes.go index baeac03..7e7276e 100644 --- a/routes.go +++ b/routes.go @@ -24,6 +24,7 @@ type Service struct { } func (s *Service) RegisterRoutes() { + s.eg.Use(RepoMiddleware) s.eg.GET("/--admin--/set-password", s.SetPassword).Name = s.RouteName("set_password") s.eg.POST("/--admin--/set-password", s.SetPassword).Name = s.RouteName("set_password_post") s.eg.GET("/--admin--/login", s.Login).Name = s.RouteName("login") @@ -234,7 +235,7 @@ func GetRepoFromPath(c echo.Context, path string) error { repo *Repo rname string ) - for i := 0; i < 3; i++ { + for i := 0; i < len(parts); i++ { // XXX Is this even needed? Should it just be the first value (parts[0])? rname = strings.Join(parts[:i+1], "/") opts := &database.FilterOptions{ @@ -268,11 +269,14 @@ func GetRepoFromPath(c echo.Context, path string) error { } rdomain := fmt.Sprintf("%s%s", gctx.Server.Config.Domain, fpath) return c.HTML(http.StatusOK, - fmt.Sprintf(``, + fmt.Sprintf(``, rdomain, repo.RepoType, repo.RepoURL), ) } - gmap := gobwebs.Map{"repo": repo} + gmap := gobwebs.Map{ + "repo": repo, + "hideNav": true, + } return gctx.Render(http.StatusOK, "repo_detail.html", gmap) } diff --git a/templates/repo_detail.html b/templates/repo_detail.html new file mode 100644 index 0000000..386ae1b --- /dev/null +++ b/templates/repo_detail.html @@ -0,0 +1,36 @@ +{{template "base" .}} +
+

{{.repo.Name}} ({{ .repo.RepoName }})

+
+ +
+
+
+
+

Description:

+
+

{{ .repo.Description }}

+
+
+
+
+
+
+
+

Details:

+
+

Repo URL:
{{ .repo.RepoURL }} ({{ .repo.RepoType }})

+

Repo Homepage:
{{ if .repo.Homepage }}{{ .repo.Homepage }}{{ else }}N/A{{ end }}

+
+
+
+
+
+

Extras:

+
+

Issue Tracker:
{{ if .repo.IssuesURL }}{{ .repo.IssuesURL }}{{ else }}N/A{{ end }}

+

Mailing List:
{{ if .repo.MailURL }}{{ .repo.MailURL }}{{ else }}N/A{{ end }}

+
+
+
+{{template "base_footer" .}} -- 2.45.2