From 3e6d0bec063c14f075a4e28b2a0f5e631861bb4d Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Thu, 16 Mar 2023 15:25:17 +0530
Subject: [PATCH] add support for repo tags and links
---
pages/repo.go | 9 ++++++++-
views/about.html | 4 +++-
views/dir.html | 16 +++++++++++-----
views/repo.html | 11 +++++++++--
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/pages/repo.go b/pages/repo.go
index 84705ed..e59f5f5 100644
--- a/pages/repo.go
+++ b/pages/repo.go
@@ -10,6 +10,7 @@ import (
"log"
"net/http"
"os"
+ "strings"
)
type Repo struct {
@@ -23,6 +24,8 @@ type Repo struct {
License string
DefaultBranch string
Readme string
+ Link string
+ Tags []string
}
type RepoFiles struct {
@@ -63,8 +66,12 @@ func HandleRepo(c *fiber.Ctx) error {
Scrape.Description = e.ChildText("p.f4")
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.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\"}']")
+ 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) {
Scrape.Readme = e.ChildText("a[href*='#readme']")
diff --git a/views/about.html b/views/about.html
index cbe7a9a..abf80a0 100644
--- a/views/about.html
+++ b/views/about.html
@@ -29,7 +29,9 @@
>