From 9a78584dcc8b8bc3c649ca10f935562e350cdbab Mon Sep 17 00:00:00 2001 From: Marvin Wendt Date: Wed, 13 Sep 2023 14:56:46 +0200 Subject: [PATCH] update website --- internal/pkg/handlers/page.go | 16 ++++ main.go | 5 +- templates/repo-maintainer.gohtml | 121 +++++++++++++++++++++++++++++++ templates/repo.gohtml | 43 ++--------- 4 files changed, 147 insertions(+), 38 deletions(-) create mode 100644 templates/repo-maintainer.gohtml diff --git a/internal/pkg/handlers/page.go b/internal/pkg/handlers/page.go index 88f917d..ca3895e 100644 --- a/internal/pkg/handlers/page.go +++ b/internal/pkg/handlers/page.go @@ -28,6 +28,22 @@ func RepoStatsPage(c *fiber.Ctx) error { }) } +func RepoMaintainerPage(c *fiber.Ctx) error { + owner, repo := getOwnerAndRepo(c) + linux, windows, macos, err := getInstallationCountPerPlatform(owner, repo) + if err != nil { + return err + } + return c.Render("repo-maintainer.gohtml", map[string]any{ + "Windows": windows, + "Linux": linux, + "MacOS": macos, + "Total": linux + windows + macos, + "Owner": owner, + "Repo": repo, + }) +} + type Stat struct { Owner string Repo string diff --git a/main.go b/main.go index 63573af..fd3d140 100644 --- a/main.go +++ b/main.go @@ -87,12 +87,11 @@ func main() { shieldsIOAPIV1.Get("/stats/total", handlers.AllStatsTotalBadge) // Stats - // - Stats landing page app.Get("/stats", handlers.AllStatsPage) app.Get("/stats/:any", func(ctx *fiber.Ctx) error { return ctx.SendStatus(404) }) - // - Legacy redirect + app.Get("/stats/:user/:repo", handlers.RedirectLegacyStats) // Legacy redirect app.Get("/:user/:repo", handlers.RepoStatsPage) - app.Get("/stats/:user/:repo", handlers.RedirectLegacyStats) + app.Get("/:user/:repo/maintainer", handlers.RepoMaintainerPage) // Installation script generator app.Get("/:user/:repo/:os", handlers.Installation) diff --git a/templates/repo-maintainer.gohtml b/templates/repo-maintainer.gohtml new file mode 100644 index 0000000..ae6b974 --- /dev/null +++ b/templates/repo-maintainer.gohtml @@ -0,0 +1,121 @@ +{{template "base" .}} + +{{define "title"}}Maintainer view for {{.Owner}}/{{.Repo}}{{end}} + +{{ define "content"}} +
+
+

+ Maintainer view for + github.com/{{.Owner}}/{{.Repo}} +

+

User view

+
+
+
+
+ This is the maintainer view for + github.com/{{.Owner}}/{{.Repo}}. + If you are not a maintainer of the repository, you might find the + user view more interesting. +
+ +

Badges

+ + + +
+

Install with instl.sh

+

+ + install with instl.sh + +

+
+
[![install with instl.sh](https://img.shields.io/badge/install_with-instl.sh-blue?link=https://instl.sh/{{.Owner}}/{{.Repo}}&style=for-the-badge)](https://instl.sh/{{.Owner}}/{{.Repo}})
+ +
+

Installation count

+

+ + install count + +

+
[![install count](https://img.shields.io/endpoint?url=https://instl.sh/api/v1/badge/shields.io/stats/{{.Owner}}/{{.Repo}}&style=for-the-badge)](https://instl.sh/{{.Owner}}/{{.Repo}})
+ +

Installation Commands

+ +

Table

+

+| Platform | Command |
+| -------- | ------- |
+| Windows  | iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex |
+| macOS    | curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash |
+| Linux    | curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash |
+
+> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
+
+ +

Headings

+

+#### Windows
+```powershell
+iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex
+```
+
+#### macOS
+```bash
+curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash
+```
+
+#### Linux
+```bash
+curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash
+```
+
+> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
+
+ +
+ + +{{end}} diff --git a/templates/repo.gohtml b/templates/repo.gohtml index 8430762..12031a1 100644 --- a/templates/repo.gohtml +++ b/templates/repo.gohtml @@ -6,7 +6,7 @@

Installer for github.com/{{.Owner}}/{{.Repo}}

-

+

@@ -62,41 +62,13 @@
-

Markdown

-

Markdown presets for your README!

+

Maintainer

+

Maintaining {{.Owner}}/{{.Repo}}?

- -

Table

-

-| Platform | Command |
-| -------- | ------- |
-| Windows  | iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex |
-| macOS    | curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash |
-| Linux    | curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash |
-
-> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
-
- -

Headings

-

-#### Windows
-```powershell
-iwr instl.sh/{{.Owner}}/{{.Repo}}/windows | iex
-```
-
-#### macOS
-```bash
-curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/macos | bash
-```
-
-#### Linux
-```bash
-curl -sSL instl.sh/{{.Owner}}/{{.Repo}}/linux | bash
-```
-
-> [📊 Install stats](https://instl.sh/{{.Owner}}/{{.Repo}})
-
- +

+ If you are a maintainer of github.com/{{.Owner}}/{{.Repo}}, + you can check out the maintainer page of this repo for + customized badges and Markdown snippets.