add support for repo tags and links
このコミットが含まれているのは:
コミット
3e6d0bec06
|
@ -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">
|
||||||
|
|
読み込み中…
新しいイシューから参照