]> git.plutz.net Git - clickslide/blobdiff - clickslide.sh
use checkbox hack for cleaner item uncovering
[clickslide] / clickslide.sh
similarity index 61%
rename from autoslide.sh
rename to clickslide.sh
index ead295b3dcf14a524345c2923369962cc041674a..ddc94c37ef79e44753e54fc71b670f1aef45d0f2 100755 (executable)
@@ -1,8 +1,10 @@
 #!/bin/sh
 
 prev='' next='' idoff=0
+depth=0 ucdepth=-1
 
-"${0%/*}"/cgilite/html-sh.sed | {
+{ "${0%/*}"/cgilite/html-sh.sed || cat; } \
+| {
   line="$(line)"
   while :; do 
     tag="${tag}${line%%>*}"
@@ -22,6 +24,13 @@ prev='' next='' idoff=0
     fi
   
     case $tag in
+      *\<head\>*|\*\<head\ *\>)
+        printf '%s<meta name="viewport" content="width=device-width">
+                <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
+        cat "${0%/*}/clickslide.css"
+        printf '\n--></style>%s' "${tag#*<head*>}"
+        tag='' depth=$((depth + 1))
+        ;;
       *\<slide\ *id=\"?*\"*\>*)
         prev="$next"
         next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
@@ -29,7 +38,7 @@ prev='' next='' idoff=0
         idoff="$((idoff + 1))"
         printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
           "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
-        tag=''
+        tag='' depth=$((depth + 1))
         ;;
       *\<slide\ *\>*|*\<slide\>*)
         prev="$next"
@@ -37,27 +46,39 @@ prev='' next='' idoff=0
         idoff="$((idoff + 1))"
         printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
           "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
-        tag=''
+        tag='' depth=$((depth + 1))
         ;;
       *\</slide\>*)
         printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
           "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
-        tag=''
+        tag='' depth=$((depth - 1))
         ;;
       *\<*class=\"uncover\"*\>*)
-        printf '%s<span></span>' "$tag"
-        tag=''
+        #printf '%s<li></li>' "$tag"
+        printf '%s' "$tag"
+        tag='' depth=$((depth + 1))
+        ucdepth=$depth
         ;;
       *\<body*\>*)
         printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
-        tag=''
+        tag='' depth=$((depth + 1))
         ;;
       *\</body*\>*)
         printf '<span class="count">%i</span>%s' "$idoff" "$tag"
-        tag=''
+        tag='' depth=$((depth - 1))
         ;;
-      *\<*\>*)
+      *\</*\>*)
         printf %s "$tag"
+        tag='' depth=$((depth - 1))
+        [ $depth -lt $ucdepth ] && ucdepth=-1
+        ;;
+      *\<*\>*)
+        if [ $ucdepth = $depth ]; then
+          printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
+        else
+          printf %s "$tag"
+        fi
+        [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))
         tag=''
         ;;
       *) :