begin
contents = eval "$#{keyword}"
line.sub!(/#{surround}#{keyword}#{surround}/, contents)
- rescue NameError
+ rescue TypeError
die _("No `%s' found for substitution") % keyword
end
end
end
end
-def html_refresh(target)
- return "<html><head><META http-equiv='refresh' content='0;URL=#{target}'></head><body></body></html>"
+def html_reload_to_thumbnails
+ html_reload_to_thumbnails = $preferred_size_reloader.clone
+ html_reload_to_thumbnails.gsub!(/~~theme~~/, $theme)
+ html_reload_to_thumbnails.gsub!(/~~default_size~~/, $default_size['name'])
+ return html_reload_to_thumbnails
end
def discover_iterations(iterations, line)
type = images.include?(file) ? 'image' : videos.include?(file) ? 'video' : nil
if type
html_thumbnails += run_iterations(iterations)
+ html_thumbnails.gsub!(/~~theme~~/, $theme)
+ html_thumbnails.gsub!(/~~current_size~~/, sizeobj['name'])
if type == 'image'
index = images.index(file)
html_thumbnails.gsub!(/~~image_iteration~~/,
ios.close
end
+ #- generate "main" thumbnails.html page that will reload to correct size thanks to cookie
+ ios = File.open("#{dest_dir}/thumbnails.html", "w")
+ ios.write(html_reload_to_thumbnails)
+ ios.close
+
#- generate image.html (page with fullscreen images)
if images.size > 0
#- don't ask me why I need so many backslashes... the aim is to print \\\" for each " in the javascript source
i.sub!(/~~captions~~/, captions4js)
i.sub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
i.sub!(/~~thumbnails~~/, '<a href="thumbnails-' + sizeobj['name'] + '.html">' + utf8(_('Return to thumbnails')) + '</a>')
+ i.sub!(/~~theme~~/, $theme)
+ i.sub!(/~~current_size~~/, sizeobj['name'])
for sizeobj2 in $images_size
if sizeobj != sizeobj2
i.sub!(/~~size_#{sizeobj2['name']}~~/,
end
#- second pass to create index.html files
- default_thumbnails = $images_size.detect { |sizeobj| sizeobj['default'] }
- if !default_thumbnails
- die _("Theme `%s' has no default size.") % $theme
- else
- default_thumbnails = default_thumbnails['name']
- end
-
msg 3, _("\trescanning directories to generate all `index.html' files...")
`find #{$source} -type d`.each { |dir|
gen_thumbnails_subdir(from_utf8(xmldir.attributes['thumbnails-captionfile']), xmldir, false,
[ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ], 'thumbnails')
html_index += run_iterations(iterations)
- html_index.gsub!(/~~image_iteration~~/, "<a href='thumbnails-#{default_thumbnails}.html'>" + img_element(thumbnail) + '</a>')
+ html_index.gsub!(/~~image_iteration~~/, "<a href='thumbnails.html'>" + img_element(thumbnail) + '</a>')
html_index.gsub!(/~~caption_iteration~~/, xmldir.attributes['thumbnails-caption'])
end
#- cleanup temp for videos
end
else
- html = html_refresh("thumbnails-#{default_thumbnails}.html")
+ html = html_reload_to_thumbnails
end
ios = File.open("#{dest_dir}/index.html", "w")
require 'booh/booh-lib'
include Booh
-$head_code = <<'EOF'
+$image_head_code = <<'EOF'
<meta name="generator" content="Generated by Booh! http://zarb.org/~gc/html/booh.html">
<script language="JavaScript1.1" type="text/JavaScript">
}
function init() {
-
+
/* retrieve GET parameters */
all_params = location.href.split("?")
if (all_params.length > 1) {
</script>
EOF
-$head_code.sub!('~~run_slideshow~~', utf8(_('Run slideshow!')))
-$head_code.sub!('~~stop_slideshow~~', utf8(_('Stop slideshow')))
+$image_head_code.sub!('~~run_slideshow~~', utf8(_('Run slideshow!')))
+$image_head_code.sub!('~~stop_slideshow~~', utf8(_('Stop slideshow')))
$body_additions = <<'EOF'
onload="init()" id="body"
$body_code = <<'EOF'
EOF
+
+$thumbnails_head_code = <<'EOF'
+<script language="JavaScript1.1" type="text/JavaScript">
+ var expires = new Date(new Date().getTime() + (30 * 86400000)); // 30 days
+ document.cookie = 'booh-preferred-size-~~theme~~=~~current_size~~'
+ + '; expires=' + expires.toGMTString()
+ + '; path=/';
+</script>
+EOF
+
+
+$preferred_size_reloader = <<'EOF'
+<html>
+ <head>
+ <script language="JavaScript1.1" type="text/JavaScript">
+
+function getPreferredSize() {
+ if (document.cookie) {
+ var index = document.cookie.indexOf('booh-preferred-size-~~theme~~');
+ if (index != -1) {
+ var oleft = (document.cookie.indexOf('=', index) + 1);
+ var oright = document.cookie.indexOf(';', index);
+ if (oright == -1) {
+ oright = document.cookie.length;
+ }
+ return 'thumbnails-' + document.cookie.substring(oleft, oright) + '.html';
+ }
+ }
+ return 'thumbnails-~~default_size~~.html';
+}
+
+window.location.href = getPreferredSize();
+
+ </script>
+ </head>
+</html>
+EOF