return name.gsub(/-/, '')
end
-def substitute_html_sizes(html, sizeobj, type)
+def substitute_html_sizes(html, sizeobj, type, suffix)
sizestrings = []
if $images_size.length > 1 || (type == 'image' && $limit_sizes =~ /original/)
for sizeobj2 in $images_size
if sizeobj != sizeobj2
if type == 'thumbnails'
- sizestrings << '<a href="thumbnails-' + size2js(sizeobj2['name']) + '.html">' + sizename(sizeobj2['name']) + '</a>'
+ sizestrings << '<a href="thumbnails-' + size2js(sizeobj2['name']) + suffix + '.html">' + sizename(sizeobj2['name']) + '</a>'
else
sizestrings << '<a id="link' + size2js(sizeobj2['name']) + '">' + sizename(sizeobj2['name']) + '</a>'
end
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)))
- substitute_html_sizes(i, sizeobj, 'thumbnails')
discover_iterations(iterations, i)
end
html_thumbnails = ''
+ html_thumbnails_nojs = ''
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)
- html_thumbnails += run_iterations(iterations, pano)
- html_thumbnails.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
+ html_elem = run_iterations(iterations, pano)
+ html_elem.gsub!(/~~colspan~~/) { 'colspan="' + pano.ceil.to_s + '"' }
else
- html_thumbnails += run_iterations(iterations, 1)
- html_thumbnails.gsub!(/~~colspan~~/, '')
+ html_elem = run_iterations(iterations, 1)
+ html_elem.gsub!(/~~colspan~~/, '')
end
else
- html_thumbnails += run_iterations(iterations, 1)
- html_thumbnails.gsub!(/~~colspan~~/, '')
+ html_elem = run_iterations(iterations, 1)
+ html_elem.gsub!(/~~colspan~~/, '')
end
if type == 'image'
index = images.index(file)
- html_thumbnails.gsub!(/~~image_iteration~~/,
- '<a href="image-' + size2js(sizeobj['name']) + '.html#current=' + fullscreen_images[sizeobj['name']][index] +
- '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
- img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
- html_thumbnails.gsub!(/~~caption_iteration~~/,
- find_caption_value(xmldir, images[index]) || utf8(images[index]))
- html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/) { $1 }
- html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/, '')
+ html_elem.gsub!(/~~caption_iteration~~/,
+ find_caption_value(xmldir, images[index]) || utf8(images[index]))
+ html_elem.gsub!(/~~ifimage\?~~(.+?)~~fi~~/) { $1 }
+ html_elem.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/, '')
elsif type == 'video'
index = videos.index(file)
if File.exists?("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}")
- html_thumbnails.gsub!(/~~image_iteration~~/,
- '<a href="' + videos[index] + '">' + img_element("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}") + '</a>')
+ html_elem.gsub!(/~~image_iteration~~/,
+ '<a href="' + videos[index] + '">' + img_element("#{dest_dir}/#{thumbnail_videos[sizeobj['name']][index]}") + '</a>')
else
- html_thumbnails.gsub!(/~~image_iteration~~/,
- '<a href="' + videos[index] + '">' + utf8(_("(no preview)")) + '</a>')
+ html_elem.gsub!(/~~image_iteration~~/,
+ '<a href="' + videos[index] + '">' + utf8(_("(no preview)")) + '</a>')
end
- html_thumbnails.gsub!(/~~caption_iteration~~/,
- find_caption_value(xmldir, videos[index]) || utf8(videos[index]))
- html_thumbnails.gsub!(/~~ifimage\?~~(.+?)~~fi~~/, '')
- html_thumbnails.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/) { $1 }
+ html_elem.gsub!(/~~caption_iteration~~/, find_caption_value(xmldir, videos[index]) || utf8(videos[index]))
+ html_elem.gsub!(/~~ifimage\?~~(.+?)~~fi~~/, '')
+ html_elem.gsub!(/~~ifvideo\?~~(.+?)~~fi~~/) { $1 }
+ end
+ html_thumbnails += html_elem
+ html_thumbnails_nojs += html_elem
+ if type == 'image'
+ html_thumbnails.gsub!(/~~image_iteration~~/,
+ '<a href="image-' + size2js(sizeobj['name']) + '.html#current=' + fullscreen_images[sizeobj['name']][index] +
+ '" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
+ img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
+ 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>')
end
end
end
- html_thumbnails += close_iterations(iterations)
+ html_thumbnails += close_iterations(iterations)
+ html_thumbnails_nojs += close_iterations(iterations)
for i in html
- i.sub!(/~~thumbnails~~/, html_thumbnails)
i.gsub!(/~~theme~~/, $theme)
i.gsub!(/~~current_size~~/, sizeobj['name'])
i.gsub!(/~~current_size_js~~/, size2js(sizeobj['name']))
i.gsub!(/~~madewith~~/, $madewith || '')
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')
+ end
+ ios = File.open("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}-nojs.html", "w")
+ ios.write(html_nojs)
+ ios.close
end
info("finished processing sizes")
i.gsub!(/~~current_size~~/, size2js(sizeobj['name']))
i.gsub!(/~~madewith~~/, $madewith || '')
i.gsub!(/~~indexlink~~/, $indexlink || '')
- substitute_html_sizes(i, sizeobj, 'image')
+ substitute_html_sizes(i, sizeobj, 'image', '')
end
ios = File.open("#{dest_dir}/image-#{size2js(sizeobj['name'])}.html", "w")
ios.write(html)
#- substitute "return to albums" and previous/next correctly
if xmldir.child_byname_notattr('image', 'deleted') || xmldir.child_byname_notattr('video', 'deleted')
- for sizeobj in $images_size
- substInFile("#{dest_dir}/thumbnails-#{size2js(sizeobj['name'])}.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>')
+ 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
- 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 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