tooltips.set_tip(optimize432, utf8(_("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)")), nil)
vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
+ nperpage_model = Gtk::ListStore.new(String, String)
+ vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per page: "))), false, false, 0).
+ pack_start(nperpagecombo = Gtk::ComboBox.new(nperpage_model), false, false, 0))
+ nperpagecombo.pack_start(crt = Gtk::CellRendererText.new, false)
+ nperpagecombo.set_attributes(crt, { :markup => 0 })
+ iter = nperpage_model.append
+ iter[0] = utf8(_("<i>None - all thumbnails in one page</i>"))
+ iter[1] = nil
+ [ 12, 20, 30, 40, 50 ].each { |v|
+ iter = nperpage_model.append
+ iter[0] = iter[1] = v.to_s
+ }
+ nperpagecombo.active = 0
vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("'Return to your website' link on pages bottom: "))), false, false, 0).
pack_start(indexlinkentry = Gtk::Entry.new, true, true, 0))
tooltips.set_tip(indexlinkentry, utf8(_("Optional HTML markup to use on pages bottom for a small link returning to wherever you see fit in your website (or somewhere else)")), nil)
dialog.vbox.add(frame1)
dialog.vbox.add(frame2)
- dialog.window_position = Gtk::Window::POS_MOUSE
dialog.show_all
keepon = true
theme = theme_button.label
sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }.join(',')
nperrow = nperrows.find { |e| e[:widget].active? }[:value]
+ nperpage = nperpage_model.get_value(nperpagecombo.active_iter, 1)
opt432 = optimize432.active?
madewith = madewithentry.text
indexlink = indexlinkentry.text
if ok
call_backend("booh-backend --source '#{srcdir}' --destination '#{destdir}' --config-skel '#{configskel}' --for-gui " +
"--verbose-level #{$verbose_level} --theme #{theme} --sizes #{sizes} --thumbnails-per-row #{nperrow} " +
+ (nperpage ? "--thumbnails-per-page #{nperpage} " : '') +
"#{opt432 ? '--optimize-for-32' : ''} --made-with '#{madewith}' --index-link '#{indexlink}' #{additional_booh_options}",
utf8(_("Please wait while scanning source directory...")),
'full scan',
theme = $xmldoc.root.attributes['theme']
opt432 = !$xmldoc.root.attributes['optimize-for-32'].nil?
nperrow = $xmldoc.root.attributes['thumbnails-per-row']
+ nperpage = $xmldoc.root.attributes['thumbnails-per-page']
limit_sizes = $xmldoc.root.attributes['limit-sizes']
if limit_sizes
limit_sizes = limit_sizes.split(/,/)
tooltips.set_tip(optimize432, utf8(_("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)")), nil)
vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per row: "))), false, false, 0).
pack_start(nperrowradios = Gtk::HBox.new, false, false, 0))
+ nperpage_model = Gtk::ListStore.new(String, String)
+ vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("Number of thumbnails per page: "))), false, false, 0).
+ pack_start(nperpagecombo = Gtk::ComboBox.new(nperpage_model), false, false, 0))
+ nperpagecombo.pack_start(crt = Gtk::CellRendererText.new, false)
+ nperpagecombo.set_attributes(crt, { :markup => 0 })
+ iter = nperpage_model.append
+ iter[0] = utf8(_("<i>None - all thumbnails in one page</i>"))
+ iter[1] = nil
+ [ 12, 20, 30, 40, 50 ].each { |v|
+ iter = nperpage_model.append
+ iter[0] = iter[1] = v.to_s
+ if nperpage && nperpage == v.to_s
+ nperpagecombo.active_iter = iter
+ end
+ }
+ if nperpagecombo.active_iter.nil?
+ nperpagecombo.active = 0
+ end
vb.add(Gtk::HBox.new(false, 3).pack_start(Gtk::Label.new(utf8(_("'Return to your website' link on pages bottom: "))), false, false, 0).
pack_start(indexlinkentry = Gtk::Entry.new, true, true, 0))
dialog.vbox.add(frame1)
dialog.vbox.add(frame2)
- dialog.window_position = Gtk::Window::POS_MOUSE
dialog.show_all
keepon = true
save_limit_sizes = theme_sizes.find_all { |e| e[:widget].active? }.collect { |e| e[:value] }
save_opt432 = optimize432.active?
save_nperrow = nperrows.find { |e| e[:widget].active? }[:value]
+ save_nperpage = nperpage_model.get_value(nperpagecombo.active_iter, 1)
save_madewith = madewithentry.text
save_indexlink = indexlinkentry.text
dialog.destroy
- if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432 || save_nperrow != nperrow || save_madewith != madewith || save_indexlink != indexlinkentry)
+ if ok && (save_theme != theme || save_limit_sizes != limit_sizes || save_opt432 != opt432 || save_nperrow != nperrow || save_nperpage != nperpage || save_madewith != madewith || save_indexlink != indexlinkentry)
mark_document_as_dirty
save_current_file
call_backend("booh-backend --use-config '#{$filename}' --for-gui --verbose-level #{$verbose_level} " +
"--thumbnails-per-row #{save_nperrow} --theme #{save_theme} --sizes #{save_limit_sizes.join(',')} " +
+ (save_nperpage ? "--thumbnails-per-page #{save_nperpage} " : '') +
"#{save_opt432 ? '--optimize-for-32' : ''} --made-with '#{save_madewith}' --index-link '#{save_indexlink}' #{additional_booh_options}",
utf8(_("Please wait while scanning source directory...")),
'full scan',
[ '--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)") ],
+ [ '--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 pictures from non digital cameras are 3/2 when pictures from digital cameras are 4/3)") ],
[ '--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)") ],
[ '--made-with', '-n', GetoptLong::REQUIRED_ARGUMENT, _("Specify the HTML markup to use on the bottom of pages for a small 'made with' message") ],
when '--thumbnails-per-row'
$N_per_row = arg
+ when '--thumbnails-per-page'
+ $N_per_page = arg
+
when '--optimize-for-32'
$optimize_for_32 = true
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']
+ $N_per_page = $xmldoc.root.attributes['thumbnails-per-page']
$madewith = $xmldoc.root.attributes['made-with']
$indexlink = $xmldoc.root.attributes['index-link']
end
if $N_per_row
additional_params += " thumbnails-per-row='#{$N_per_row}'"
end
+ if $N_per_page
+ additional_params += " thumbnails-per-page='#{$N_per_page}'"
+ end
if $madewith
additional_params += " made-with='#{$madewith}'"
end
else
$xmldoc.root.delete_attribute('thumbnails-per-row')
end
+ if $N_per_page
+ $xmldoc.root.add_attribute('thumbnails-per-page', $N_per_page)
+ else
+ $xmldoc.root.delete_attribute('thumbnails-per-page')
+ end
if $madewith
$xmldoc.root.add_attribute('made-with', $madewith)
else
html_reload_to_thumbnails.gsub!(/~~all_sizes~~/, all_images_sizes.collect { |s| "\"#{size2js(s['name'])}\"" }.join(', '))
size_auto_chooser = '';
all_images_sizes.sort { |a,b| b['optimizedforwidth'].to_i <=> a['optimizedforwidth'].to_i }.
- each { |s| size_auto_chooser += "if (w + 50 > #{s['optimizedforwidth']}) { return 'thumbnails-#{size2js(s['name'])}.html'; }\n" }
+ each { |s| size_auto_chooser += "if (w + 50 > #{s['optimizedforwidth']}) { return 'thumbnails-#{size2js(s['name'])}-1.html'; }\n" }
html_reload_to_thumbnails.gsub!(/~~size_auto_chooser~~/, size_auto_chooser)
return html_reload_to_thumbnails
end
}
msg 3, _("\tgenerating HTML pages...")
+ #- fixup max per page
+ if $N_per_page && $N_per_row
+ $N_per_page = $N_per_page.to_i / $N_per_row.to_i * $N_per_row.to_i
+ end
- #- generate thumbnails.html (page with thumbnails)
+ #- generate thumbnails*.html (page with thumbnails)
+ image2thumbnailpage4js = []
for sizeobj in $images_size
info("processing size")
html = $html_thumbnails.collect { |l| l.clone }
iterations = {}
for i in html
- i.sub!(/~~run_slideshow~~/, images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html#run_slideshow=1">' + utf8(_('Run slideshow!'))+'</a>')
- i.sub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
+ i.sub!(/~~run_slideshow~~/,
+ images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html#run_slideshow=1">' + utf8(_('Run slideshow!'))+'</a>')
+ i.sub!(/~~title~~/,
+ xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
discover_iterations(iterations, i)
end
+ all_pages = []
html_thumbnails = ''
html_thumbnails_nojs = ''
+ counter = 0
+ pagecount = 0
reset_iterations(iterations)
for file in entries
type = images.include?(file) ? 'image' : videos.include?(file) ? 'video' : nil
if type
if type == 'image' && elem = xmldir.elements["image[@filename='#{utf8(file)}']"]
- if pano = pano_amount(elem)
+ if pano = pano_amount(elem)
html_elem = run_iterations(iterations, pano)
- html_elem.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
+ counter += count = pano.ceil
+ html_elem.gsub!(/~~colspan~~/) { "colspan=\"#{count}\"" }
else
html_elem = run_iterations(iterations, 1)
+ counter += 1
html_elem.gsub!(/~~colspan~~/, '')
end
else
html_elem = run_iterations(iterations, 1)
+ counter += 1
html_elem.gsub!(/~~colspan~~/, '')
end
if type == 'image'
html_thumbnails_nojs.gsub!(/~~image_iteration~~/,
'<a href="' + fullscreen_images[sizeobj['name']][index] + '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
+ #- remember in which thumbnails page is this element, for image->thumbnail link
+ if sizeobj == $images_size[0]
+ image2thumbnailpage4js << pagecount
+ end
+ end
+
+ if counter == $N_per_page
+ html_thumbnails += close_iterations(iterations)
+ html_thumbnails_nojs += close_iterations(iterations)
+ all_pages << [ html_thumbnails, html_thumbnails_nojs ]
+ html_thumbnails = ''
+ html_thumbnails_nojs = ''
+ counter = 0
+ reset_iterations(iterations)
+ pagecount += 1
end
end
end
- html_thumbnails += close_iterations(iterations)
- html_thumbnails_nojs += close_iterations(iterations)
+ if counter > 0
+ html_thumbnails += close_iterations(iterations)
+ html_thumbnails_nojs += close_iterations(iterations)
+ all_pages << [ html_thumbnails, html_thumbnails_nojs ]
+ end
for i in html
i.gsub!(/~~theme~~/, $theme)
i.gsub!(/~~current_size~~/, sizeobj['name'])
i.gsub!(/~~indexlink~~/, $indexlink || '')
end
html_nojs = html.collect { |l| l.clone }
- for i in html
- i.sub!(/~~thumbnails~~/, html_thumbnails)
- substitute_html_sizes(i, sizeobj, 'thumbnails', '')
- end
- ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}.html", "w")
- ios.write(html)
- ios.close
- for i in html_nojs
- i.sub!(/~~thumbnails~~/, html_thumbnails_nojs)
- substitute_html_sizes(i, sizeobj, 'thumbnails', '-nojs')
+ pagecount = 0
+ for page in all_pages
+ html_thumbnails, html_thumbnails_nojs = page
+ final_html = html.collect { |l| l.clone }
+ mstuff = utf8(_("Pages: %s") % (pagecount > 0 ? "<a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{pagecount - 1}.html\">" + _("<- Previous") + "</a> " : '') +
+ all_pages.collect_with_index { |p,idx| page == p ? idx + 1 : "<a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{idx}.html\">#{idx + 1}</a>" }.join(', ') +
+ (pagecount < all_pages.size - 1 ? " <a href=\"thumbnails-#{size2js(sizeobj['name'])}-#{pagecount + 1}.html\">" + _("Next ->") + "</a> " : ''))
+ for i in final_html
+ if all_pages.size == 1
+ i.gsub!(/~~ifmultiplepages\?~~.*~~fi~~/, '')
+ else
+ i.gsub!(/~~ifmultiplepages\?~~(.+?)~~fi~~/) { $1 }
+ i.gsub!(/~~multiplepagesstuff~~/, mstuff)
+ end
+ i.sub!(/~~thumbnails~~/, html_thumbnails)
+ substitute_html_sizes(i, sizeobj, 'thumbnails', '')
+ end
+ ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-#{pagecount}.html", "w")
+ ios.write(final_html)
+ ios.close
+ final_html_nojs = html_nojs.collect { |l| l.clone }
+ for i in final_html_nojs
+ i.sub!(/~~thumbnails~~/, html_thumbnails_nojs)
+ substitute_html_sizes(i, sizeobj, 'thumbnails', '-nojs')
+ end
+ ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs-#{pagecount}.html", "w")
+ ios.write(final_html_nojs)
+ ios.close
+ pagecount += 1
end
- ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs.html", "w")
- ios.write(html_nojs)
- ios.close
end
info("finished processing sizes")
#- generate image.html (page with fullscreen images)
if images.size > 0
captions4js = find_captions(xmldir, images).collect { |e| e ? '"' + e.gsub('"', '\"') + '"' : '""' }.join(', ')
+ thumbnailspage4js = image2thumbnailpage4js.collect { |e| "\"#{e}\"" }.join(', ')
for sizeobj in $images_size
html = $html_images.collect { |l| l.clone }
for i in html
i.gsub!(/~~images~~/, images4js)
i.gsub!(/~~other_images~~/, otherimages4js)
+ i.gsub!(/~~thumbnailspages~~/, thumbnailspage4js)
i.gsub!(/~~other_sizes~~/, othersizes.join(', '))
i.gsub!(/~~captions~~/, captions4js)
i.gsub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
ios.write(html)
ios.close
- #- substitute "return to albums" and previous/next correctly
+ #- substitute multiple "return to albums", previous/next correctly
if xmldir.child_byname_notattr('image', 'deleted') || xmldir.child_byname_notattr('video', 'deleted')
for suffix in [ '', '-nojs' ]
for sizeobj in $images_size
- substInFile("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}#{suffix}.html") { |line|
- sub_previous_next_album(previous_album, next_album, line)
- if xmldir.elements['dir']
- line.sub!(/~~return_to_albums~~/, '<a href="index.html">' + utf8(_('return to albums')) + '</a>')
- else
- if xmldir.parent.name == 'dir'
- line.sub!(/~~return_to_albums~~/, '<a href="../index.html">' + utf8(_('return to albums')) + '</a>')
+ Dir.glob("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}#{suffix}-*.html") do |file|
+ substInFile(file) { |line|
+ sub_previous_next_album(previous_album, next_album, line)
+ if xmldir.elements['dir']
+ line.sub!(/~~return_to_albums~~/, '<a href="index.html">' + utf8(_('return to albums')) + '</a>')
else
- line.sub!(/~~return_to_albums~~/, '')
+ if xmldir.parent.name == 'dir'
+ line.sub!(/~~return_to_albums~~/, '<a href="../index.html">' + utf8(_('return to albums')) + '</a>')
+ else
+ line.sub!(/~~return_to_albums~~/, '')
+ end
end
- end
- line
- }
- if suffix == '' && xmldir.child_byname_notattr('image', 'deleted')
- substInFile("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html") { |line|
- sub_previous_next_album(previous_album, next_album, line)
+ line
}
+ if suffix == '' && xmldir.child_byname_notattr('image', 'deleted')
+ substInFile("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html") { |line|
+ sub_previous_next_album(previous_album, next_album, line)
+ }
+ end
end
end
end