require 'optparse' require 'RedCloth' module Slideshow def Slideshow.create_slideshow( fn ) gradient = < EOS header = < Slideshow
EOS footer = < EOS basename = File.basename( fn, '.*' ) extname = File.extname( fn ) extname = ".textile" if extname.eql?("") inname = "#{basename}#{extname}" outname = "#{basename}.html" svgname = "#{basename}.svg" puts "Preparing slideshow theme '#{svgname}'..." out = File.new( svgname, "w+") out << gradient out.flush out.close puts "Preparing slideshow '#{outname}'..." content = '' slide_counter = 0 infile = File.new( inname ) infile.each { |line| if line.include?( 'h1.' ) then content << "\n\n" if slide_counter > 0 content << "
\n\n" slide_counter += 1 end content << line } content << "\n\n
" if slide_counter > 0 out = File.new( outname, "w+") out << header.gsub( '$svgname', svgname ) out << RedCloth.new( content ).to_html out << footer out.flush out.close puts "Done." end def Slideshow.main $options = {} opt=OptionParser.new do |opts| opts.banner = "Usage: slideshow [options] name" # opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s } opts.on_tail( "-h", "--help", "Show this message" ) { puts opts.help; exit } end opt.parse! ARGV.each { |fn| Slideshow.create_slideshow( fn ) } end end