Creates a photo gallery from a folder full of images, somewhat per this request: http://www.idiotking.org/archives/2012/05/exercise-in-futility/
# save as "Rakefile" in desired directory
# cd to directory and type "rake"
task :default => 'make_html'
desc "Turns a directory of images into linked HTML"
task :make_html do
extensions = "png,PNG,jpg,JPG,gif"
working_dir =File.dirname(__FILE__)
pictures = Dir.glob("#{working_dir}/*.{#{extensions}}")
puts "converting pictures in #{working_dir}"
pictures.each_with_index do |img_name, index|
current_file = "index#{index == 0 ? nil : index}.html"
next_index = (index + 1) % pictures.size
next_file = "index#{next_index == 0 ? nil : next_index}.html"
File.open("#{working_dir}/#{current_file}", "w").write <<-EOF
<html>
<a href="#{next_file}"><img src="#{img_name}" /></a>
</html>
EOF
end
sh "cd '#{working_dir}'; open index.html"
end