2minNoods/2minNoods.sh

65 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
mkdir -p siteroot
# html and css stolen from https://perfectmotherfuckingwebsite.com/
cat <<EOF > siteroot/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>2minNoods</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A saucy photoblog 😉">
<!-- <link rel="stylesheet" href="style.css">-->
<style>
body{
max-width:650px;
margin:40px auto;
padding:0 10px;
font:18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
color:#444
}
h1,h2,h3{
line-height:1.2
}
@media (prefers-color-scheme: dark){
body{
color:#c9d1d9;
background:#0d1117
}
a:link{
color:#58a6ff
}
a:visited{
color:#8e96f0
}
}
</style>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>😉</text></svg>">
</head>
<body>
<h1>2minNoods</h1>
<hr>
EOF
ls *.jpg | sort -r > photolist.txt
while read i; do
if [ -f "$i" ]; then
if [ ! -f "siteroot/$i" ]; then
echo "Resizing $i"
convert "$i" -quality 80 -strip -auto-orient -resize "2160^>" "siteroot/$i"
fi
echo '<h3>'"$(basename $i .jpg)"'</h3>' >> siteroot/index.html
echo '<a href="'"$i"'"><img src="'"$i"'" style="width:100%" loading="lazy"><hr></a>' >> siteroot/index.html
fi
done < photolist.txt
cat <<EOF >> siteroot/index.html
</body>
</html>
EOF
rm photolist.txt