]> Sergey Matveev's repositories - galgen.git/commitdiff
More navigation links
authorSergey Matveev <stargrave@stargrave.org>
Wed, 22 Feb 2023 10:41:40 +0000 (13:41 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 22 Feb 2023 10:41:40 +0000 (13:41 +0300)
galgen.zsh

index 8124fd8554016b2fa6adb7c8d77eb82b9d3a0077..0e03a3a99d8e7440a37acd3407565f460c61e199 100755 (executable)
@@ -27,16 +27,34 @@ djxl2ppm() {
 
 setopt EXTENDED_GLOB
 imgs=((*.jxl|*.webp~*.preview.webp)($ordering))
+pages=$(( ${#imgs} / $pagesize ))
+[[ $(( $pages * $pagesize )) -lt ${#imgs} ]] && pages=$(( $pages + 1 ))
+
 for (( i=1 ; i <= ${#imgs} ; i++ )) {
     local img=${imgs[$i]}
     echo $i $img
     local dst=$i.img.html
+    local p=$(( ( $i / $pagesize ) + 1 ))
     cat > $dst <<EOF
 <!DOCTYPE html>
-<html><head>${style}<title>Image ${i}/${#imgs}: $img</title></head><body>
+<html>
+    <head>
+        ${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">
+EOF
+    [[ $i -eq 1 ]] ||
+        echo "<link href=\"$(( $i - 1 )).img.html\" rel=\"prev\" title=\"previous\">" >> $dst
+    [[ $i -eq ${#imgs} ]] ||
+        echo "<link href=\"$(( $i + 1 )).img.html\" rel=\"next\" title=\"next\">" >> $dst
+    cat >> $dst <<EOF
+    </head>
+<body>
 EOF
     [[ $i -eq 1 ]] ||
         echo "<a href=\"$(( $i - 1 )).img.html\">&lt;&lt;&lt;</a>" >> $dst
+    echo "<a href=\"${p}.page.html\">^^^</a>" >> $dst
     [[ $i -eq ${#imgs} ]] ||
         echo "<a href=\"$(( $i + 1 )).img.html\">&gt;&gt;&gt;</a>" >> $dst
     echo "<hr/><img alt=\"$img\" src=\"$img\"/>" >> $dst
@@ -92,13 +110,23 @@ EOF
     touch -r $img $dst
 }
 
-pages=$(( ${#imgs} / $pagesize ))
-[[ $(( $pages * $pagesize )) -lt ${#imgs} ]] && pages=$(( $pages + 1 ))
 for (( p=1 ; p <= $pages ; p++ )) {
     local dst=$p.page.html
     cat > $dst <<EOF
 <!DOCTYPE html>
-<html><head>${style}<title>Page ${p}/$pages</title></head><body>
+<html>
+    <head>
+        ${style}
+        <title>Page ${p}/$pages</title>
+        <link href="1.page.html" rel="start" title="home">
+EOF
+    [[ $p -eq 1 ]] ||
+        echo "<link href=\"$(( $p - 1 )).page.html\" rel=\"prev\" title=\"previous\">" >> $dst
+    [[ $p -eq $pages ]] ||
+        echo "<link href=\"$(( $p + 1 )).page.html\" rel=\"next\" title=\"next\">" >> $dst
+    cat >> $dst <<EOF
+    </head>
+<body>
 EOF
     [[ $p -eq 1 ]] && [[ -r .txt ]] && {
         echo "<pre>" >> $dst