ユーザーページにアクセスしやすくに

このコミットが含まれているのは:
守矢諏訪子 2023-06-06 20:32:41 +09:00
コミット 24f23d1731
2個のファイルの変更13行の追加9行の削除

ファイルの表示

@ -18,7 +18,8 @@ type Languages struct {
}
type Repo struct {
Fullname string
Username string
Reponame string
Description string
Parent string
Stars string
@ -38,7 +39,8 @@ type RepoFiles struct {
Name string
Path string
Type string
Fullname string
Username string
Reponame string
DefaultBranch string
}
@ -73,7 +75,8 @@ func HandleRepo(c *fiber.Ctx) error {
sc := colly.NewCollector(colly.AllowedDomains("github.com"), colly.UserAgent(UserAgent))
sc.OnHTML("div.Layout-sidebar", func(e *colly.HTMLElement) {
Scrape.Fullname = c.Params("user") + "/" + repoUrl
Scrape.Username = c.Params("user")
Scrape.Reponame = repoUrl
Scrape.Description = e.ChildText("p.f4")
Scrape.Stars = e.ChildText("a[href*='/" + c.Params("user") + "/" + repoUrl + "/stargazers' i] strong")
Scrape.Watchers = e.ChildText("a[href*='/" + c.Params("user") + "/" + repoUrl + "/watchers' i] strong")
@ -121,7 +124,8 @@ func HandleRepo(c *fiber.Ctx) error {
Name: el.ChildText("div.flex-auto span.d-block a.js-navigation-open"),
Path: el.ChildText("div.flex-auto span.d-block a.js-navigation-open"),
Type: FileType,
Fullname: Scrape.Fullname,
Username: Scrape.Username,
Reponame: Scrape.Reponame,
DefaultBranch: Scrape.DefaultBranch,
})
})

ファイルの表示

@ -3,12 +3,12 @@
<main>
{{ if .repo }} {{ range $key, $value := .repo}}
<div class="button-parent">
<a href="/{{.Fullname}}/archive/{{.DefaultBranch}}.zip" class="button">Download (zip)</a>
<a rel="noreferrer" href="https://github.com/{{.Fullname}}" class="button">View on GitHub</a>
<a href="/{{.Username}}/{{.Reponame}}/archive/{{.DefaultBranch}}.zip" class="button">Download (zip)</a>
<a rel="noreferrer" href="https://github.com/{{.Username}}/{{.Reponame}}" class="button">View on GitHub</a>
</div>
<div class="user-profile">
<h1>{{.Fullname}}</h1>
<h1><a href="/{{.Username}}">{{.Username}}</a>/<a href="/{{.Username}}/{{.Reponame}}">{{.Reponame}}</a></h1>
{{ if .Parent }}
<p>This repository is a fork of <a href="/{{.Parent}}">{{.Parent}}</a>.</p>
{{ end }} {{ if .Description }}
@ -47,12 +47,12 @@
{{ range $key, $value := .files}} {{ if eq .Type "dir" }}
<li class="file-list">
📁
<a href="/{{.Fullname}}/tree/{{.DefaultBranch}}/{{.Path}}" class="filesA">{{.Path}}</a>
<a href="/{{.Username}}/{{.Reponame}}/tree/{{.DefaultBranch}}/{{.Path}}" class="filesA">{{.Path}}</a>
</li>
{{ else }}
<li class="file-list">
🗒️
<a href="/{{.Fullname}}/blob/{{.DefaultBranch}}/{{.Path}}">{{.Path}}</a>
<a href="/{{.Username}}/{{.Reponame}}/blob/{{.DefaultBranch}}/{{.Path}}">{{.Path}}</a>
</li>
{{ end }} {{ end }}
</ul>