diff --git a/README.md b/README.md index fb08b99..2c55356 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 | 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.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 | diff --git a/pages/repo.go b/pages/repo.go index c7dc8d6..8d6e844 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 @@ -18,8 +24,9 @@ type Repo struct { Stars string Forks string CommitsBehind string + CommitsAhead string Watchers string - Language []string + Language []Languages License string DefaultBranch string Readme string @@ -79,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']") @@ -90,7 +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) { - 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 88b4889..f89f031 100644 --- a/public/css/global.css +++ b/public/css/global.css @@ -234,6 +234,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..fbcef1c 100644 --- a/views/repo.html +++ b/views/repo.html @@ -30,10 +30,22 @@ ⭐ {{.Stars}} 🍴 {{.Forks}} 👀 {{.Watchers}} ⚖️ No license 🌿 {{.DefaultBranch}}
- {{ end }} {{ if .Language }} -🗒️ {{range .Language}} {{.}} {{end}}
- {{end}} {{ if .CommitsBehind }} This repository is {{.CommitsBehind}} - commits behind its parent. {{end}} + {{ end }} {{ if .Language }} {{range $o := .Language}}{{$o.Name}} + {{$o.Percent}}, {{end}} + + {{end}} {{ if or .CommitsAhead .CommitsBehind }} ++ 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}} {{end}} {{ if .files}}{{.Name}} ({{.Type}})
- {{if .ForkOf}} Forked from: {{.ForkOf}} - {{else}} {{end}} {{if .Desc}} {{if eq .Type "Gist"}} - - {{.Desc}}
+ {{range .MainRepos}} {{ if .ForkOf }}
+ {{.Desc}}
- {{end}} {{else}} {{end}} -- {{if .Stars}}⭐ {{.Stars}}{{else}}{{end}} {{if .Forks}} 🍴 {{.Forks}} - {{else}}{{end}} {{if .Lang}} 🗒️ {{.Lang}} {{else}}{{end}} -
- - {{ end }} + + {{end}} {{if .ForkOf}} + + {{else}} +{{.Name}} ({{.Type}})
+ {{end}} {{if .ForkOf}} +Forked from: {{.ForkOf}}
+ {{else}} {{end}} {{if .Desc}} {{if eq .Type "Gist"}} + + {{.Desc}}
+ {{else}}
+ {{.Desc}}
+ {{end}} {{else}} {{end}} ++ {{if .Stars}}⭐ {{.Stars}}{{else}}{{end}} {{if .Forks}} 🍴 {{.Forks}} + {{else}}{{end}} {{if .Lang}} 🗒️ {{.Lang}} {{else}}{{end}} +
+ {{ if .ForkOf }} {{else}} + + {{end}} {{ if .ForkOf }} +