diff --git a/pages/wiki.go b/pages/wiki.go index 623794f..3fa4208 100644 --- a/pages/wiki.go +++ b/pages/wiki.go @@ -1,6 +1,7 @@ package pages import ( + "codeberg.org/gothub/gothub/utils" "github.com/gocolly/colly" "github.com/gofiber/fiber/v2" "log" @@ -61,7 +62,7 @@ func WikiView(c *fiber.Ctx) error { Scrape.LastEditor = re.ReplaceAllString(strings.Replace(e.ChildText("div.gh-header-meta"), "\n", "", -1), "${1}") Scrape.RevisionNum = strings.TrimSuffix(e.ChildText("a.Link--muted"), " revisions") }) - sc.OnHTML("div.Box--condensed", func(e *colly.HTMLElement) { + sc.OnHTML("div.wiki-pages-box div.Box--condensed", func(e *colly.HTMLElement) { Scrape.PageNum = e.ChildText("span.Counter--primary") e.ForEach("ul.list-style-none li.Box-row", func(i int, el *colly.HTMLElement) { Scrape.Sidebar = append(Scrape.Sidebar, Sidebar{ @@ -70,6 +71,10 @@ func WikiView(c *fiber.Ctx) error { }) }) }) + sc.OnHTML("div#wiki-body > div.markdown-body", func(e *colly.HTMLElement) { + Content, _ := e.DOM.Html() + Scrape.PageContent = string(utils.UGCPolicy().SanitizeBytes([]byte(Content))) + }) sc.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/wiki/" + c.Params("page")) // Add scrape-based info to wikiArray wikiArray = append(wikiArray, Scrape) diff --git a/views/wiki.html b/views/wiki.html index 4a6a8a8..9485def 100644 --- a/views/wiki.html +++ b/views/wiki.html @@ -8,7 +8,10 @@

LastEdit: {{.LastEdit}}

LastEditor: {{.LastEditor}}

RevisionNum: {{.RevisionNum}}

+

PageNum: {{.PageNum}}

Sidebar: {{.Sidebar}}

+

Content:

+ {{ unescape .PageContent }} {{ end }} {{ else }}

Wiki not found

That wiki doesn't exist.