Added: configureable site root, thumbnails, pages, (slightly) better CSS
This commit is contained in:
parent
f18617c30c
commit
e4dc7060ac
69
2minNoods.sh
69
2minNoods.sh
|
@ -1,10 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p siteroot
|
||||
siteroot="../2minNoods_siteroot"
|
||||
noodspp=40
|
||||
|
||||
|
||||
mkdir -p "$siteroot/img/thumbs"
|
||||
pageno=1
|
||||
noodcount=1
|
||||
|
||||
|
||||
# html and css stolen from https://perfectmotherfuckingwebsite.com/
|
||||
cat <<EOF > siteroot/index.html
|
||||
<!DOCTYPE html>
|
||||
pageheader='''<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -21,7 +27,18 @@ body{
|
|||
color:#444
|
||||
}
|
||||
h1,h2,h3{
|
||||
line-height:1.2
|
||||
line-height:1
|
||||
}
|
||||
.page-links{
|
||||
font-size: 2em;
|
||||
}
|
||||
a.button{
|
||||
padding: 1px 6px;
|
||||
border: 1px outset buttonborder;
|
||||
border-radius: 3px;
|
||||
color: buttontext;
|
||||
background-color: buttonface;
|
||||
text-decoration: none;
|
||||
}
|
||||
@media (prefers-color-scheme: dark){
|
||||
body{
|
||||
|
@ -40,25 +57,43 @@ h1,h2,h3{
|
|||
</head>
|
||||
<body>
|
||||
<h1>2minNoods</h1>
|
||||
<hr>
|
||||
EOF
|
||||
<hr>'''
|
||||
|
||||
ls *.jpg | sort -r > photolist.txt
|
||||
rm -v "$siteroot"/index.*.html
|
||||
|
||||
echo '<meta http-equiv="refresh" content="0; url=index.1.html" />' > "$siteroot/index.html"
|
||||
|
||||
ls *.jpg | sort -k2 -t'_' -r > "$siteroot/photolist.txt"
|
||||
|
||||
while read i; do
|
||||
if [ -f "$i" ]; then
|
||||
if [ ! -f "siteroot/$i" ]; then
|
||||
if [ ! -f "$siteroot/img/$i" ]; then
|
||||
echo "Resizing $i"
|
||||
convert "$i" -quality 80 -strip -auto-orient -resize "2160^>" "siteroot/$i"
|
||||
convert "$i" -quality 70 -strip -auto-orient -resize "960^>" "$siteroot/img/thumbs/$i"
|
||||
convert "$i" -quality 90 -strip -auto-orient -resize "2160^>" "$siteroot/img/$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
|
||||
if [[ $noodcount -eq 1 ]]; then
|
||||
echo "$pageheader" > "$siteroot/index.$pageno.html"
|
||||
fi
|
||||
done < photolist.txt
|
||||
echo '<h3>'"$(basename $i .jpg)"'</h3><a href="'"img/$i"'"><img src="'"img/thumbs/$i"'" style="width:100%" loading="lazy"></a><hr>' >> "$siteroot/index.$pageno.html"
|
||||
((noodcount++))
|
||||
if [[ $noodcount -gt $noodspp ]]; then
|
||||
((pageno++))
|
||||
noodcount=1
|
||||
fi
|
||||
fi
|
||||
done < "$siteroot/photolist.txt"
|
||||
|
||||
cat <<EOF >> siteroot/index.html
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
for ((page=1;page<=pageno;page++)); do
|
||||
echo -n '<div class="page-links">' >> "$siteroot/index.$page.html"
|
||||
for ((link=1;link<=pageno;link++)); do
|
||||
if [ $link -eq $page ]; then
|
||||
echo -n "$link "
|
||||
else
|
||||
echo -n "<a class=\"button\" href=\"index.$link.html\">$link</a> "
|
||||
fi
|
||||
done >> "$siteroot/index.$page.html"
|
||||
echo '</div></body></html>' >> "$siteroot/index.$page.html"
|
||||
done
|
||||
|
||||
rm photolist.txt
|
||||
rm -v "$siteroot/photolist.txt"
|
||||
|
|
Loading…
Reference in New Issue