From 24f23d1731f5a41db2698cb8301d5910a68c7917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Tue, 6 Jun 2023 20:32:41 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AB=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9?= =?UTF-8?q?=E3=81=97=E3=82=84=E3=81=99=E3=81=8F=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/repo.go | 12 ++++++++---- views/repo.html | 10 +++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pages/repo.go b/pages/repo.go index bf53a71..205aaec 100644 --- a/pages/repo.go +++ b/pages/repo.go @@ -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, }) }) diff --git a/views/repo.html b/views/repo.html index a3c3d39..ad4b416 100644 --- a/views/repo.html +++ b/views/repo.html @@ -3,12 +3,12 @@
{{ if .repo }} {{ range $key, $value := .repo}}