allow ~~navigation~~ in more places
[booh] / bin / booh-backend
index 58ceaa75fbba636cf0459bf8d87d4518a4d14b82..d33cfc3eb3280fa6a81ec044a84ebe31dc0e4cc3 100755 (executable)
@@ -537,6 +537,24 @@ def substitute_html_sizes(html, sizeobj, type, suffix)
     html.sub!(/~~sizes~~(.+)~~/) { sizestrings.join($1) }
 end
 
+def substitute_navigation(html, xmldir)
+    if xmldir.parent.name == 'dir'
+        nav = ''
+        path = '..'
+        parent = xmldir.parent
+        while parent.name == 'dir'
+            parentcaption = parent.attributes['subdirs-caption'] || File.basename(parent.attributes['path'])
+            nav = "<a href=\"#{path}/index.html\">#{parentcaption}</a> #{utf8(_(" > "))} #{nav}"
+            path += '/..'
+            parent = parent.parent
+        end
+        html.gsub!(/~~ifnavigation\?~~(.+?)~~fi~~/) { $1 }
+        html.gsub!(/~~navigation~~/, nav + (xmldir.attributes['subdirs-caption'] || File.basename(xmldir.attributes['path'])))
+    else
+        html.gsub!(/~~ifnavigation\?~~(.+?)~~fi~~/, '')
+    end
+end
+
 def xmldir2destdir(xmldir)
     return make_dest_filename(from_utf8(File.basename(xmldir.attributes['path'])))
 end
@@ -1010,6 +1028,7 @@ def walk_source_dir
                     i.gsub!(/~~current_size_js~~/, size2js(sizeobj['name']))
                     i.gsub!(/~~madewith~~/, $madewith || '')
                     i.gsub!(/~~indexlink~~/, $indexlink || '')
+                    substitute_navigation(i, xmldir)
                 end
                 html_nojs = html.collect { |l| l.clone }
                 pagecount = 0
@@ -1088,6 +1107,7 @@ def walk_source_dir
                         i.gsub!(/~~madewith~~/, $madewith || '')
                         i.gsub!(/~~indexlink~~/, $indexlink || '')
                         substitute_html_sizes(i, sizeobj, 'image', '')
+                        substitute_navigation(i, xmldir)
                     end
                     ios = File.open("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html", "w")
                     ios.write(html)
@@ -1171,21 +1191,7 @@ def walk_source_dir
             for i in html
                 caption = xmldir.attributes['subdirs-caption']
                 i.gsub!(/~~title~~/, caption)
-                if xmldir.parent.name == 'dir'
-                    nav = ''
-                    path = '..'
-                    parent = xmldir.parent
-                    while parent.name == 'dir'
-                        parentcaption = parent.attributes['subdirs-caption']
-                        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
+                substitute_navigation(i, xmldir)
                 discover_iterations(iterations, i)
             end