add support for repo tags and links

このコミットが含まれているのは:
Arya Kiran 2023-03-16 15:25:17 +05:30
コミット 3e6d0bec06
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 842D12BDA50DF120
4個のファイルの変更31行の追加9行の削除

ファイルの表示

@ -10,6 +10,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"strings"
) )
type Repo struct { type Repo struct {
@ -23,6 +24,8 @@ type Repo struct {
License string License string
DefaultBranch string DefaultBranch string
Readme string Readme string
Link string
Tags []string
} }
type RepoFiles struct { type RepoFiles struct {
@ -63,8 +66,12 @@ func HandleRepo(c *fiber.Ctx) error {
Scrape.Description = e.ChildText("p.f4") Scrape.Description = e.ChildText("p.f4")
Scrape.Stars = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/stargazers' i] strong") Scrape.Stars = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/stargazers' i] strong")
Scrape.Watchers = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/watchers' i] strong") Scrape.Watchers = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/watchers' i] strong")
Scrape.Forks = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/network/members' i] strong") Scrape.Forks = e.ChildText("a[href*='/" + c.Params("user") + "/" + c.Params("repo") + "/forks' i] strong")
Scrape.Link = e.ChildAttr("span.css-truncate a.text-bold", "href")
Scrape.License = e.ChildText("a[data-analytics-event*='{\"category\":\"Repository Overview\",\"action\":\"click\",\"label\":\"location:sidebar;file:license\"}']") Scrape.License = e.ChildText("a[data-analytics-event*='{\"category\":\"Repository Overview\",\"action\":\"click\",\"label\":\"location:sidebar;file:license\"}']")
e.ForEach("a.topic-tag", func(i int, el *colly.HTMLElement) {
Scrape.Tags = append(Scrape.Tags, strings.TrimPrefix(el.Attr("data-octo-dimensions"), "topic:"))
})
}) })
sc.OnHTML("div#readme", func(e *colly.HTMLElement) { sc.OnHTML("div#readme", func(e *colly.HTMLElement) {
Scrape.Readme = e.ChildText("a[href*='#readme']") Scrape.Readme = e.ChildText("a[href*='#readme']")

ファイルの表示

@ -29,7 +29,9 @@
> >
</p> </p>
<ul> <ul>
<li><b>Go Version</b>: Fiber {{ .FiberVersion}} running on {{ .GoVersion}}</li> <li>
<b>Go Version</b>: Fiber {{ .FiberVersion}} running on {{ .GoVersion}}
</li>
<li><b>Country:</b> {{.Country}}</li> <li><b>Country:</b> {{.Country}}</li>
<li><b>Cloudflare:</b> {{.Cloudflare}}</li> <li><b>Cloudflare:</b> {{.Cloudflare}}</li>
<li><b>ISP:</b> {{.Provider}}</li> <li><b>ISP:</b> {{.Provider}}</li>

ファイルの表示

@ -3,12 +3,14 @@
<main> <main>
{{ if .dir }} {{ range $key, $value := .dir}} {{ if .dir }} {{ range $key, $value := .dir}}
<div class="buttonParent"> <div class="buttonParent">
<a href="https://github.com/{{.Fullname}}/tree/{{.DirName}}" class="button">View on GitHub</a> <a href="https://github.com/{{.Fullname}}/tree/{{.DirName}}" class="button"
<a href="/{{.Fullname}}" class="button">Back to {{.Fullname}}</a> >View on GitHub</a
>
<a href="/{{.Fullname}}" class="button">Back to {{.Fullname}}</a>
</div> </div>
<div class="userProfile"> <div class="userProfile">
<h1>{{.Fullname}} | {{.DirName}}</h1> <h1>{{.Fullname}} | {{.DirName}}</h1>
</div> </div>
{{end}} {{ if .files}} {{end}} {{ if .files}}
<div class="userReadme"> <div class="userReadme">
@ -17,11 +19,15 @@
<ul class="filesUList"> <ul class="filesUList">
{{ range $key, $value := .files}} {{ if eq .Type "dir" }} {{ range $key, $value := .files}} {{ if eq .Type "dir" }}
<li class="filesList"> <li class="filesList">
<a href="/{{.Fullname}}/tree/{{.Branch}}/{{.DirName}}/{{.Path}}" class="filesA">{{.Path}} (directory)</a> <a
href="/{{.Fullname}}/tree/{{.Branch}}/{{.DirName}}/{{.Path}}"
class="filesA"
>{{.Path}} (directory)</a
>
</li> </li>
{{ else }} {{ else }}
<li class="filesList"> <li class="filesList">
<a href="/{{.Fullname}}/blob/{{.Branch}}/{{.DirName}}/{{.Path}}" <a href="/{{.Fullname}}/blob/{{.Branch}}/{{.DirName}}/{{.Path}}"
>{{.Path}}</a >{{.Path}}</a
> >
</li> </li>

ファイルの表示

@ -15,7 +15,10 @@
<p>This repository is a fork of <a href="/{{.Parent}}">{{.Parent}}</a>.</p> <p>This repository is a fork of <a href="/{{.Parent}}">{{.Parent}}</a>.</p>
{{ end }} {{ if .Description }} {{ end }} {{ if .Description }}
<p>{{.Description}}</p> <p>{{.Description}}</p>
{{ end }} {{ if .License }} {{ end }} {{ if .Link }} <a href="{{.Link}}">{{.Link}}</a> {{end}} {{ if
.Tags }}
<p>Tags: {{range .Tags}} {{.}} {{end}}</p>
{{end}} {{ if .License }}
<p> <p>
⭐ {{.Stars}} 🍴 {{.Forks}} 👀 {{.Watchers}} ⚖️ {{.License}} 🌿 ⭐ {{.Stars}} 🍴 {{.Forks}} 👀 {{.Watchers}} ⚖️ {{.License}} 🌿
{{.DefaultBranch}} {{.DefaultBranch}}
@ -36,7 +39,11 @@
<ul class="filesUList"> <ul class="filesUList">
{{ range $key, $value := .files}} {{ if eq .Type "dir" }} {{ range $key, $value := .files}} {{ if eq .Type "dir" }}
<li class="filesList"> <li class="filesList">
<a href="/{{.Fullname}}/tree/{{.DefaultBranch}}/{{.Path}}" class="filesA">{{.Path}} (directory)</a> <a
href="/{{.Fullname}}/tree/{{.DefaultBranch}}/{{.Path}}"
class="filesA"
>{{.Path}} (directory)</a
>
</li> </li>
{{ else }} {{ else }}
<li class="filesList"> <li class="filesList">