X-Git-Url: http://git.zarb.org/?p=booh;a=blobdiff_plain;f=bin%2Fbooh-backend;h=12de9d81c206b89355dc6a1e3f9814b28c0c8c44;hp=f161ee8c65e326f1a2b11374ca7892a8771cdf8f;hb=4feaa778f5a4b9b8d4ea30473f84b45c7bb313b2;hpb=aa5966557701016a05a15b4b15f8fbc37d753432 diff --git a/bin/booh-backend b/bin/booh-backend index f161ee8..12de9d8 100644 --- a/bin/booh-backend +++ b/bin/booh-backend @@ -10,7 +10,7 @@ # called Boo, so this one will be it "Booh". Or whatever. # # -# Copyright (c) 2004-2011 Guillaume Cottenceau +# Copyright (c) 2004-2013 Guillaume Cottenceau # # This software may be freely redistributed under the terms of the GNU # public license version 2. @@ -34,7 +34,7 @@ rescue LoadError end require 'gettext' include GetText -require 'booh/rexml/document' +require 'rexml/document' include REXML require 'booh/booh-lib' @@ -69,7 +69,7 @@ $options = [ [ '--thumbnails-per-page', '-p', GetoptLong::REQUIRED_ARGUMENT, _("Specify the amount of thumbnails per page in the thumbnails page, after which split occurs") ], [ '--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 photos from point-and-shoot cameras - also called compact cameras - is 4/3, whereas photos from SLR cameras - also called reflex cameras - is 3/2)") ], [ '--transcode-videos', '-r', GetoptLong::REQUIRED_ARGUMENT, _("Transcode videos with given external program; %f is the placeholder for the input video, %o for the output video; before the external program, the output video extension should be given followed by a colon") ], - [ '--flv-generator', '-F', GetoptLong::REQUIRED_ARGUMENT, _("Use embedded flash player for videos (flowplayer) and use this .flv generator (%f is the placeholder for the input video, %o for the output video)") ], + [ '--mp4-generator', '-F', GetoptLong::REQUIRED_ARGUMENT, _("Use this .mp4 generator (%f is the placeholder for the input video, %o for the output video)") ], [ '--index-link', '-l', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages for a small link returning to wherever you see fit in your website (or somewhere else)") ], [ '--addthis', '-a', GetoptLong::NO_ARGUMENT, _("Include the 'addthis' bookmarking and sharing button") ], [ '--made-with', '-n', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages for a small 'made with' message") ], @@ -112,7 +112,7 @@ def handle_options when '--version' puts _("Booh version %s -Copyright (c) 2005-2011 Guillaume Cottenceau. +Copyright (c) 2005-2013 Guillaume Cottenceau. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") % $VERSION @@ -234,11 +234,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") % end $transcode_videos = arg - when '--flv-generator' + when '--mp4-generator' if arg !~ /%f/ || arg !~ /%o/ - die _("--flv-generator: argument must contain %f for the input video and %o for the output video") + die _("--mp4-generator: argument must contain %f for the input video and %o for the output video") end - $flv_generator = arg + $mp4_generator = arg when '--made-with' $madewith = arg @@ -315,7 +315,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") % die _("Missing --destination parameter.") end if !$theme - $theme = 'simple' + $theme = 'gradient' end select_theme($theme, $limit_sizes, $optimize_for_32, $N_per_row) @@ -414,10 +414,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") % $xmldoc.root.delete_attribute('transcode-videos') end - if $flv_generator - $xmldoc.root.add_attribute('flv-generator', $flv_generator) + if $mp4_generator + $xmldoc.root.add_attribute('mp4-generator', $mp4_generator) else - $xmldoc.root.delete_attribute('flv-generator') + $xmldoc.root.delete_attribute('mp4-generator') end if $madewith @@ -1002,10 +1002,6 @@ def walk_source_dir psys("cp '#{$themedir}/root/#{entry}' '#{dest_dir}'") end } - #- copy flowplayer stuff if needed - if $flv_generator - psys("cp #{$FPATH}/flowplayer/flowplayer* '#{dest_dir}'") - end end end next @@ -1077,7 +1073,7 @@ def walk_source_dir videos.size >= 1 and msg 3, _("\tcreating videos thumbnails...") transcoded_videos = {} - flv_videos = {} + mp4_videos = {} #- create thumbnails for videos videos.each { |video| @@ -1110,16 +1106,18 @@ def walk_source_dir psys(parts[1].gsub(/%f/, "'#{dir}/#{video}'").gsub(/%o/, "'#{destvideo}'")) end - elsif $flv_generator - basedestvideo = video.sub(/\.\w+/, '') + '.flv' - flv_videos[video] = basedestvideo + elsif $mp4_generator + msg 3, "video1" + basedestvideo = video.sub(/\.\w+/, '') + '.mp4' + mp4_videos[video] = basedestvideo destvideo = "#{dest_dir}/#{basedestvideo}" if File.exists?(destvideo) && File.size(destvideo) == 0 File.delete(destvideo) end if ! File.exists?(destvideo) - psys($flv_generator.gsub(/%f/, "'#{dir}/#{video}'").gsub(/%o/, "'#{destvideo}'")) + psys($mp4_generator.gsub(/%f/, "'#{dir}/#{video}'").gsub(/%o/, "'#{destvideo}'")) end + msg 3, "video2" else destvideo = "#{dest_dir}/#{video}" @@ -1143,7 +1141,7 @@ def walk_source_dir concat(thumbnail_images.collect { |e| e[1] }.flatten). concat(fullscreen_videos.collect { |e| e[1] }.flatten). concat(thumbnail_videos.collect { |e| e[1] }.flatten). - concat($transcode_videos ? transcoded_videos.values : $flv_generator ? flv_videos.values : videos). + concat($transcode_videos ? transcoded_videos.values : $mp4_generator ? mp4_videos.values : videos). push('.htaccess') to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } if to_del.size > 0 @@ -1169,10 +1167,6 @@ def walk_source_dir psys("cp '#{$themedir}/root/#{entry}' '#{dest_dir}'") end } - #- copy flowplayer stuff if needed - if $flv_generator - psys("cp #{$FPATH}/flowplayer/flowplayer* '#{dest_dir}'") - end end msg 3, _("\tgenerating HTML pages...") @@ -1189,7 +1183,6 @@ def walk_source_dir iterations = {} for i in html i.sub!(/~~title~~/, quote_caption(xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))) - i.sub!(/~~flowplayer_head_code~~/, ($flv_generator && videos.size > 0) ? '' : '') discover_iterations(iterations, i) end all_pages = [] @@ -1238,17 +1231,16 @@ def walk_source_dir else video_preview = defer_translation(N_("(no preview)")) end - if $flv_generator + if $mp4_generator size = get_image_size("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}") if ! size sizeobj['thumbnails'] =~ /(\d+)x(\d+)/ size = { :x => $1, :y => $2 } end sizespec = 'width:' + size[:x].to_s + 'px;height:' + (size[:y] + 24).to_s + 'px' - image_iteration = '' + video_preview + - '' + - '' + '' html_elem.gsub!(/~~image_iteration~~/, apply_hook(:image_iteration, image_iteration, 'video')) else html_elem.gsub!(/~~image_iteration~~/, @@ -1371,8 +1363,8 @@ def walk_source_dir types4js << '"' + type + '"' if type == 'video' index = videos.index(file) - if $flv_generator - videos4js << '"' + flv_videos[videos[index]] + '"' + if $mp4_generator + videos4js << '"' + mp4_videos[videos[index]] + '"' else videos4js << '"' + videos[index] + '"' end @@ -1450,13 +1442,6 @@ def walk_source_dir i.gsub!(/~~other_sizes~~/, othersizes.join(', ')) i.gsub!(/~~captions~~/, captions4js.join(', ')) i.gsub!(/~~title~~/, quote_caption(xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))) - if $flv_generator && videos.size > 0 - i.sub!(/~~flowplayer_head_code~~/, '') - i.sub!(/~~flowplayer_active~~/, 'true') - else - i.sub!(/~~flowplayer_head_code~~/, '') - i.sub!(/~~flowplayer_active~~/, 'false') - end i.gsub!(/~~thumbnails~~/, '' + defer_translation(N_('return to thumbnails')) + '') i.gsub!(/~~theme~~/, $theme)