simplify social code

このコミットが含まれているのは:
Arya Kiran 2023-02-09 22:11:53 +05:30
コミット ba642bf695
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 842D12BDA50DF120
2個のファイルの変更7行の追加27行の削除

ファイルの表示

@ -25,10 +25,7 @@ type User struct {
Following int64
Followers int64
Link string
Link1 string
Link2 string
Link3 string
Link4 string
Social []string
Company string
Type string
Contributions string
@ -144,18 +141,8 @@ func HandleUser(c *fiber.Ctx) error {
Scrape.Location = e.ChildText("li[itemprop*='homeLocation'] span")
Scrape.Timezone = e.ChildText("li[itemprop*='localTime'] span")
Scrape.Company = e.ChildText("li[itemprop*='worksFor'] span")
// I know this is hacky, I'll get around to fixing it later -arya
e.ForEach("li[itemprop*='social']", func(i int, el *colly.HTMLElement) {
switch i {
case 0:
Scrape.Link1 = el.ChildText("a.Link--primary")
case 1:
Scrape.Link2 = el.ChildText("a.Link--primary")
case 2:
Scrape.Link3 = el.ChildText("a.Link--primary")
case 3:
Scrape.Link4 = el.ChildText("a.Link--primary")
}
Scrape.Social = append(Scrape.Social, el.ChildText("a.Link--primary"))
})
})

ファイルの表示

@ -26,18 +26,11 @@
{{ if .Link }}
<p>🌐 <a href="https://{{.Link}}" target="_blank">{{.Link}}</a></p>
{{ end }}
{{ if .Link1 }}
<p>🔗 <a href="https://{{.Link1}}" target="_blank">{{.Link1}}</a></p>
{{ end }}
{{ if .Link2 }}
<p>🔗 <a href="https://{{.Link2}}" target="_blank">{{.Link2}}</a></p>
{{ end }}
{{ if .Link3 }}
<p>🔗 <a href="https://{{.Link3}}" target="_blank">{{.Link3}}</a></p>
{{ end }}
{{ if .Link4 }}
<p>🔗 <a href="https://{{.Link4}}" target="_blank">{{.Link4}}</a></p>
{{ end }}
{{ if .Social }}
{{range .Social}}
<p>🔗 <a href="{{.}}" target="_blank">{{.}}</a></p>
{{ end }}
{{ end }}
{{ if .Company }}
<p>🏢 {{.Company}}</p>
{{ end }}