be nice with ice age browsers
authorgc <gc>
Fri, 17 Feb 2006 23:01:35 +0000 (23:01 +0000)
committergc <gc>
Fri, 17 Feb 2006 23:01:35 +0000 (23:01 +0000)
bin/booh-backend
lib/booh/html-merges.rb

index 76383f1c64b8b14db74016b13effb1956676a1e8..9f7b5d2086d71849865f340f70f52bc3dc2ae7ff 100755 (executable)
@@ -500,13 +500,13 @@ def size2js(name)
     return name.gsub(/-/, '')
 end
 
-def substitute_html_sizes(html, sizeobj, type)
+def substitute_html_sizes(html, sizeobj, type, suffix)
     sizestrings = []
     if $images_size.length > 1 || (type == 'image' && $limit_sizes =~ /original/)
         for sizeobj2 in $images_size
             if sizeobj != sizeobj2
                 if type == 'thumbnails'
-                    sizestrings << '<a href="thumbnails-' + size2js(sizeobj2['name']) + '.html">' + sizename(sizeobj2['name']) + '</a>'
+                    sizestrings << '<a href="thumbnails-' + size2js(sizeobj2['name']) + suffix + '.html">' + sizename(sizeobj2['name']) + '</a>'
                 else
                     sizestrings << '<a id="link' + size2js(sizeobj2['name']) + '">' + sizename(sizeobj2['name']) + '</a>'
                 end
@@ -899,64 +899,82 @@ def walk_source_dir
                 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)))
-                    substitute_html_sizes(i, sizeobj, 'thumbnails')
                     discover_iterations(iterations, i)
                 end
                 html_thumbnails = ''
+                html_thumbnails_nojs = ''
                 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)
-                                html_thumbnails += run_iterations(iterations, pano)
-                                html_thumbnails.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
+                                html_elem = run_iterations(iterations, pano)
+                                html_elem.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
                             else
-                                html_thumbnails += run_iterations(iterations, 1)
-                                html_thumbnails.gsub!(/~~colspan~~/, '')
+                                html_elem = run_iterations(iterations, 1)
+                                html_elem.gsub!(/~~colspan~~/, '')
                             end
                         else 
-                            html_thumbnails += run_iterations(iterations, 1)
-                            html_thumbnails.gsub!(/~~colspan~~/, '')
+                            html_elem = run_iterations(iterations, 1)
+                            html_elem.gsub!(/~~colspan~~/, '')
                         end
                         if type == 'image'
                             index = images.index(file)
-                            html_thumbnails.gsub!(/~~image_iteration~~/,
-                                                  '<a href="image-' + size2js(sizeobj['name']) + '.html#current=' + fullscreen_images[sizeobj['name']][index] +
-                                                      '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
-                                                      img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
-                            html_thumbnails.gsub!(/~~caption_iteration~~/,
-                                                  find_caption_value(xmldir, images[index]) || utf8(images[index]))
-                            html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/) { $1 }
-                            html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/, '')
+                            html_elem.gsub!(/~~caption_iteration~~/,
+                                            find_caption_value(xmldir, images[index]) || utf8(images[index]))
+                            html_elem.gsub!(/~~ifimage\?~~(.+?)~~fi~~/) { $1 }
+                            html_elem.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/, '')
                         elsif type == 'video'
                             index = videos.index(file)
                             if File.exists?("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}")
-                                html_thumbnails.gsub!(/~~image_iteration~~/,
-                                                      '<a href="' + videos[index] + '">' + img_element("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}") + '</a>')
+                                html_elem.gsub!(/~~image_iteration~~/,
+                                                '<a href="' + videos[index] + '">' + img_element("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}") + '</a>')
                             else
-                                html_thumbnails.gsub!(/~~image_iteration~~/,
-                                                      '<a href="' + videos[index] + '">' + utf8(_("(no preview)")) + '</a>')
+                                html_elem.gsub!(/~~image_iteration~~/,
+                                                '<a href="' + videos[index] + '">' + utf8(_("(no preview)")) + '</a>')
                             end
-                            html_thumbnails.gsub!(/~~caption_iteration~~/,
-                                                  find_caption_value(xmldir, videos[index]) || utf8(videos[index]))
-                            html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/, '')
-                            html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/) { $1 }
+                            html_elem.gsub!(/~~caption_iteration~~/, find_caption_value(xmldir, videos[index]) || utf8(videos[index]))
+                            html_elem.gsub!(/~~ifimage\?~~(.+?)~~fi~~/, '')
+                            html_elem.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/) { $1 }
+                        end
+                        html_thumbnails += html_elem
+                        html_thumbnails_nojs += html_elem
+                        if type == 'image'
+                            html_thumbnails.gsub!(/~~image_iteration~~/,
+                                                  '<a href="image-' + size2js(sizeobj['name']) + '.html#current=' + fullscreen_images[sizeobj['name']][index] +
+                                                      '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
+                                                      img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
+                            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>')
                         end
                     end
                 end
-                html_thumbnails += close_iterations(iterations)
+                html_thumbnails      += close_iterations(iterations)
+                html_thumbnails_nojs += close_iterations(iterations)
                 for i in html
-                    i.sub!(/~~thumbnails~~/, html_thumbnails)
                     i.gsub!(/~~theme~~/, $theme)
                     i.gsub!(/~~current_size~~/, sizeobj['name'])
                     i.gsub!(/~~current_size_js~~/, size2js(sizeobj['name']))
                     i.gsub!(/~~madewith~~/, $madewith || '')
                     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')
+                end
+                ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs.html", "w")
+                ios.write(html_nojs)
+                ios.close
             end
 
             info("finished processing sizes")
@@ -992,7 +1010,7 @@ def walk_source_dir
                         i.gsub!(/~~current_size~~/, size2js(sizeobj['name']))
                         i.gsub!(/~~madewith~~/, $madewith || '')
                         i.gsub!(/~~indexlink~~/, $indexlink || '')
-                        substitute_html_sizes(i, sizeobj, 'image')
+                        substitute_html_sizes(i, sizeobj, 'image', '')
                     end
                     ios = File.open("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html", "w")
                     ios.write(html)
@@ -1140,24 +1158,26 @@ def walk_source_dir
 
         #- substitute "return to albums" and previous/next correctly
         if xmldir.child_byname_notattr('image', 'deleted') || xmldir.child_byname_notattr('video', 'deleted')
-            for sizeobj in $images_size
-                substInFile("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}.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>')
+            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
-                            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 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 5d6f813db970d3acd0084220cf0392e163c4cf00..b34b099fb85b9e9130324fb532fc291a1f4bd3bc 100644 (file)
@@ -522,6 +522,8 @@ function getPreferredSize() {
 window.location.href = getPreferredSize();
 
         </script>
+
+        <meta http-equiv="refresh" content="0.1;url=thumbnails-~~default_size~~-nojs.html">
 </html>
 EOF