Skip to content

Commit 5d9c740

Browse files
committed
feat(sorting): add codeberg api
1 parent 94dd318 commit 5d9c740

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

scripts/sort_themes.nu

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ export def gitlab [
5050
}
5151
}
5252

53+
# Codeberg API.
54+
export def codeberg [
55+
token?: string # API Token.
56+
]: record<owner: string, name: string> -> record<pushed_at: string, stargazers_count: int, avatar: string> {
57+
let repo = $in
58+
59+
let headers = if ($token | is-empty) {
60+
[]
61+
} else {
62+
{
63+
Authorization: $"token ($token)"
64+
}
65+
}
66+
67+
let item = http get $"https://codeberg.org/api/v1/repos/($repo.owner)/($repo.name)" --headers $headers
68+
69+
{
70+
pushed_at: $item.updated_at
71+
stargazers_count: ($item.stars_count | into int)
72+
avatar: $item.owner.avatar_url
73+
}
74+
}
75+
5376
# In case of not having API, clone and get information yourself.
5477
export def clone [
5578
--temp: string = '/tmp/firefoxcss-store/' # Temporary folder to save themes.
@@ -130,6 +153,9 @@ export def main [
130153
} else if ($item.link | str contains 'gitlab') {
131154
sleep $delay
132155
$item.link | parse_link | gitlab $token
156+
} else if ($item.link | str contains 'codeberg') {
157+
sleep $delay
158+
$item.link | parse_link | codeberg $token
133159
} else {
134160
$item.link | parse_link | clone
135161
}

0 commit comments

Comments
 (0)