#!/bin/bash

URI=https://aninix.net/assets/css/theme-arc-green.css

# Gitea arc-green palette
BOLDTEXT='#87ab63'
TEXT='#9e9e9e'
BGCOLOR='#383c4a'
ACCENTBG='#353945'
HEADERBG='#404552'
ROW='#2a2e3a'
HOVER='#a0cc75'
NAV='#2e323e'

# AniNIX palette
ANINIXBOLD='#df0000'
ANINIXTEXT='#ffffff'
ANINIXBG='#000000'
ANINIXACCENTBG='#303030'
ANINIXHEADERBG='#151515'
ANINIXROW='#2a2a2a'
ANINIXHOVER='#af0000'
ANINIXNAV='#000000'

(curl -ks "$URI"; echo; echo ".home a {
    color: $ANINIXBOLD;
}
.bounding {
	border: 1px solid #FFF;
	border-radius: 15px;
	margin: 0;
	margin-top: 20px;
	padding: 10px;
	background-color: #000;
	margin-bottom: 30px;
    display: block;
}

body {
    background-color: $ANINIXBG;
    color: $ANINIXTEXT;
}

a {
   color: $ANINIXBOLD;
}
") \
    | sed "s/$BOLDTEXT/$ANINIXBOLD/gI" \
    | sed "s/$TEXT/$ANINIXTEXT/gI" \
    | sed "s/$ACCENTBG/$ANINIXACCENTBG/gI" \
    | sed "s/$HEADERBG/$ANINIXHEADERBG/gI" \
    | sed "s/$ROW/$ANINIXROW/gI" \
    | sed "s/$NAV/$ANINIXNAV/gI" \
    | sed "s/$HOVER/$ANINIXHOVER/gI" \
    | sed "s/$BGCOLOR/$ANINIXBG/gI" > /var/lib/gitea/custom/public/css/theme-aninix.css

cd /var/lib/gitea/web-snippets
head="$(curl -ks https://aninix.net/ | egrep -B 99999 '^<div class="home"')"
foot="$(curl -ks https://aninix.net/ | egrep -A 99999 '<footer>')"
for i in `find . -type f`; do
    (echo "$head"
    cat "$i"
    echo "$foot") > /var/lib/gitea/custom/public/"$i".html
done
