diff --git a/donate.sh b/donate.sh new file mode 100755 index 0000000..5ed3078 --- /dev/null +++ b/donate.sh @@ -0,0 +1,91 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' +cd "$(dirname "$0")" + +DONATE_JSON_URL="https://data.nhcarrigan.com/donate.json" +DONATE_JSON_FILE="donate.json" +DONATE_HTML_FILE="donate/index.html" + +# Templating +HTML_START=' + + + Donate + + + + + + + +
+

Donate

+

Support our work and help us make a difference!

+
+' +HTML_END='
+
+ + +' + +# Fetch the latest donate.json +curl -sSL "$DONATE_JSON_URL" -o "$DONATE_JSON_FILE" + +# Convert JSON to HTML, sorted by date descending (newest first) +DONATE_HTML=$(jq -r '.[] | +"
+ + +
+

" + .name + "

+

" + .description + "

+
+
+
" +' "$DONATE_JSON_FILE") + +# Create temporary file with the HTML content +echo "$HTML_START" > "$DONATE_HTML_FILE" +echo "$DONATE_HTML" >> "$DONATE_HTML_FILE" +echo "$HTML_END" >> "$DONATE_HTML_FILE" + +echo "Donate updated in $DONATE_HTML_FILE" + +# Clean up +rm "$DONATE_JSON_FILE" \ No newline at end of file diff --git a/donate/index.html b/donate/index.html new file mode 100644 index 0000000..c5e86d8 --- /dev/null +++ b/donate/index.html @@ -0,0 +1,145 @@ + + + + Donate + + + + + + + +
+

Donate

+

Support our work and help us make a difference!

+
+ + + + + + + + + + + +
+
+ + +