レポジトリヘッダー
このコミットが含まれているのは:
コミット
ba97d8b78b
|
@ -13,38 +13,22 @@ import (
|
|||
)
|
||||
|
||||
type Languages struct {
|
||||
Name string
|
||||
Percent string
|
||||
Color string
|
||||
Name, Percent, Color string
|
||||
}
|
||||
|
||||
type LastCommit struct {
|
||||
Ava, User, Id, IdShort, Mess, MessIssue, Date string
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
Username string
|
||||
Reponame string
|
||||
Description string
|
||||
Parent string
|
||||
Stars string
|
||||
Forks string
|
||||
CommitsBehind string
|
||||
Watchers string
|
||||
Username, Reponame, CommitCount, Description, Parent, Stars, Forks, CommitsBehind, Watchers, License, DefaultBranch, Readme, Link, ComCount string
|
||||
Tags, Branch []string
|
||||
Language []Languages
|
||||
License string
|
||||
DefaultBranch string
|
||||
Readme string
|
||||
Link string
|
||||
Tags []string
|
||||
Branch []string
|
||||
LastCom LastCommit
|
||||
}
|
||||
|
||||
type RepoFiles struct {
|
||||
Name string
|
||||
Path string
|
||||
Commit string
|
||||
Date string
|
||||
Type string
|
||||
Username string
|
||||
Reponame string
|
||||
DefaultBranch string
|
||||
Name, Path, Commit, Date, Type, Username, Reponame, DefaultBranch string
|
||||
}
|
||||
|
||||
func HandleRepo(c *fiber.Ctx) error {
|
||||
|
@ -81,8 +65,8 @@ func HandleRepo(c *fiber.Ctx) error {
|
|||
sc := colly.NewCollector(colly.AllowedDomains("github.com"), colly.UserAgent(UserAgent))
|
||||
sc.Limit(&colly.LimitRule{
|
||||
DomainGlob: "github.githubassets.com/*",
|
||||
Delay: 15 * time.Second,
|
||||
RandomDelay: 15 * time.Second,
|
||||
Delay: 30 * time.Second,
|
||||
RandomDelay: 30 * time.Second,
|
||||
})
|
||||
sc.OnHTML("div.Layout-sidebar", func(e *colly.HTMLElement) {
|
||||
Scrape.Username = c.Params("user")
|
||||
|
@ -97,6 +81,24 @@ func HandleRepo(c *fiber.Ctx) error {
|
|||
Scrape.Tags = append(Scrape.Tags, strings.TrimPrefix(el.Attr("data-octo-dimensions"), "topic:"))
|
||||
})
|
||||
})
|
||||
sc.OnHTML("div.Box-header div.js-details-container", func(e *colly.HTMLElement) {
|
||||
var commit LastCommit
|
||||
commit.Ava = strings.ReplaceAll(e.ChildAttr("img", "src"), "https://avatars.githubusercontent.com/u", "/avatar")
|
||||
commit.User = e.ChildText("a.commit-author")
|
||||
commit.Id = strings.TrimPrefix(e.ChildAttr("a.Link--primary", "href"), "/" + c.Params("user") + "/" + repoUrl + "/commit/")
|
||||
commit.IdShort = e.ChildText("div.flex-items-baseline a.f6")
|
||||
commit.Mess = e.ChildText("span.d-none a.Link--primary")
|
||||
Scrape.ComCount = e.ChildText("li.ml-0 a.Link--primary span.d-none strong")
|
||||
commit.MessIssue = strings.ReplaceAll(e.ChildText("span.d-none a.issue-link"), "#", "")
|
||||
tstring := e.ChildAttr("relative-time", "datetime")
|
||||
if tstring != "" {
|
||||
tstring = strings.Split(tstring, "T")[0]
|
||||
tstrings := strings.Split(tstring, "-")
|
||||
tstring = tstrings[0] + "-" + tstrings[1] + "-" + tstrings[2]
|
||||
}
|
||||
commit.Date = tstring
|
||||
Scrape.LastCom = commit
|
||||
})
|
||||
sc.OnHTML("div.Box-body div.d-flex div span", func(e *colly.HTMLElement) {
|
||||
Scrape.CommitsBehind = strings.TrimSuffix(e.ChildText("a"), " commits behind")
|
||||
})
|
||||
|
@ -154,11 +156,14 @@ func HandleRepo(c *fiber.Ctx) error {
|
|||
// Add scrape-based info to repoArray
|
||||
repoArray = append(repoArray, Scrape)
|
||||
return c.Render("repo", fiber.Map{
|
||||
"title": c.Params("user") + "/" + repoUrl + branchExists,
|
||||
"ver": utils.Ver,
|
||||
"ves": utils.Ves,
|
||||
"repo": repoArray,
|
||||
"files": repoFilesArray,
|
||||
"readme": readmeOutput,
|
||||
"title": c.Params("user") + "/" + repoUrl + branchExists,
|
||||
"ver": utils.Ver,
|
||||
"ves": utils.Ves,
|
||||
"repo": repoArray,
|
||||
"usrep": c.Params("user") + "/" + repoUrl,
|
||||
"commits": Scrape.ComCount,
|
||||
"lastcom": Scrape.LastCom,
|
||||
"files": repoFilesArray,
|
||||
"readme": readmeOutput,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -42,6 +42,21 @@
|
|||
<div class="user-readme">
|
||||
<h3>ファイル</h3>
|
||||
<table class="user-readme-text file-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a href="/{{.lastcom.User}}"><img src="{{.lastcom.Ava}}" alt="{{.lastcom.User}}さんの画像" class="avatar" width="24" height="24" /></a>
|
||||
<a href="/{{.usrep}}/commits?author={{.lastcom.User}}">{{.lastcom.User}}</a>
|
||||
<a href="/{{.usrep}}/commit/{{.lastcom.Id}}">{{.lastcom.Mess}}</a>
|
||||
{{if .lastcom.MessIssue}}(<a href="/{{.usrep}}/pull/{{.lastcom.MessIssue}}">#{{.lastcom.MessIssue}}</a>){{end}}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<a href="/{{.usrep}}/commit/{{.lastcom.Id}}">{{.lastcom.IdShort}}</a>
|
||||
<a href="/{{.usrep}}/commit/{{.lastcom.Id}}">{{.lastcom.Date}}</a>
|
||||
<a href="/{{.usrep}}/commits/{{.DefaultBranch}}">{{.commits}}件コミット</a>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $key, $value := .files}}
|
||||
<tr class="file-u-list">
|
||||
|
|
読み込み中…
新しいイシューから参照