Add page numbers to top of page, use mktemp(1) for temp files
This commit is contained in:
parent
a37c16ff4e
commit
8eea7fc1b5
23
2minNoods.sh
23
2minNoods.sh
|
@ -7,7 +7,7 @@ noodspp=40
|
|||
mkdir -p "$siteroot/img/thumbs"
|
||||
pageno=1
|
||||
noodcount=1
|
||||
|
||||
photolist="$(mktemp --suffix='.txt')"
|
||||
|
||||
# html and css stolen from https://perfectmotherfuckingwebsite.com/
|
||||
pageheader='''<!DOCTYPE html>
|
||||
|
@ -57,13 +57,14 @@ a.button{
|
|||
</head>
|
||||
<body>
|
||||
<h1>2minNoods</h1>
|
||||
<hr>'''
|
||||
<hr>
|
||||
<!--pageno-->'''
|
||||
|
||||
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"
|
||||
ls *.jpg | sort -k2 -t'_' -r > "$photolist"
|
||||
|
||||
while read i; do
|
||||
if [ -f "$i" ]; then
|
||||
|
@ -82,26 +83,30 @@ while read i; do
|
|||
noodcount=1
|
||||
fi
|
||||
fi
|
||||
done < "$siteroot/photolist.txt"
|
||||
done < "$photolist"
|
||||
|
||||
for ((page=1;page<=pageno;page++)); do
|
||||
echo -n '<div class="page-links">' >> "$siteroot/index.$page.html"
|
||||
htmlpagenumbers=$(
|
||||
echo -n '<div class="page-links">'
|
||||
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
|
||||
echo '</div><hr>')
|
||||
echo "$htmlpagenumbers" >> "$siteroot/index.$page.html"
|
||||
sed -i "s%<!--pageno-->%$htmlpagenumbers%" "$siteroot/index.$page.html"
|
||||
echo '</body></html>' >> "$siteroot/index.$page.html"
|
||||
done
|
||||
|
||||
echo "Searching for deleted images"
|
||||
for i in $siteroot/img/*.jpg; do
|
||||
pic="$(basename $i)"
|
||||
if ! grep -Fxq "$pic" "$siteroot/photolist.txt"; then
|
||||
if ! grep -Fxq "$pic" "$photolist"; then
|
||||
rm -v "$siteroot/img/thumbs/$pic" "$siteroot/img/$pic"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -v "$siteroot/photolist.txt"
|
||||
rm -v "$photolist"
|
||||
|
|
Loading…
Reference in New Issue