add navigation from subalbums to upper albums
[booh] / booh
diff --git a/booh b/booh
index 1428824dbd079d0d9aad38654885f9702c93318a..4980f06d7739443dd6b9b421996e6804b3d6cd9c 100755 (executable)
--- a/booh
+++ b/booh
@@ -573,8 +573,8 @@ def walk_source_dir
                                                   img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
                         html_thumbnails.gsub!(/~~caption_iteration~~/,
                                               find_caption_value(xmldir, images[index]) || images[index])
-                        html_thumbnails.gsub!(/~~ifimage\?~~([^~]+)~~/) { $1 }
-                        html_thumbnails.gsub!(/~~ifvideo\?~~[^~]+~~/, '')
+                        html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/) { $1 }
+                        html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/, '')
                     elsif type == 'video'
                         index = videos.index(file)
                         if File.exists?("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}")
@@ -586,8 +586,8 @@ def walk_source_dir
                         end
                         html_thumbnails.gsub!(/~~caption_iteration~~/,
                                               find_caption_value(xmldir, videos[index]) || videos[index])
-                        html_thumbnails.gsub!(/~~ifimage\?~~[^~]+~~/, '')
-                        html_thumbnails.gsub!(/~~ifvideo\?~~([^~]+)~~/) { $1 }
+                        html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/, '')
+                        html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/) { $1 }
                     end
                 end
             end
@@ -694,7 +694,23 @@ def walk_source_dir
         html = $html_index.collect { |l| l.clone }
         iterations = {}
         for i in html
-            i.sub!(/~~title~~/, xmldir.attributes['subdirs-caption'] || xmldir.attributes['thumbnails-caption'] || File.basename(dir))
+            caption = xmldir.attributes['subdirs-caption'] || xmldir.attributes['thumbnails-caption'] || File.basename(dir)
+            i.gsub!(/~~title~~/, caption)
+            if xmldir.parent.name == 'dir'
+                nav = ''
+                path = '..'
+                parent = xmldir.parent
+                while parent.name == 'dir'
+                    parentcaption = parent.attributes['subdirs-caption'] || parent.attributes['thumbnails-caption'] || File.basename(parent.attributes['path'])
+                    nav = "<a href='#{path}/index.html'>#{parentcaption}</a> #{utf8(_(" > "))} #{nav}"
+                    path += '/..'
+                    parent = parent.parent
+                end
+                i.gsub!(/~~ifnavigation\?~~(.+?)~~fi~~/) { $1 }
+                i.gsub!(/~~navigation~~/, nav + caption)
+            else
+                i.gsub!(/~~ifnavigation\?~~(.+?)~~fi~~/, '')
+            end
             discover_iterations(iterations, i)
         end
 
@@ -716,7 +732,6 @@ def walk_source_dir
                 subdir = File.basename(child.attributes['path'])
                 thumbnail = "#{dest_dir}/thumbnails-#{subdir}.jpg"
                 html_index += run_iterations(iterations)
-                html_index.gsub!(/~~image_iteration~~/, "<a href='#{subdir}/index.html'>" + img_element(thumbnail) + '</a>')
                 #- first look for subdirs info; if not, means there is no subdir
                 caption = child.attributes['subdirs-caption']
                 if caption
@@ -726,6 +741,7 @@ def walk_source_dir
                     gen_thumbnails(child.attributes['thumbnails-captionfile'], [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
                     html_index.gsub!(/~~caption_iteration~~/, child.attributes['thumbnails-caption'])
                 end
+                html_index.gsub!(/~~image_iteration~~/, "<a href='#{subdir}/index.html'>" + img_element(thumbnail) + '</a>')
             }
 
         else
@@ -734,7 +750,7 @@ def walk_source_dir
 
         html_index += close_iterations(iterations)
         for i in html
-            i.sub!(/~~thumbnails~~/, html_index)
+            i.gsub!(/~~thumbnails~~/, html_index)
         end
 
         ios = File.open("#{dest_dir}/index.html", "w")