Skip to content

Commit

Permalink
'showoff serve' can take an argument to specify presentation directory
Browse files Browse the repository at this point in the history
  • Loading branch information
alexch committed Apr 28, 2011
1 parent dd14958 commit df9e678
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 5 additions & 1 deletion bin/showoff
Expand Up @@ -66,9 +66,13 @@ command :serve do |c|
c.desc 'Host or ip to run on'
c.default_value "localhost"
c.flag [:h,:host]

c.desc 'Presentation directory'
c.default_value "."
c.arg_name "pres_dir"

c.action do |global_options,options,args|
ShowOff.run! :host => options[:h], :port => options[:p].to_i
ShowOff.run! :host => options[:h], :port => options[:p].to_i, :pres_dir => args[0]
end
end

Expand Down
15 changes: 6 additions & 9 deletions lib/showoff.rb
Expand Up @@ -37,20 +37,20 @@ 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'
showoff_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
if Dir.pwd == showoff_dir
options.pres_dir = "#{showoff_dir}/example"
@root_path = "."
else
options.pres_dir = Dir.pwd
options.pres_dir ||= Dir.pwd
@root_path = ".."
end
options.pres_dir = File.expand_path(options.pres_dir)
puts "Serving presentation from #{options.pres_dir}"
@cached_image_size = {}
puts options.pres_dir
@pres_name = options.pres_dir.split('/').pop
require_ruby_files
end
Expand Down Expand Up @@ -107,9 +107,6 @@ def process_markdown(name, content, static=false, pdf=false)
# extract id, defaulting to none
id = nil
content_classes.delete_if { |x| x =~ /^#([\w-]+)/ && id = $1 }
puts "id: #{id}" if id
puts "classes: #{content_classes.inspect}"
puts "transition: #{transition}"
# create html
md += "<div"
md += " id=\"#{id}\"" if id
Expand Down

0 comments on commit df9e678

Please sign in to comment.