]> Sergey Matveev's repositories - galgen.git/commitdiff
Less duplicate links and entities master
authorSergey Matveev <stargrave@stargrave.org>
Thu, 5 Feb 2026 10:56:15 +0000 (13:56 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 5 Feb 2026 11:07:18 +0000 (14:07 +0300)
galgen

diff --git a/galgen b/galgen
index 4e1321d069e58bba131bdb6a3767c4244a54865b..0fb803d440040cc6ebee3e2c714d582643e314c3 100755 (executable)
--- a/galgen
+++ b/galgen
@@ -1,7 +1,7 @@
 #!/usr/bin/env zsh
 # Copyright (C) 2022-2026 Sergey Matveev <stargrave@stargrave.org>
 
-VERSION=0.7.0
+VERSION=0.8.0
 
 setopt ERR_EXIT
 
@@ -18,7 +18,7 @@ exifTagsOmit=(
     FilePermissions
 )
 
-[[ -z $style ]] || style="<link rel=\"stylesheet\" type=\"text/css\" href=\"$style\">"
+[[ -z $style ]] || style="<link rel=stylesheet type=\"text/css\" href=\"$style\">"
 
 mkdir -p alt .info preview
 setopt EXTENDED_GLOB
@@ -27,7 +27,7 @@ imgs=()
 for img (*.jxl(N)) { [[ -r .info/$img.img ]] || imgs=($imgs $img) }
 [[ ${#imgs} == 0 ]] || {
     echo Infos... >&2
-    parallel "jxlinfo {} > .info/{}.img" ::: $imgs
+    parallel "jxlinfo {} >.info/{}.img" ::: $imgs
 }
 
 imgs=()
@@ -36,7 +36,7 @@ for img ($src) { [[ -r .info/$img.exif ]] || imgs=($imgs $img) }
 src=()
 [[ ${#imgs} == 0 ]] || {
     echo Exif info... >&2
-    parallel "exiftool -escapeHTML -htmlFormat -groupHeadings --${=${(j/ --/)exifTagsOmit}} {} > .info/{}.exif" ::: $imgs
+    parallel "exiftool -escapeHTML -htmlFormat -groupHeadings --${=${(j/ --/)exifTagsOmit}} {} >.info/{}.exif" ::: $imgs
 }
 
 imgs=((*.jxl)($ordering))
@@ -72,7 +72,7 @@ else
 
     [[ ${#pngs} == 0 ]] || {
         echo PNG generation... >&2
-        parallel "$djxl2pam | pamtopng > {}.png" ::: $pngs
+        parallel "$djxl2pam | pamtopng >{}.png" ::: $pngs
         parallel "pngcrush -warn -rem alla -rem allb -z 2 {}.png alt/{}.png && rm {}.png" ::: $pngs
         parallel "advpng --quiet --recompress -4 alt/{}.png && touch -r {} alt/{}.png" ::: $pngs
     }
@@ -93,112 +93,99 @@ for (( i=1 ; i <= ${#imgs} ; i++ )) {
     echo $i $img
     local dst=$i.img.html
     local p=$(( ( $i / $pagesize ) + 1 ))
-    cat > $tmp <<EOF
+    cat >$tmp <<EOF
 <!DOCTYPE html>
 <html>
     <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-        <meta name="generator" content="galgen $VERSION">
+        <meta http-equiv=Content-Type content="text/html; charset=utf-8">
+        <meta name=generator content="galgen $VERSION">
         ${style}
         <title>Image ${i}/${#imgs}: $img</title>
-        <link href="1.page.html" rel="start" title="home">
-        <link href="${p}.page.html" rel="up" title="page">
+        <link rel=start href="1.page.html" title="home">
+        <link rel=up href="${p}.page.html" title="page">
 EOF
     [[ $i -eq 1 ]] ||
-        echo "<link href=\"$(( $i - 1 )).img.html\" rel=\"prev\" title=\"previous\">" >> $tmp
+        echo "<link rel=prev href=\"$(( $i - 1 )).img.html\" title=\"prev\">" >>$tmp
     [[ $i -eq ${#imgs} ]] ||
-        echo "<link href=\"$(( $i + 1 )).img.html\" rel=\"next\" title=\"next\">" >> $tmp
-    cat >> $tmp <<EOF
+        echo "<link rel=next href=\"$(( $i + 1 )).img.html\" title=\"next\">" >>$tmp
+    cat >>$tmp <<EOF
     </head>
 <body>
 EOF
-    [[ $i -eq 1 ]] ||
-        echo "<a href=\"$(( $i - 1 )).img.html\">&lt;&lt;&lt;</a>" >> $tmp
-    echo "<a href=\"${p}.page.html\">^^^</a>" >> $tmp
-    [[ $i -eq ${#imgs} ]] ||
-        echo "<a href=\"$(( $i + 1 )).img.html\">&gt;&gt;&gt;</a>" >> $tmp
-    echo "<hr/><img alt=\"$img\" src=\"$img\" />" >> $tmp
+    echo "<img alt=\"$img\" src=\"$img\" />" >>$tmp
     [[ ! -r ${img}.txt ]] || {
-        echo "<hr/><pre>" >> $tmp
-        cat ${img}.txt >> $tmp
-        echo "</pre>" >> $tmp
+        echo "<pre>" >>$tmp
+        cat ${img}.txt >>$tmp
+        echo "</pre>" >>$tmp
     }
-    [[ ! -r ${img}.html ]] || { cat ${img}.html >> $tmp }
-    echo "<hr/>" >> $tmp
+    [[ ! -r ${img}.html ]] || { cat ${img}.html >>$tmp }
     [[ -r .info/$img.img ]]
-    echo "<pre>" >> $tmp
-    cat .info/$img.img >> $tmp
-    echo "</pre>" >> $tmp
+    echo "<pre>" >>$tmp
+    cat .info/$img.img >>$tmp
+    echo "</pre>" >>$tmp
     [[ -n "$NOALT" ]] || {
         if [[ $img:e = jxl ]] ; then
-            echo "Alternative formats:" >> $tmp
+            echo "Alternative formats:" >>$tmp
             [[ -r alt/$img.jpg ]] && {
-                echo "<a href=\"alt/$img.jpg\">JPEG</a>" >> $tmp
+                echo "<a href=\"alt/$img.jpg\">JPEG</a>" >>$tmp
             } || {
-                echo "<a href=\"alt/$img.png\">PNG</a>" >> $tmp
+                echo "<a href=\"alt/$img.png\">PNG</a>" >>$tmp
             }
         fi
-        echo "<hr/>" >> $tmp
     }
     [[ -r .info/$img.exif ]]
-    cat .info/$img.exif >> $tmp
-    echo "</body></html>" >> $tmp
+    cat .info/$img.exif >>$tmp
+    echo "</body></html>" >>$tmp
     cmp -s $tmp $dst || {
-        cat $tmp > $dst
+        cat $tmp >$dst
         touch -r $img $dst
     }
 }
 
 for (( p=1 ; p <= $pages ; p++ )) {
     local dst=$p.page.html
-    cat > $tmp <<EOF
+    cat >$tmp <<EOF
 <!DOCTYPE html>
 <html>
     <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-        <meta name="generator" content="galgen $VERSION">
+        <meta http-equiv=Content-Type content="text/html; charset=utf-8">
+        <meta name=generator content="galgen $VERSION">
         ${style}
         <title>Page ${p}/$pages</title>
-        <link href="1.page.html" rel="start" title="home">
+        <link rel=start href="1.page.html" title="home">
+        <link rel=end href="${pages}.page.html" title="end">
 EOF
     [[ $p -eq 1 ]] ||
-        echo "<link href=\"$(( $p - 1 )).page.html\" rel=\"prev\" title=\"previous\">" >> $tmp
+        echo "<link rel=prev href=\"$(( $p - 1 )).page.html\" title=\"prev\">" >>$tmp
     [[ $p -eq $pages ]] ||
-        echo "<link href=\"$(( $p + 1 )).page.html\" rel=\"next\" title=\"next\">" >> $tmp
-    cat >> $tmp <<EOF
+        echo "<link rel=next href=\"$(( $p + 1 )).page.html\" title=\"next\">" >>$tmp
+    cat >>$tmp <<EOF
     </head>
 <body>
 EOF
     [[ $p -ne 1 ]] || {
         [[ ! -r .txt ]] || {
-            echo "<pre>" >> $tmp
-            cat .txt >> $tmp
-            echo "</pre>" >> $tmp
+            echo "<pre>" >>$tmp
+            cat .txt >>$tmp
+            echo "</pre>" >>$tmp
         }
-        [[ ! -r .html ]] || { cat .html >> $tmp }
+        [[ ! -r .html ]] || { cat .html >>$tmp }
     }
-    [[ $p -eq 1 ]] ||
-        echo "<a href=\"$(( $p - 1 )).page.html\">&lt;&lt;&lt;</a>" >> $tmp
-    [[ $p -eq $pages ]] ||
-        echo "<a href=\"$(( $p + 1 )).page.html\">&gt;&gt;&gt;</a>" >> $tmp
-    echo "| <a href=\"1.page.html\">home</a>" >> $tmp
-    echo "| <a href=\"${pages}.page.html\">end</a>" >> $tmp
-    echo "<hr/>" >> $tmp
     for (( i=1 ; i <= $pagesize ; i++ )) {
         img=$(( ( $p - 1 ) * $pagesize + $i ))
         [[ $img -le ${#imgs} ]] || break
-        echo "<a href=\"${img}.img.html\">" >> $tmp
+        echo "<a href=\"${img}.img.html\">" >>$tmp
         alt="preview ${img}"
         title=""
         [[ ! -r ${imgs[$img]}.txt ]] || {
             alt=`cat ${imgs[$img]}.txt`
             title="title=\"$alt\""
         }
-        echo "<img alt=\"$alt\" $title src=\"preview/${imgs[$img]}.webp\" /></a>" >> $tmp
+        echo "<img alt=\"$alt\" $title src=\"preview/${imgs[$img]}.webp\" /></a>" >>$tmp
     }
-    echo "</body></html>" >> $tmp
+    echo "</body></html>" >>$tmp
     cmp -s $tmp $dst || {
-        cat $tmp > $dst
+        cat $tmp >$dst
         echo page $p
     }
 }