mirror of
https://codeberg.org/gothub/gothub
synced 2024-12-06 19:16:24 +01:00
add asset list support
This commit is contained in:
+15
-5
@@ -25,10 +25,9 @@ type Release struct {
|
||||
Reactions []Reactions
|
||||
}
|
||||
type Assets struct {
|
||||
Name string
|
||||
Link string
|
||||
Size string
|
||||
ReleasedOn string
|
||||
Name string
|
||||
Link string
|
||||
Size string
|
||||
}
|
||||
type Reactions struct {
|
||||
Name string
|
||||
@@ -93,9 +92,20 @@ func ReleaseView(c *fiber.Ctx) error {
|
||||
Count: el.ChildText("span.js-discussion-reaction-group-count"),
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
sc.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/releases/" + c.Params("release"))
|
||||
// Scrape assets from the fragment page
|
||||
sc2 := colly.NewCollector(colly.AllowedDomains("github.com"), colly.UserAgent(UserAgent))
|
||||
sc2.OnHTML("ul", func(e *colly.HTMLElement) {
|
||||
e.ForEach("li", func(i int, el *colly.HTMLElement) {
|
||||
Scrape.Assets = append(Scrape.Assets, Assets{
|
||||
Name: el.ChildText("div.col-lg-9 a span"),
|
||||
Link: el.ChildAttr("div.col-lg-9 a", "href"),
|
||||
Size: el.ChildText("div.pl-1 span.text-sm-left"),
|
||||
})
|
||||
})
|
||||
})
|
||||
sc2.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/releases/expanded_assets/" + c.Params("release"))
|
||||
// Add scrape-based info to releaseArray
|
||||
releaseArray = append(releaseArray, Scrape)
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ func Serve(port string) {
|
||||
app.Get("/:user/:repo/tree/:branch/+", pages.DirView)
|
||||
app.Get("/:user/:repo/releases/:release", pages.ReleaseView)
|
||||
app.Get("/:user/:repo/releases/tag/:release", pages.ReleaseView)
|
||||
app.Get("/:user/:repo/releases/download/:release/:item", func(c *fiber.Ctx) error {
|
||||
utils.ProxyRequest(c, "https://github.com/"+c.Params("user")+"/"+c.Params("repo")+"/releases/download"+c.Params("release")/c.Params("item"))
|
||||
return nil
|
||||
})
|
||||
app.Get("/:user/:repo/tree/:branch", pages.HandleRepo)
|
||||
app.Get("/download/:user/:repo/:branch", func(c *fiber.Ctx) error {
|
||||
utils.ProxyRequest(c, "https://github.com/"+c.Params("user")+"/"+c.Params("repo")+"/archive/"+c.Params("branch")+".zip")
|
||||
|
||||
Reference in New Issue
Block a user