require 'rubygems' require 'sinatra/base' require 'json' require 'nokogiri' require 'showoff_utils' require 'princely' begin require 'rdiscount' rescue LoadError require 'bluecloth' Markdown = BlueCloth end require 'pp' class ShowOff < Sinatra::Application set :views, File.dirname(__FILE__) + '/../views' set :public, File.dirname(__FILE__) + '/../public' set :pres_dir, 'example' def initialize(app=nil) super(app) puts dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) if Dir.pwd == dir options.pres_dir = dir + '/example' else options.pres_dir = Dir.pwd end puts options.pres_dir end helpers do def load_section_files(section) section = File.join(options.pres_dir, section) files = Dir.glob("#{section}/**/*").sort pp files files end def css_files Dir.glob("#{options.pres_dir}/*.css").map { |path| File.basename(path) } end def js_files Dir.glob("#{options.pres_dir}/*.js").map { |path| File.basename(path) } end def process_markdown(name, content) slides = content.split(/^!SLIDE/) slides.delete('') final = '' if slides.size > 1 seq = 1 end slides.each do |slide| md = '' # extract content classes lines = slide.split("\n") content_classes = lines.shift.split slide = lines.join("\n") # add content class too content_classes.unshift "content" # extract transition, defaulting to none transition = 'none' content_classes.delete_if { |x| x =~ /^transition=(.+)/ && transition = $1 } puts "classes: #{content_classes.inspect}" puts "transition: #{transition}" # create html md += "