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}}
- Download (zip) - View on GitHub + Download (zip) + View on GitHub
-

{{.Fullname}}

+

{{.Username}}/{{.Reponame}}

{{ if .Parent }}

This repository is a fork of {{.Parent}}.

{{ end }} {{ if .Description }} @@ -47,12 +47,12 @@ {{ range $key, $value := .files}} {{ if eq .Type "dir" }}
  • 📁 - {{.Path}} + {{.Path}}
  • {{ else }}
  • 🗒️ - {{.Path}} + {{.Path}}
  • {{ end }} {{ end }}