User contributions

This commit is contained in:
Arya Kiran
2023-02-08 18:57:45 +05:30
parent fc19decc13
commit 24cefa1afa
2 changed files with 22 additions and 12 deletions
+17 -12
View File
@@ -16,18 +16,19 @@ import (
)
type User struct {
Login string
Name string
Bio string
AvatarUrl string
Location string
Following int64
Followers int64
Link string
Company string
Type string
EwTwitter string
Readme string
Login string
Name string
Bio string
AvatarUrl string
Location string
Following int64
Followers int64
Link string
Company string
Type string
EwTwitter string
Contributions string
Readme string
}
type Ratelimit struct {
@@ -152,6 +153,10 @@ func HandleUser(c *fiber.Ctx) error {
Scrape.Login = e.ChildText("span[itemprop*='additionalName']")
Scrape.Name = e.ChildText("span[itemprop*='name']")
})
// Contributions
sc.OnHTML("div.js-yearly-contributions", func(e *colly.HTMLElement) {
Scrape.Contributions = e.ChildText("h2")
})
} else {
sc.OnHTML("img[alt*='@"+c.Params("user")+"' i]", func(e *colly.HTMLElement) {
Scrape.AvatarUrl = e.Attr("src")
+5
View File
@@ -20,6 +20,8 @@
{{ if .Location }}
<p>🌍 {{.Location}}</p>
{{ end }}
{{ if .Timezone }}
<p>🕑️ {{.Timezone}}</p>
{{ if .Link }}
<p>🔗 <a href="https://{{.Link}}" target="_blank">{{.Link}}</a></p>
{{ end }}
@@ -29,6 +31,9 @@
{{ if .EwTwitter }}
<p>🐦 <a href="https://twitter.com/{{.EwTwitter}}" target="_blank">{{.EwTwitter}}</a></p>
{{ end }}
{{ if eq .Type "http://schema.org/Person" }}
<p>✏️ {{ if .Name }} {{.Name}} {{ else }} {{.Login}} {{ end }} has made {{.Contributions}}</p>
{{ end }}
</div>
{{ if .Bio }}