Skip to content

Instantly share code, notes, and snippets.

@motiejus
Last active January 5, 2017 07:32
Show Gist options
  • Save motiejus/dac1f357894bb7536610cc2aceca5d33 to your computer and use it in GitHub Desktop.
Save motiejus/dac1f357894bb7536610cc2aceca5d33 to your computer and use it in GitHub Desktop.
gifs from dans.im
#!/bin/bash
if [[ -n "$1" ]]; then
URL=$1
else
URL=https://dans.im/gifs/
fi
set -euo pipefail
cat <<EOF
<html>
<head>
<title>gifs from dans.im</title>
<style>
.container { width: 80%; margin: 30px auto; overflow: hidden; }
.galleryItem { margin: 10px; float: left; border: 1px red solid; padding: 10px; border-radius: 5px; }
.galleryItem img { max-width: 100%; border-radius: 5px; }
</style>
</head>
<!-- generated by https://gist.github.com/Motiejus/dac1f357894bb7536610cc2aceca5d33 -->
<body>
EOF
curl -s $URL | \
awk -F'"' '/^<a href="/ { print $2}' | while read gif; do
echo " <div class=\"galleryItem\">"
echo " <img src=\"${URL}${gif}\" alt=\"\" /></a>"
echo " <p>https://dans.im/gifs/${gif}</p>"
echo " </div>"
echo
done
cat <<EOF
</body>
</html>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment