add ability to split thumbnails on several pages, suggested by Till
authorgc <gc>
Sun, 12 Mar 2006 16:46:30 +0000 (16:46 +0000)
committergc <gc>
Sun, 12 Mar 2006 16:46:30 +0000 (16:46 +0000)
bin/booh
bin/booh-backend
data/booh/themes/dark/skeleton_thumbnails.html
data/booh/themes/sbs/skeleton_thumbnails.html
data/booh/themes/simple/skeleton_thumbnails.html
lib/booh/booh-lib.rb
lib/booh/html-merges.rb

index da0028e..5fc8147 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -2919,6 +2919,19 @@ def new_album
     tooltips.set_tip(optimize432, utf8(_("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)")), nil)
     vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
                                    pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
+    nperpage_model = Gtk::ListStore.new(String, String)
+    vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per page: "))), false, false, 0).
+                                   pack_start(nperpagecombo = Gtk::ComboBox.new(nperpage_model), false, false, 0))
+    nperpagecombo.pack_start(crt = Gtk::CellRendererText.new, false)
+    nperpagecombo.set_attributes(crt, { :markup => 0 })
+    iter = nperpage_model.append
+    iter[0] = utf8(_("<i>None - all thumbnails in one page</i>"))
+    iter[1] = nil
+    [ 12, 20, 30, 40, 50 ].each { |v|
+        iter = nperpage_model.append
+        iter[0] = iter[1] = v.to_s
+    }
+    nperpagecombo.active = 0
     vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("'Return to your website' link on pages bottom: "))), false, false, 0).
                                    pack_start(indexlinkentry = Gtk::Entry.new, true, true, 0))
     tooltips.set_tip(indexlinkentry, utf8(_("Optional HTML markup to use on pages bottom for a small link returning to wherever you see fit in your website (or somewhere else)")), nil)
@@ -3063,7 +3076,6 @@ def new_album
 
     dialog.vbox.add(frame1)
     dialog.vbox.add(frame2)
-    dialog.window_position = Gtk::Window::POS_MOUSE
     dialog.show_all
 
     keepon = true
@@ -3124,6 +3136,7 @@ def new_album
         theme = theme_button.label
         sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }.join(',')
         nperrow = nperrows.find { |e| e[:widget].active? }[:value]
+        nperpage = nperpage_model.get_value(nperpagecombo.active_iter, 1)
         opt432 = optimize432.active?
         madewith = madewithentry.text
         indexlink = indexlinkentry.text
@@ -3138,6 +3151,7 @@ def new_album
     if ok
         call_backend("booh-backend --source '#{srcdir}' --destination '#{destdir}' --config-skel '#{configskel}' --for-gui " +
                      "--verbose-level #{$verbose_level} --theme #{theme} --sizes #{sizes} --thumbnails-per-row #{nperrow} " +
+                     (nperpage ? "--thumbnails-per-page #{nperpage} " : '') +
                      "#{opt432 ? '--optimize-for-32' : ''} --made-with '#{madewith}' --index-link '#{indexlink}' #{additional_booh_options}",
                      utf8(_("Please wait while scanning source directory...")),
                      'full scan',
@@ -3157,6 +3171,7 @@ def properties
     theme = $xmldoc.root.attributes['theme']
     opt432 = !$xmldoc.root.attributes['optimize-for-32'].nil?
     nperrow = $xmldoc.root.attributes['thumbnails-per-row']
+    nperpage = $xmldoc.root.attributes['thumbnails-per-page']
     limit_sizes = $xmldoc.root.attributes['limit-sizes']
     if limit_sizes
         limit_sizes = limit_sizes.split(/,/)
@@ -3188,6 +3203,24 @@ def properties
     tooltips.set_tip(optimize432, utf8(_("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)")), nil)
     vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
                                    pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
+    nperpage_model = Gtk::ListStore.new(String, String)
+    vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per page: "))), false, false, 0).
+                                   pack_start(nperpagecombo = Gtk::ComboBox.new(nperpage_model), false, false, 0))
+    nperpagecombo.pack_start(crt = Gtk::CellRendererText.new, false)
+    nperpagecombo.set_attributes(crt, { :markup => 0 })
+    iter = nperpage_model.append
+    iter[0] = utf8(_("<i>None - all thumbnails in one page</i>"))
+    iter[1] = nil
+    [ 12, 20, 30, 40, 50 ].each { |v|
+        iter = nperpage_model.append
+        iter[0] = iter[1] = v.to_s
+        if nperpage && nperpage == v.to_s
+            nperpagecombo.active_iter = iter
+        end
+    }
+    if nperpagecombo.active_iter.nil?
+        nperpagecombo.active = 0
+    end
 
     vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("'Return to your website' link on pages bottom: "))), false, false, 0).
                                    pack_start(indexlinkentry = Gtk::Entry.new, true, true, 0))
@@ -3263,7 +3296,6 @@ def properties
 
     dialog.vbox.add(frame1)
     dialog.vbox.add(frame2)
-    dialog.window_position = Gtk::Window::POS_MOUSE
     dialog.show_all
 
     keepon = true
@@ -3285,15 +3317,17 @@ def properties
     save_limit_sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }
     save_opt432 = optimize432.active?
     save_nperrow = nperrows.find { |e| e[:widget].active? }[:value]
+    save_nperpage = nperpage_model.get_value(nperpagecombo.active_iter, 1)
     save_madewith = madewithentry.text
     save_indexlink = indexlinkentry.text
     dialog.destroy
 
-    if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432 || save_nperrow != nperrow || save_madewith != madewith || save_indexlink != indexlinkentry)
+    if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432 || save_nperrow != nperrow || save_nperpage != nperpage || save_madewith != madewith || save_indexlink != indexlinkentry)
         mark_document_as_dirty
         save_current_file
         call_backend("booh-backend --use-config '#{$filename}' --for-gui --verbose-level #{$verbose_level} " +
                      "--thumbnails-per-row #{save_nperrow} --theme #{save_theme} --sizes #{save_limit_sizes.join(',')} " +
+                     (save_nperpage ? "--thumbnails-per-page #{save_nperpage} " : '') +
                      "#{save_opt432 ? '--optimize-for-32' : ''} --made-with '#{save_madewith}' --index-link '#{save_indexlink}' #{additional_booh_options}",
                      utf8(_("Please wait while scanning source directory...")),
                      'full scan',
index 9f7b5d2..f520cae 100755 (executable)
@@ -52,6 +52,7 @@ $options = [
 
     [ '--sizes',         '-S', GetoptLong::REQUIRED_ARGUMENT, _("Specify the list of images sizes to use instead of all specified in the theme (this is a comma-separated list)") ],
     [ '--thumbnails-per-row', '-T', GetoptLong::REQUIRED_ARGUMENT, _("Specify the amount of thumbnails per row in the thumbnails page (if applicable in theme)") ],
+    [ '--thumbnails-per-page', '-p', GetoptLong::REQUIRED_ARGUMENT, _("Specify the amount of thumbnails per page in the thumbnails page, after which split occurs") ],
     [ '--optimize-for-32', '-o', GetoptLong::NO_ARGUMENT,       _("Resize images with optimized sizes for 3/2 aspect ratio rather than 4/3 (typical aspect ratio of pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)") ],
     [ '--index-link',    '-l', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages for a small link returning to wherever you see fit in your website (or somewhere else)") ],
     [ '--made-with',     '-n', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages for a small 'made with' message") ],
@@ -195,6 +196,9 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
             when '--thumbnails-per-row'
                 $N_per_row = arg
 
+            when '--thumbnails-per-page'
+                $N_per_page = arg
+
             when '--optimize-for-32'
                 $optimize_for_32 = true
 
@@ -239,6 +243,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
         if $mode == 'use_config' || $mode =~ /^merge_config/
             $optimize_for_32 = !$xmldoc.root.attributes['optimize-for-32'].nil?
             $N_per_row = $xmldoc.root.attributes['thumbnails-per-row']
+            $N_per_page = $xmldoc.root.attributes['thumbnails-per-page']
             $madewith = $xmldoc.root.attributes['made-with']
             $indexlink = $xmldoc.root.attributes['index-link']
         end
@@ -275,6 +280,9 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
         if $N_per_row
             additional_params += " thumbnails-per-row='#{$N_per_row}'"
         end
+        if $N_per_page
+            additional_params += " thumbnails-per-page='#{$N_per_page}'"
+        end
         if $madewith
             additional_params += " made-with='#{$madewith}'"
         end
@@ -304,6 +312,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
         else
             $xmldoc.root.delete_attribute('thumbnails-per-row')
         end
+        if $N_per_page
+            $xmldoc.root.add_attribute('thumbnails-per-page', $N_per_page)
+        else
+            $xmldoc.root.delete_attribute('thumbnails-per-page')
+        end
         if $madewith
             $xmldoc.root.add_attribute('made-with', $madewith)
         else
@@ -408,7 +421,7 @@ def html_reload_to_thumbnails
     html_reload_to_thumbnails.gsub!(/~~all_sizes~~/, all_images_sizes.collect { |s| "\"#{size2js(s['name'])}\"" }.join(', '))
     size_auto_chooser = '';
     all_images_sizes.sort { |a,b| b['optimizedforwidth'].to_i <=> a['optimizedforwidth'].to_i }.
-                     each { |s| size_auto_chooser += "if (w + 50 > #{s['optimizedforwidth']}) { return 'thumbnails-#{size2js(s['name'])}.html'; }\n" }
+                     each { |s| size_auto_chooser += "if (w + 50 > #{s['optimizedforwidth']}) { return 'thumbnails-#{size2js(s['name'])}-1.html'; }\n" }
     html_reload_to_thumbnails.gsub!(/~~size_auto_chooser~~/, size_auto_chooser)
     return html_reload_to_thumbnails
 end
@@ -890,33 +903,46 @@ def walk_source_dir
             }
 
             msg 3, _("\tgenerating HTML pages...")
+            #- fixup max per page
+            if $N_per_page && $N_per_row
+                $N_per_page = $N_per_page.to_i / $N_per_row.to_i * $N_per_row.to_i
+            end
 
-            #- generate thumbnails.html (page with thumbnails)
+            #- generate thumbnails*.html (page with thumbnails)
+            image2thumbnailpage4js = []
             for sizeobj in $images_size
                 info("processing size")
                 html = $html_thumbnails.collect { |l| l.clone }
                 iterations = {}
                 for i in html
-                    i.sub!(/~~run_slideshow~~/, images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html#run_slideshow=1">' + utf8(_('Run slideshow!'))+'</a>')
-                    i.sub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
+                    i.sub!(/~~run_slideshow~~/,
+                           images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html#run_slideshow=1">' + utf8(_('Run slideshow!'))+'</a>')
+                    i.sub!(/~~title~~/,
+                           xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
                     discover_iterations(iterations, i)
                 end
+                all_pages = []
                 html_thumbnails = ''
                 html_thumbnails_nojs = ''
+                counter = 0
+                pagecount = 0
                 reset_iterations(iterations)
                 for file in entries
                     type = images.include?(file) ? 'image' : videos.include?(file) ? 'video' : nil
                     if type
                         if type == 'image' && elem = xmldir.elements["image[@filename='#{utf8(file)}']"]
-                            if  pano = pano_amount(elem)
+                            if pano = pano_amount(elem)
                                 html_elem = run_iterations(iterations, pano)
-                                html_elem.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
+                                counter += count = pano.ceil
+                                html_elem.gsub!(/~~colspan~~/) { "colspan=\"#{count}\"" }
                             else
                                 html_elem = run_iterations(iterations, 1)
+                                counter += 1
                                 html_elem.gsub!(/~~colspan~~/, '')
                             end
                         else 
                             html_elem = run_iterations(iterations, 1)
+                            counter += 1
                             html_elem.gsub!(/~~colspan~~/, '')
                         end
                         if type == 'image'
@@ -948,11 +974,29 @@ def walk_source_dir
                             html_thumbnails_nojs.gsub!(/~~image_iteration~~/, 
                                                        '<a href="' + fullscreen_images[sizeobj['name']][index] + '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
                                                            img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
+                            #- remember in which thumbnails page is this element, for image->thumbnail link
+                            if sizeobj == $images_size[0]
+                                image2thumbnailpage4js << pagecount
+                            end
+                        end
+
+                        if counter == $N_per_page
+                            html_thumbnails      += close_iterations(iterations)
+                            html_thumbnails_nojs += close_iterations(iterations)
+                            all_pages << [ html_thumbnails, html_thumbnails_nojs ]
+                            html_thumbnails = ''
+                            html_thumbnails_nojs = ''
+                            counter = 0
+                            reset_iterations(iterations)
+                            pagecount += 1
                         end
                     end
                 end
-                html_thumbnails      += close_iterations(iterations)
-                html_thumbnails_nojs += close_iterations(iterations)
+                if counter > 0
+                    html_thumbnails      += close_iterations(iterations)
+                    html_thumbnails_nojs += close_iterations(iterations)
+                    all_pages << [ html_thumbnails, html_thumbnails_nojs ]
+                end
                 for i in html
                     i.gsub!(/~~theme~~/, $theme)
                     i.gsub!(/~~current_size~~/, sizeobj['name'])
@@ -961,20 +1005,36 @@ def walk_source_dir
                     i.gsub!(/~~indexlink~~/, $indexlink || '')
                 end
                 html_nojs = html.collect { |l| l.clone }
-                for i in html
-                    i.sub!(/~~thumbnails~~/, html_thumbnails)
-                    substitute_html_sizes(i, sizeobj, 'thumbnails', '')
-                end
-                ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}.html", "w")
-                ios.write(html)
-                ios.close
-                for i in html_nojs
-                    i.sub!(/~~thumbnails~~/, html_thumbnails_nojs)
-                    substitute_html_sizes(i, sizeobj, 'thumbnails', '-nojs')
+                pagecount = 0
+                for page in all_pages
+                    html_thumbnails, html_thumbnails_nojs = page
+                    final_html = html.collect { |l| l.clone }
+                    mstuff = utf8(_("Pages: %s") % (pagecount > 0 ? "<a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{pagecount - 1}.html\">" + _("<- Previous") + "</a> " : '') +
+                                                   all_pages.collect_with_index { |p,idx| page == p ? idx + 1 : "<a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{idx}.html\">#{idx + 1}</a>" }.join(', ') +
+                                                   (pagecount < all_pages.size - 1 ? " <a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{pagecount + 1}.html\">" + _("Next ->") + "</a> " : ''))
+                    for i in final_html
+                        if all_pages.size == 1
+                            i.gsub!(/~~ifmultiplepages\?~~.*~~fi~~/, '')
+                        else
+                            i.gsub!(/~~ifmultiplepages\?~~(.+?)~~fi~~/) { $1 }
+                            i.gsub!(/~~multiplepagesstuff~~/, mstuff)
+                        end
+                        i.sub!(/~~thumbnails~~/, html_thumbnails)
+                        substitute_html_sizes(i, sizeobj, 'thumbnails', '')
+                    end
+                    ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-#{pagecount}.html", "w")
+                    ios.write(final_html)
+                    ios.close
+                    final_html_nojs = html_nojs.collect { |l| l.clone }
+                    for i in final_html_nojs
+                        i.sub!(/~~thumbnails~~/, html_thumbnails_nojs)
+                        substitute_html_sizes(i, sizeobj, 'thumbnails', '-nojs')
+                    end
+                    ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs-#{pagecount}.html", "w")
+                    ios.write(final_html_nojs)
+                    ios.close
+                    pagecount += 1
                 end
-                ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs.html", "w")
-                ios.write(html_nojs)
-                ios.close
             end
 
             info("finished processing sizes")
@@ -987,6 +1047,7 @@ def walk_source_dir
             #- generate image.html (page with fullscreen images)
             if images.size > 0
                 captions4js = find_captions(xmldir, images).collect { |e| e ? '"' + e.gsub('"', '\"') + '"' : '""' }.join(', ')
+                thumbnailspage4js = image2thumbnailpage4js.collect { |e| "\"#{e}\"" }.join(', ')
 
                 for sizeobj in $images_size
                     html = $html_images.collect { |l| l.clone }
@@ -1002,6 +1063,7 @@ def walk_source_dir
                     for i in html
                         i.gsub!(/~~images~~/, images4js)
                         i.gsub!(/~~other_images~~/, otherimages4js)
+                        i.gsub!(/~~thumbnailspages~~/, thumbnailspage4js)
                         i.gsub!(/~~other_sizes~~/, othersizes.join(', '))
                         i.gsub!(/~~captions~~/, captions4js)
                         i.gsub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
@@ -1156,27 +1218,29 @@ def walk_source_dir
         ios.write(html)
         ios.close
 
-        #- substitute "return to albums" and previous/next correctly
+        #- substitute multiple "return to albums", previous/next correctly
         if xmldir.child_byname_notattr('image', 'deleted') || xmldir.child_byname_notattr('video', 'deleted')
             for suffix in [ '', '-nojs' ]
                 for sizeobj in $images_size
-                    substInFile("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}#{suffix}.html") { |line|
-                        sub_previous_next_album(previous_album, next_album, line)
-                        if xmldir.elements['dir']
-                            line.sub!(/~~return_to_albums~~/, '<a href="index.html">' + utf8(_('return to albums')) + '</a>')
-                        else
-                            if xmldir.parent.name == 'dir'
-                                line.sub!(/~~return_to_albums~~/, '<a href="../index.html">' + utf8(_('return to albums')) + '</a>')
+                    Dir.glob("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}#{suffix}-*.html") do |file|
+                        substInFile(file) { |line|
+                            sub_previous_next_album(previous_album, next_album, line)
+                            if xmldir.elements['dir']
+                                line.sub!(/~~return_to_albums~~/, '<a href="index.html">' + utf8(_('return to albums')) + '</a>')
                             else
-                                line.sub!(/~~return_to_albums~~/, '')
+                                if xmldir.parent.name == 'dir'
+                                    line.sub!(/~~return_to_albums~~/, '<a href="../index.html">' + utf8(_('return to albums')) + '</a>')
+                                else
+                                    line.sub!(/~~return_to_albums~~/, '')
+                                end
                             end
-                        end
-                        line
-                    }
-                    if suffix == '' && xmldir.child_byname_notattr('image', 'deleted')
-                        substInFile("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html") { |line|
-                            sub_previous_next_album(previous_album, next_album, line)
+                            line
                         }
+                        if suffix == '' && xmldir.child_byname_notattr('image', 'deleted')
+                            substInFile("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html") { |line|
+                                sub_previous_next_album(previous_album, next_album, line)
+                            }
+                        end
                     end
                 end
             end
index bd2f6fb..bd98500 100644 (file)
@@ -58,6 +58,8 @@ img {
     ~~run_slideshow~~
 </p>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <table width="100%">
 ~~iterate1_open~~
 <tr>
@@ -71,6 +73,8 @@ img {
 ~~iterate1_close~~
 </table>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <p align="center">~~previous_album~~ ~~ifprevious_album?~~|~~fi~~ ~~return_to_albums~~ ~~ifnext_album?~~|~~fi~~ ~~next_album~~</p>
 
 <p align="right"><font size="-1"><i>~~madewith~~</i></font></p>
index 5837008..5e4b4f7 100644 (file)
@@ -67,6 +67,8 @@ img {
     ~~run_slideshow~~
 </p>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <table width="100%">
 ~~iterate1_open~~
 <tr>
@@ -80,6 +82,8 @@ img {
 ~~iterate1_close~~
 </table>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <p align="center">~~previous_album~~ ~~ifprevious_album?~~|~~fi~~ ~~return_to_albums~~ ~~ifnext_album?~~|~~fi~~ ~~next_album~~</p>
 
 </body>
index c84f784..1a861cb 100644 (file)
@@ -55,6 +55,8 @@ img {
     ~~run_slideshow~~
 </p>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <table width="100%">
 ~~iterate1_open~~
 <tr>
@@ -68,6 +70,8 @@ img {
 ~~iterate1_close~~
 </table>
 
+~~ifmultiplepages?~~<p align="center"><font size="-1">~~multiplepagesstuff~~</font></p>~~fi~~
+
 <p align="center">~~previous_album~~ ~~ifprevious_album?~~|~~fi~~ ~~return_to_albums~~ ~~ifnext_album?~~|~~fi~~ ~~next_album~~</p>
 
 <table width="100%" cellpadding="0" border="0">
index 35a3b36..f0df7de 100644 (file)
@@ -475,6 +475,16 @@ class File
     end
 end
 
+module Enumerable
+    def collect_with_index
+        out = []
+        each_with_index { |e,i|
+            out << yield(e,i)
+        }
+        return out
+    end
+end
+
 class REXML::Element
     def previous_element_byname(name)
         n = self
index b34b099..d17353d 100644 (file)
@@ -33,6 +33,7 @@ $image_head_code = '<meta name="generator" content="Booh-' + $VERSION + <<'EOF'
 <script language="JavaScript1.1" type="text/JavaScript">
 var images = new Array(~~images~~);
 ~~other_images~~
+var thumbnailspages = new Array(~~thumbnailspages~~);
 var other_sizes = new Array(~~other_sizes~~);
 var captions = new Array(~~captions~~);
 
@@ -262,7 +263,7 @@ function show_current_text() {
                 document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + '.html#current=' + eval("images_" + other_sizes[i] + "[current]");
             }
         }
-        document.getElementById('thumbnails').href = 'thumbnails-~~current_size~~.html#' + images[current];
+        document.getElementById('thumbnails').href = 'thumbnails-~~current_size~~-' + thumbnailspages[current] + '.html#' + images[current];
         set_cursor("default");
     } else {
         setTimeout("show_current_text()", 100);
@@ -509,21 +510,21 @@ function getPreferredSize() {
             size = document.cookie.substring(oleft, oright);
             for (i = 0; i < sizes.length; i++) {
                 if (sizes[i] == size) {
-                    return 'thumbnails-' + size + '.html';
+                    return 'thumbnails-' + size + '-0.html';
                 }
             }
         }
     }
     w = document.body.offsetWidth;
     ~~size_auto_chooser~~
-    return 'thumbnails-~~default_size~~.html';
+    return 'thumbnails-~~default_size~~-0.html';
 }
 
 window.location.href = getPreferredSize();
 
         </script>
 
-        <meta http-equiv="refresh" content="0.1;url=thumbnails-~~default_size~~-nojs.html">
+        <meta http-equiv="refresh" content="0.1;url=thumbnails-~~default_size~~-nojs-0.html">
 </html>
 EOF