handle a link to original image
[booh] / bin / booh
index fb8d643bb7309aa5674552785f8d7e371fed377f..49762e1a526e670d1dd77d2eab85dfd1e7df8583 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -310,7 +310,7 @@ end
 
 def substitute_html_sizes(html, sizeobj, type)
     sizestrings = []
 
 def substitute_html_sizes(html, sizeobj, type)
     sizestrings = []
-    if $images_size.length > 1
+    if $images_size.length > 1 || (type == 'image' && $limit_sizes =~ /original/)
         for sizeobj2 in $images_size
             if sizeobj != sizeobj2
                 if type == 'thumbnails'
         for sizeobj2 in $images_size
             if sizeobj != sizeobj2
                 if type == 'thumbnails'
@@ -322,6 +322,9 @@ def substitute_html_sizes(html, sizeobj, type)
                 sizestrings << sizename(sizeobj2['name'])
             end
         end
                 sizestrings << sizename(sizeobj2['name'])
             end
         end
+        if type == 'image' && $limit_sizes =~ /original/
+            sizestrings << '<a id="linkoriginal" target="newframe">' + sizename('original') + '</a>'
+        end
     end
     html.sub!(/~~sizes~~(.+)~~/) { sizestrings.join($1) }
 end
     end
     html.sub!(/~~sizes~~(.+)~~/) { sizestrings.join($1) }
 end
@@ -411,6 +414,9 @@ def walk_source_dir
             thumbnail_videos ||= {}
             thumbnail_videos[sizeobj['name']] = []
         end
             thumbnail_videos ||= {}
             thumbnail_videos[sizeobj['name']] = []
         end
+        if $limit_sizes =~ /original/
+            fullscreen_images['original'] = []
+        end
 
         images.size >= 1 and msg 3, _("\tcreating images thumbnails...")
 
 
         images.size >= 1 and msg 3, _("\tcreating images thumbnails...")
 
@@ -431,6 +437,13 @@ def walk_source_dir
                     gen_thumbnails_element("#{dir}/#{img}", xmldir, true, [ { 'filename' => fullscreen_dest_img, 'size' => size_fullscreen },
                                                                             { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
                 end
                     gen_thumbnails_element("#{dir}/#{img}", xmldir, true, [ { 'filename' => fullscreen_dest_img, 'size' => size_fullscreen },
                                                                             { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
                 end
+                if $limit_sizes =~ /original/
+                    fullscreen_images['original'] << img
+                end
+                destimg = "#{dest_dir}/#{img}"
+                if $limit_sizes =~ /original/ && !File.exists?(destimg)
+                    psys("cp '#{dir}/#{img}' '#{destimg}'")
+                end
             end
         }
 
             end
         }
 
@@ -536,7 +549,8 @@ def walk_source_dir
                     images4js = fullscreen_images[sizeobj['name']].collect { |e| "\"#{e}\"" }.join(', ')
                     otherimages4js = ''
                     othersizes = []
                     images4js = fullscreen_images[sizeobj['name']].collect { |e| "\"#{e}\"" }.join(', ')
                     otherimages4js = ''
                     othersizes = []
-                    for sizeobj2 in $images_size
+                    all_images_sizes = $limit_sizes =~ /original/ ? $images_size + [ { 'name' => 'original' } ] : $images_size
+                    for sizeobj2 in all_images_sizes
                         if sizeobj != sizeobj2
                             otherimages4js += "var images_#{size2js(sizeobj2['name'])} = new Array(" + fullscreen_images[sizeobj2['name']].collect { |e| "\"#{e}\"" }.join(', ') + ")\n"
                             othersizes << "\"#{size2js(sizeobj2['name'])}\""
                         if sizeobj != sizeobj2
                             otherimages4js += "var images_#{size2js(sizeobj2['name'])} = new Array(" + fullscreen_images[sizeobj2['name']].collect { |e| "\"#{e}\"" }.join(', ') + ")\n"
                             othersizes << "\"#{size2js(sizeobj2['name'])}\""