Add initial commit.

This commit is contained in:
2026-04-18 23:06:19 +01:00
parent cd6d872b78
commit 11ef2a5c94
3 changed files with 783 additions and 0 deletions

89
git-portfolio Executable file
View File

@@ -0,0 +1,89 @@
#!/usr/bin/bash
GIT_URL='https://git.seanhealy.ie'
GIT_USER=sean
TOKEN="$(pass gitea-api-token)"
EXCLUDE_LANGUAGES=(Makefile TeX)
cat <<EOF
<div id="git-portfolio">
<style>
#git-portfolio {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#git-portfolio section {
background: wheat;
padding: 15px;
max-width: 400px;
border: 2px black solid;
margin: 10px;
border-radius: 20px;
}
li.language {
display: inline-block;
background: lightgray;
padding: 5px 10px;
border-radius: 20px;
margin: 5px;
}
</style>
<h1>Projects</h1>
EOF
curl "$GIT_URL/api/v1/users/$GIT_USER/repos" \
-H 'Accept: application/json' \
-H "Authorization: $TOKEN" | jq -c '
sort_by(.updated_at) | reverse | .[] | select(.private == false) | select(.empty == false) | [
.name,
.description,
.languages_url,
.html_url,
.clone_url,
.website,
.updated_at,
.avatar_url,
.licenses
]' |
while read project; do
i=0
name=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
description=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
languages_url=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
languages="$(curl -s "$languages_url" -H "Authorization: $TOKEN" |
jq -r 'to_entries[]|[.key,.value]|@tsv')"
total_bytes=$(echo "$languages" | awk '{sum += $2} END {print sum}')
languages_percentages=$(echo "$languages" |
awk -v total="$total_bytes" '{print $2, $1}' |
sort -n -r |
cut -d' ' -f2 | grep -v -F -w -f <(printf "%s\n" "${EXCLUDE_LANGUAGES[@]}")
)
html_url=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
clone_url=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
website=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
updated_at=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
updated_at=$(date -d "$updated_at" +"%B %d, %Y")
avatar_url=$(jq -r ".[$i]" <<< "$project"); i=$((i + 1))
licenses=$(jq -r '.['$i'] | join(", ")' <<< "$project"); i=$((i + 1))
cat <<EOF
<section>
<a href="$html_url">
<h2>$name</h2>
</a>
<a href="$html_url">
<img src="$avatar_url" alt="Avatar" width="100" height="100" alt="$name (logo)">
</a>
<p>$description</p>
<ul>
EOF
while read -r language; do
echo "<li class='language'>$language</li>"
done <<< "$languages_percentages"
cat <<EOF
</ul>
<pre>git clone $clone_url</pre>
<p>Last Updated: $updated_at</p>
<p>Licenses: $licenses</p>
</section>
EOF
done
echo '</div>'