From 7da420482b95f50cff7afbbfcf89c512cafbf5e2 Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Thu, 8 Jun 2023 15:18:17 +0800
Subject: [PATCH 1/5] make forkof repos not look broken (fixes #122)
---
views/user.html | 51 ++++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/views/user.html b/views/user.html
index 90b6674..3e3f9ae 100644
--- a/views/user.html
+++ b/views/user.html
@@ -74,27 +74,38 @@
{{ end }} {{ if .MainRepos }}
{{.PinOrPopular}} repositories
- {{range .MainRepos}}
-
-
- {{if .ForkOf}} Forked from: {{.ForkOf}}
- {{else}} {{end}} {{if .Desc}} {{if eq .Type "Gist"}}
-
-
{{.Desc}}
+ {{range .MainRepos}} {{ if .ForkOf }}
+
+ {{end}} {{ end }}
{{ end }} {{ end }} {{ else }}
User not found
From cc451e1c0e474559d4b335218919450cedc608c8 Mon Sep 17 00:00:00 2001
From: TechnicalSuwako
Date: Thu, 8 Jun 2023 07:21:06 +0000
Subject: [PATCH 2/5] add language bar (#121)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
#120
Co-authored-by: 諏訪子
Reviewed-on: https://codeberg.org/gothub/gothub/pulls/121
Co-authored-by: TechnicalSuwako
Co-committed-by: TechnicalSuwako
---
pages/repo.go | 14 ++++++++++++--
public/css/global.css | 14 ++++++++++++++
views/repo.html | 10 +++++++++-
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/pages/repo.go b/pages/repo.go
index c7dc8d6..908b82d 100644
--- a/pages/repo.go
+++ b/pages/repo.go
@@ -11,6 +11,12 @@ import (
"github.com/gofiber/fiber/v2"
)
+type Languages struct {
+ Name string
+ Percent string
+ Color string
+}
+
type Repo struct {
Fullname string
Description string
@@ -19,7 +25,7 @@ type Repo struct {
Forks string
CommitsBehind string
Watchers string
- Language []string
+ Language []Languages
License string
DefaultBranch string
Readme string
@@ -90,7 +96,11 @@ func HandleRepo(c *fiber.Ctx) error {
})
sc.OnHTML("div.BorderGrid-cell ul.list-style-none", func(e *colly.HTMLElement) {
e.ForEach("li.d-inline .d-inline-flex", func(i int, el *colly.HTMLElement) {
- Scrape.Language = append(Scrape.Language, el.ChildText("span.text-bold")+" "+el.ChildText("span:contains('%')"))
+ var lang Languages
+ lang.Name = el.ChildText("span.text-bold")
+ lang.Percent = el.ChildText("span:contains('%')")
+ lang.Color = strings.ReplaceAll(strings.ReplaceAll(el.ChildAttr("svg", "style"), "color:", ""), ";", "")
+ Scrape.Language = append(Scrape.Language, lang)
})
})
sc.OnHTML("div#repository-container-header", func(e *colly.HTMLElement) {
diff --git a/public/css/global.css b/public/css/global.css
index b01effb..67e3ebf 100644
--- a/public/css/global.css
+++ b/public/css/global.css
@@ -211,6 +211,20 @@ a:hover {
color: var(--text);
}
+.lang-bar:last-child {
+ margin-bottom: 0;
+}
+
+.lang-bar {
+ width: 100%;
+ display: inherit;
+ height: 10px;
+ border-radius:4px;
+ overflow: hidden; /* To force the corners to be round. */
+ user-select: none; /* Prevent the selection */
+ -webkit-user-select: none; /* Safari specific fix. */
+}
+
/* URI: /:user/:repo */
.button {
background-color: var(--background);
diff --git a/views/repo.html b/views/repo.html
index e5816de..ff1ff36 100644
--- a/views/repo.html
+++ b/views/repo.html
@@ -31,7 +31,15 @@
{{.DefaultBranch}}
{{ end }} {{ if .Language }}
- 🗒️ {{range .Language}} {{.}} {{end}}
+
+ {{range $o := .Language}}{{$o.Name}} {{$o.Percent}}, {{end}}
+
{{range $i, $o := .Language}}
+
+
+
+ {{end}}
+
+
{{end}} {{ if .CommitsBehind }} This repository is {{.CommitsBehind}}
commits behind its parent. {{end}}
From d9f01b80d8694ce5ff485cce442344cff37dd7f0 Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Thu, 8 Jun 2023 15:34:43 +0800
Subject: [PATCH 3/5] gofmt + fix commits behind/ahead
---
pages/repo.go | 22 ++++++++++++----------
views/repo.html | 24 ++++++++++++++----------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/pages/repo.go b/pages/repo.go
index 908b82d..8d6e844 100644
--- a/pages/repo.go
+++ b/pages/repo.go
@@ -12,9 +12,9 @@ import (
)
type Languages struct {
- Name string
- Percent string
- Color string
+ Name string
+ Percent string
+ Color string
}
type Repo struct {
@@ -24,8 +24,9 @@ type Repo struct {
Stars string
Forks string
CommitsBehind string
+ CommitsAhead string
Watchers string
- Language []Languages
+ Language []Languages
License string
DefaultBranch string
Readme string
@@ -85,7 +86,8 @@ func HandleRepo(c *fiber.Ctx) error {
})
})
sc.OnHTML("div.Box-body div.d-flex div span", func(e *colly.HTMLElement) {
- Scrape.CommitsBehind = strings.TrimSuffix(e.ChildText("a"), " commits behind")
+ Scrape.CommitsBehind = strings.TrimSuffix(e.ChildText("a[data-analytics-event*='Behind Compare']"), " commits behind")
+ Scrape.CommitsAhead = strings.TrimSuffix(e.ChildText("a[data-analytics-event*='Ahead Compare']"), " commits ahead")
})
sc.OnHTML("div#readme", func(e *colly.HTMLElement) {
Scrape.Readme = e.ChildText("a[href='#readme']")
@@ -96,11 +98,11 @@ func HandleRepo(c *fiber.Ctx) error {
})
sc.OnHTML("div.BorderGrid-cell ul.list-style-none", func(e *colly.HTMLElement) {
e.ForEach("li.d-inline .d-inline-flex", func(i int, el *colly.HTMLElement) {
- var lang Languages
- lang.Name = el.ChildText("span.text-bold")
- lang.Percent = el.ChildText("span:contains('%')")
- lang.Color = strings.ReplaceAll(strings.ReplaceAll(el.ChildAttr("svg", "style"), "color:", ""), ";", "")
- Scrape.Language = append(Scrape.Language, lang)
+ var lang Languages
+ lang.Name = el.ChildText("span.text-bold")
+ lang.Percent = el.ChildText("span:contains('%')")
+ lang.Color = strings.ReplaceAll(strings.ReplaceAll(el.ChildAttr("svg", "style"), "color:", ""), ";", "")
+ Scrape.Language = append(Scrape.Language, lang)
})
})
sc.OnHTML("div#repository-container-header", func(e *colly.HTMLElement) {
diff --git a/views/repo.html b/views/repo.html
index ff1ff36..fbcef1c 100644
--- a/views/repo.html
+++ b/views/repo.html
@@ -30,18 +30,22 @@
⭐ {{.Stars}} 🍴 {{.Forks}} 👀 {{.Watchers}} ⚖️ No license 🌿
{{.DefaultBranch}}
- {{ end }} {{ if .Language }}
+ {{ end }} {{ if .Language }} {{range $o := .Language}}{{$o.Name}}
+ {{$o.Percent}}, {{end}}
+
+ {{range $i, $o := .Language}}
+
+
+
+ {{end}}
+
+ {{end}} {{ if or .CommitsAhead .CommitsBehind }}
- {{range $o := .Language}}{{$o.Name}} {{$o.Percent}}, {{end}}
-
{{range $i, $o := .Language}}
-
-
-
- {{end}}
-
+ This repository is {{if .CommitsBehind}} {{.CommitsBehind}} commits behind {{end}} {{if and .CommitsBehind .CommitsAhead}} and {{end}}
+ {{if .CommitsAhead}} {{ .CommitsAhead }} commits ahead of {{end}} its
+ parent.
- {{end}} {{ if .CommitsBehind }} This repository is {{.CommitsBehind}}
- commits behind its parent. {{end}}
+ {{end}}
{{end}} {{ if .files}}
From 29e4ec180fe0a2cf62fdecea5cf5837a3cfe7f0b Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Tue, 13 Jun 2023 12:47:00 +0530
Subject: [PATCH 4/5] lunar.icu is no longer cloudflared
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index fb08b99..c191728 100644
--- a/README.md
+++ b/README.md
@@ -37,11 +37,11 @@ The `master` branch runs on the master branch of GotHub. This means that the ins
| Link | Cloudflare | Country | ISP | Branch |
| -------- | ---------- | ----------- | ----- | ----- |
| [gh.akisblack.dev](https://gh.akisblack.dev) | No | Germany | OVHcloud | master |
+| [gh.bloatcat.tk](https://gh.bloatcat.tk) | No | Iceland | 1984 | master |
+| [gothub.lunar.icu](https://gothub.lunar.icu) | No | Germany | Unesty | master |
| [gothub.no-logs.com](https://gothub.no-logs.com/) | No | Sweden | Vultr | master |
| [gothub.projectsegfau.lt](https://gothub.projectsegfau.lt) | No | GeoDNS (Luxembourg/USA/India) | BuyVM/Digital Ocean/Airtel | master |
-| [gh.bloatcat.tk](https://gh.bloatcat.tk) | No | Iceland | 1984 | master |
| [gh.fascinated.cc](https://gh.fascinated.cc) | Yes | Germany | Contabo | master |
-| [gothub.lunar.icu](https://gothub.lunar.icu) | Yes | Germany | Unesty | master |
| [gh.whateveritworks.org](https://gh.whateveritworks.org) | Yes | Germany | Hetzner | master |
| [dev.gh.akisblack.dev](https://dev.gh.akisblack.dev) | No | Germany | OVHcloud | dev |
| [gh.creller.net](https://gh.creller.net) | No | Scotland | British Telecommunications PLC | dev |
From 623fd42e45db8b45f5ca71a56e35b42f9139f934 Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Tue, 13 Jun 2023 12:54:58 +0530
Subject: [PATCH 5/5] lunar.icu new provider
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c191728..2c55356 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ The `master` branch runs on the master branch of GotHub. This means that the ins
| -------- | ---------- | ----------- | ----- | ----- |
| [gh.akisblack.dev](https://gh.akisblack.dev) | No | Germany | OVHcloud | master |
| [gh.bloatcat.tk](https://gh.bloatcat.tk) | No | Iceland | 1984 | master |
-| [gothub.lunar.icu](https://gothub.lunar.icu) | No | Germany | Unesty | master |
+| [gothub.lunar.icu](https://gothub.lunar.icu) | No | Germany | Avoro | master |
| [gothub.no-logs.com](https://gothub.no-logs.com/) | No | Sweden | Vultr | master |
| [gothub.projectsegfau.lt](https://gothub.projectsegfau.lt) | No | GeoDNS (Luxembourg/USA/India) | BuyVM/Digital Ocean/Airtel | master |
| [gh.fascinated.cc](https://gh.fascinated.cc) | Yes | Germany | Contabo | master |