Merge branch 'dev' of codeberg.org:gothub/gothub into dev

This commit is contained in:
Midou
2023-06-18 10:58:44 +01:00
5 changed files with 78 additions and 29 deletions
+2 -2
View File
@@ -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 |
+15 -3
View File
@@ -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) {
+14
View File
@@ -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);
+16 -4
View File
@@ -30,10 +30,22 @@
⭐ {{.Stars}} 🍴 {{.Forks}} 👀 {{.Watchers}} ⚖️ No license 🌿
{{.DefaultBranch}}
</p>
{{ end }} {{ if .Language }}
<p>🗒️ {{range .Language}} {{.}} {{end}}</p>
{{end}} {{ if .CommitsBehind }} This repository is {{.CommitsBehind}}
commits behind its parent. {{end}}
{{ end }} {{ if .Language }} {{range $o := .Language}}{{$o.Name}}
{{$o.Percent}}, {{end}}
<div class="lang-bar">
{{range $i, $o := .Language}}
<span style="width: {{$o.Percent}}; background-color: {{$o.Color}}">
&nbsp;
</span>
{{end}}
</div>
{{end}} {{ if or .CommitsAhead .CommitsBehind }}
<p>
This repository is {{if .CommitsBehind}} {{.CommitsBehind}} commits behind {{end}} {{if and .CommitsBehind .CommitsAhead}} and {{end}}
{{if .CommitsAhead}} {{ .CommitsAhead }} commits ahead of {{end}} its
parent.
</p>
{{end}}
</div>
{{end}} {{ if .files}}
<div class="user-readme">
+31 -20
View File
@@ -74,27 +74,38 @@
{{ end }} {{ if .MainRepos }}
<div class="user-readme">
<h3>{{.PinOrPopular}} repositories</h3>
{{range .MainRepos}}
<a class="user-repo-card" href="{{.Link}}">
<p class="user-repo-header">{{.Name}} ({{.Type}})</p>
{{if .ForkOf}} Forked from: <a href="/{{.ForkOf}}">{{.ForkOf}}</a>
{{else}} {{end}} {{if .Desc}} {{if eq .Type "Gist"}}
<style>
pre {
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
<pre> {{.Desc}} </pre>
{{range .MainRepos}} {{ if .ForkOf }}
<div class="user-repo-card">
{{else}}
<p class="">{{.Desc}}</p>
{{end}} {{else}} {{end}}
<p class="">
{{if .Stars}}⭐ {{.Stars}}{{else}}{{end}} {{if .Forks}} 🍴 {{.Forks}}
{{else}}{{end}} {{if .Lang}} 🗒️ {{.Lang}} {{else}}{{end}}
</p>
</a>
{{ end }}
<a class="user-repo-card" href="{{.Link}}">
{{end}} {{if .ForkOf}}
<p class="user-repo-header">
<a href="{{.Link}}">{{.Name}} ({{.Type}})</a>
</p>
{{else}}
<p class="user-repo-header">{{.Name}} ({{.Type}})</p>
{{end}} {{if .ForkOf}}
<p class="">Forked from: <a href="/{{.ForkOf}}">{{.ForkOf}}</a></p>
{{else}} {{end}} {{if .Desc}} {{if eq .Type "Gist"}}
<style>
pre {
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
<pre> {{.Desc}} </pre>
{{else}}
<p class="">{{.Desc}}</p>
{{end}} {{else}} {{end}}
<p class="">
{{if .Stars}}⭐ {{.Stars}}{{else}}{{end}} {{if .Forks}} 🍴 {{.Forks}}
{{else}}{{end}} {{if .Lang}} 🗒️ {{.Lang}} {{else}}{{end}}
</p>
{{ if .ForkOf }} {{else}}
</a>
{{end}} {{ if .ForkOf }}
</div>
{{end}} {{ end }}
</div>
{{ end }} {{ end }} {{ else }}
<h2>User not found</h2>