mirror of
https://codeberg.org/gothub/gothub
synced 2024-12-06 19:16:24 +01:00
Removed printlns and ran file through gofmt.
This commit is contained in:
+12
-15
@@ -1,12 +1,12 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tidwall/gjson"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"fmt"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
|
||||
"codeberg.org/gothub/gothub/utils"
|
||||
"github.com/gocolly/colly"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@@ -56,34 +56,31 @@ func DirView(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
sc := colly.NewCollector(colly.AllowedDomains("github.com"), colly.UserAgent(UserAgent))
|
||||
|
||||
|
||||
sc.OnResponse(func(r *colly.Response) {
|
||||
jsonMess := string(r.Body)
|
||||
dirList := gjson.Get(jsonMess, "payload.tree.items")
|
||||
|
||||
|
||||
dirList.ForEach(func(i, e gjson.Result) bool {
|
||||
var FileType string
|
||||
if(e.Get("contentType").Str == "directory"){
|
||||
if e.Get("contentType").Str == "directory" {
|
||||
FileType = "dir"
|
||||
} else {
|
||||
FileType = "file"
|
||||
}
|
||||
|
||||
|
||||
dirFilesArray = append(dirFilesArray, DirFiles{
|
||||
Name: e.Get("name").Str,
|
||||
// Path is the path to the file/folder from the repository root
|
||||
Path: e.Get("path").Str,
|
||||
Type: FileType,
|
||||
Branch: Scrape.Branch,
|
||||
Path: e.Get("path").Str,
|
||||
Type: FileType,
|
||||
Branch: Scrape.Branch,
|
||||
Fullname: Scrape.Fullname,
|
||||
})
|
||||
|
||||
fmt.Println(dirFilesArray)
|
||||
|
||||
|
||||
return true //keep iterating
|
||||
})
|
||||
fmt.Println(dirList)
|
||||
|
||||
|
||||
})
|
||||
|
||||
sc.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/tree/" + c.Params("branch") + "/" + c.Params("+"))
|
||||
|
||||
Reference in New Issue
Block a user