Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#options and #public are deprecated, use #settings and #public_folder…

… instead
  • Loading branch information...
commit 5b8e1139260fa4b16fb0563770b3cee7739f981a 1 parent 4ddf2f4
@timfel timfel authored
Showing with 22 additions and 22 deletions.
  1. +22 −22 lib/showoff.rb
View
44 lib/showoff.rb
@@ -36,7 +36,7 @@ class ShowOff < Sinatra::Application
attr_reader :cached_image_size
set :views, File.dirname(__FILE__) + '/../views'
- set :public, File.dirname(__FILE__) + '/../public'
+ set :public_folder, File.dirname(__FILE__) + '/../public'
set :verbose, false
set :pres_dir, '.'
@@ -46,22 +46,22 @@ def initialize(app=nil)
super(app)
@logger = Logger.new(STDOUT)
@logger.formatter = proc { |severity,datetime,progname,msg| "#{progname} #{msg}\n" }
- @logger.level = options.verbose ? Logger::DEBUG : Logger::WARN
+ @logger.level = settings.verbose ? Logger::DEBUG : Logger::WARN
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
@logger.debug(dir)
showoff_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
- options.pres_dir ||= Dir.pwd
+ settings.pres_dir ||= Dir.pwd
@root_path = "."
- options.pres_dir = File.expand_path(options.pres_dir)
- if (options.pres_file)
- ShowOffUtils.presentation_config_file = options.pres_file
+ settings.pres_dir = File.expand_path(settings.pres_dir)
+ if (settings.pres_file)
+ ShowOffUtils.presentation_config_file = settings.pres_file
end
@cached_image_size = {}
- @logger.debug options.pres_dir
- @pres_name = options.pres_dir.split('/').pop
+ @logger.debug settings.pres_dir
+ @pres_name = settings.pres_dir.split('/').pop
require_ruby_files
end
@@ -71,12 +71,12 @@ def self.pres_dir_current
end
def require_ruby_files
- Dir.glob("#{options.pres_dir}/*.rb").map { |path| require path }
+ Dir.glob("#{settings.pres_dir}/*.rb").map { |path| require path }
end
helpers do
def load_section_files(section)
- section = File.join(options.pres_dir, section)
+ section = File.join(settings.pres_dir, section)
files = if File.directory? section
Dir.glob("#{section}/**/*").sort
else
@@ -87,16 +87,16 @@ def load_section_files(section)
end
def css_files
- Dir.glob("#{options.pres_dir}/*.css").map { |path| File.basename(path) }
+ Dir.glob("#{settings.pres_dir}/*.css").map { |path| File.basename(path) }
end
def js_files
- Dir.glob("#{options.pres_dir}/*.js").map { |path| File.basename(path) }
+ Dir.glob("#{settings.pres_dir}/*.js").map { |path| File.basename(path) }
end
def preshow_files
- Dir.glob("#{options.pres_dir}/_preshow/*").map { |path| File.basename(path) }.to_json
+ Dir.glob("#{settings.pres_dir}/_preshow/*").map { |path| File.basename(path) }.to_json
end
# todo: move more behavior into this class
@@ -187,7 +187,7 @@ def update_image_paths(path, slide, static=false, pdf=false)
paths.pop
path = paths.join('/')
replacement_prefix = static ?
- ( pdf ? %(img src="file://#{options.pres_dir}/#{path}) : %(img src="./file/#{path}) ) :
+ ( pdf ? %(img src="file://#{settings.pres_dir}/#{path}) : %(img src="./file/#{path}) ) :
%(img src="/image/#{path})
slide.gsub(/img src=\"([^\/].*?)\"/) do |s|
img_path = File.join(path, $1)
@@ -265,7 +265,7 @@ def update_commandline_code(slide)
end
def get_slides_html(static=false, pdf=false)
- sections = ShowOffUtils.showoff_sections(options.pres_dir, @logger)
+ sections = ShowOffUtils.showoff_sections(settings.pres_dir, @logger)
files = []
if sections
data = ''
@@ -279,7 +279,7 @@ def get_slides_html(static=false, pdf=false)
files = files.flatten
files = files.select { |f| f =~ /.md$/ }
files.each do |f|
- fname = f.gsub(options.pres_dir + '/', '').gsub('.md', '')
+ fname = f.gsub(settings.pres_dir + '/', '').gsub('.md', '')
data << process_markdown(fname, File.read(f), static, pdf)
end
end
@@ -294,7 +294,7 @@ def inline_css(csses, pre = nil)
if pre
css_file = File.join(File.dirname(__FILE__), '..', pre, css_file)
else
- css_file = File.join(options.pres_dir, css_file)
+ css_file = File.join(settings.pres_dir, css_file)
end
css_content += File.read(css_file)
end
@@ -308,7 +308,7 @@ def inline_js(jses, pre = nil)
if pre
js_file = File.join(File.dirname(__FILE__), '..', pre, js_file)
else
- js_file = File.join(options.pres_dir, js_file)
+ js_file = File.join(settings.pres_dir, js_file)
end
js_content += File.read(js_file)
end
@@ -361,10 +361,10 @@ def assets_needed
assets << href if href
end
- css = Dir.glob("#{options.public}/**/*.css").map { |path| path.gsub(options.public + '/', '') }
+ css = Dir.glob("#{settings.public_folder}/**/*.css").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << css
- js = Dir.glob("#{options.public}/**/*.js").map { |path| path.gsub(options.public + '/', '') }
+ js = Dir.glob("#{settings.public_folder}/**/*.js").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << js
assets.uniq.join("\n")
@@ -433,7 +433,7 @@ def self.do_static(what)
# Set up file dir
file_dir = File.join(out, 'file')
FileUtils.makedirs(file_dir)
- pres_dir = showoff.options.pres_dir
+ pres_dir = showoff.settings.pres_dir
# ..., copy all user-defined styles and javascript files
Dir.glob("#{pres_dir}/*.{css,js}").each { |path|
@@ -475,7 +475,7 @@ def eval_ruby code
get %r{(?:image|file)/(.*)} do
path = params[:captures].first
- full_path = File.join(options.pres_dir, path)
+ full_path = File.join(settings.pres_dir, path)
send_file full_path
end
Please sign in to comment.
Something went wrong with that request. Please try again.