add possibility to display "made with" markup at the bottom of pages
[booh] / bin / booh-backend
index 6dacc456165314bb92b761f5086570888213b315..874ae5fe40160c97c5d4991978705ad59a59b04f 100755 (executable)
@@ -53,6 +53,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)") ],
     [ '--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)") ],
+    [ '--made-with',     '-n', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages") ],
     [ '--empty-comments','-e', GetoptLong::NO_ARGUMENT,       _("Prefer empty comments over filename when creating new albums") ],
 
     [ '--mproc',         '-m', GetoptLong::REQUIRED_ARGUMENT, _("Specify the number of processors for multi-processors machines") ],
@@ -195,6 +196,9 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
             when '--optimize-for-32'
                 $optimize_for_32 = true
 
+            when '--made-with'
+                $madewith = arg
+
             when '--empty-comments'
                 $empty_comments = true
 
@@ -230,6 +234,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']
+            $madewith = $xmldoc.root.attributes['made-with']
         end
     end
 
@@ -264,6 +269,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 $madewith
+            additional_params += " made-with='#{$madewith}'"
+        end
         $xmldoc = Document.new "<booh version='#{$VERSION}' source='#{utf8($source)}' destination='#{utf8($dest)}' theme='#{$theme}' #{additional_params}/>"
         $xmldoc << XMLDecl.new(XMLDecl::DEFAULT_VERSION, $CURRENT_CHARSET)
         $mode = 'gen_config'
@@ -287,6 +295,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
         else
             $xmldoc.root.delete_attribute('thumbnails-per-row')
         end
+        if $madewith
+            $xmldoc.root.add_attribute('made-with', $madewith)
+        else
+            $xmldoc.root.delete_attribute('made-with')
+        end
+    end
+
+    if $madewith
+        $madewith = $madewith.gsub('%booh', 'http://zarb.org/~gc/html/booh.html')
     end
 end
 
@@ -785,6 +802,7 @@ def walk_source_dir
                      concat(videos)
             to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?("#{dest_dir}/#{e}") && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } - themestuff
             if to_del.size > 0
+                msg 3, _("\tcleaning up: #{to_del.join(', ')}")
                 system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' '))
             end
 
@@ -797,6 +815,7 @@ def walk_source_dir
 
             #- generate .htaccess file if needed
             if auth_user_file = xmldir.attributes['password-protect']
+                msg 3, _("\tgenerating password protection file #{dest_dir}/.htaccess")
                 ios = File.open("#{dest_dir}/.htaccess", "w")
                 ios.write("AuthType Basic\nAuthName \"protected area\"\nAuthUserFile #{auth_user_file}\nrequire valid-user\n")
                 ios.close
@@ -864,6 +883,7 @@ def walk_source_dir
                     i.gsub!(/~~theme~~/, $theme)
                     i.gsub!(/~~current_size~~/, sizeobj['name'])
                     i.gsub!(/~~current_size_js~~/, size2js(sizeobj['name']))
+                    i.gsub!(/~~madewith~~/, $madewith || '')
                 end
                 ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}.html", "w")
                 ios.write(html)
@@ -901,6 +921,7 @@ def walk_source_dir
                         i.gsub!(/~~thumbnails~~/, '<a href="thumbnails-' + size2js(sizeobj['name']) + '.html" id="thumbnails">' + utf8(_('return to thumbnails')) + '</a>')
                         i.gsub!(/~~theme~~/, $theme)
                         i.gsub!(/~~current_size~~/, size2js(sizeobj['name']))
+                        i.gsub!(/~~madewith~~/, $madewith || '')
                         substitute_html_sizes(i, sizeobj, 'image')
                     end
                     ios = File.open("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html", "w")
@@ -1036,6 +1057,7 @@ def walk_source_dir
 
             for i in html
                 i.gsub!(/~~thumbnails~~/, html_index)
+                i.gsub!(/~~madewith~~/, $madewith || '')
             end
             
         else