Added: configureable site root, thumbnails, pages, (slightly) better CSS

This commit is contained in:
tim 2024-07-29 16:08:07 +09:30
parent f18617c30c
commit e4dc7060ac
1 changed files with 52 additions and 17 deletions

View File

@ -1,10 +1,16 @@
#!/bin/bash #!/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/ # html and css stolen from https://perfectmotherfuckingwebsite.com/
cat <<EOF > siteroot/index.html pageheader='''<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -21,7 +27,18 @@ body{
color:#444 color:#444
} }
h1,h2,h3{ 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){ @media (prefers-color-scheme: dark){
body{ body{
@ -40,25 +57,43 @@ h1,h2,h3{
</head> </head>
<body> <body>
<h1>2minNoods</h1> <h1>2minNoods</h1>
<hr> <hr>'''
EOF
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 while read i; do
if [ -f "$i" ]; then if [ -f "$i" ]; then
if [ ! -f "siteroot/$i" ]; then if [ ! -f "$siteroot/img/$i" ]; then
echo "Resizing $i" 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
if [[ $noodcount -eq 1 ]]; then
echo "$pageheader" > "$siteroot/index.$pageno.html"
fi
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
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 fi
done < photolist.txt done < "$siteroot/photolist.txt"
cat <<EOF >> siteroot/index.html for ((page=1;page<=pageno;page++)); do
</body> echo -n '<div class="page-links">' >> "$siteroot/index.$page.html"
</html> for ((link=1;link<=pageno;link++)); do
EOF 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"