Created
May 10, 2021 18:51
-
-
Save Wevah/8c4315833cd0aa66c6a8921c0d1912d1 to your computer and use it in GitHub Desktop.
Paparazzi! download block generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z "$1" ]; then | |
echo "I need a file!" | |
exit 1 | |
fi | |
baseName=$(basename "$1") | |
downloadName="${baseName%.*}" | |
hash=$(shasum -a 256 "$baseName" | cut -d' ' -f1) | |
fileSize=$(stat -f%z "$1") | |
fileSize=$(printf "%'u" "$fileSize") | |
modDate=$(stat -f%Sm -t"%B %e, %Y" "$1") | |
datetime=$(stat -f%Sm -t"%Y-%m-%d" "$1") | |
# echo $fileSize | |
cat <<EOF | |
<p class="download"> | |
<a href="downloads/${baseName}">${downloadName}</a> (10.9+; Compressed .dmg) <span class="info">[${fileSize} bytes]<span> <time datetime="${datetime}">${modDate}</time> | |
<span class="hash">SHA-256: ${hash}</span> | |
</p> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm superseding this with a Swift version that will be put in a proper repo!