Permalink
Browse files

Merge branch 'master' into templating

Conflicts:
	lib/showoff.rb
  • Loading branch information...
2 parents fbb96ab + 0657b2d commit 842c00b8464370d57d7b40c1206b956207d87375 @grundprinzip committed Nov 21, 2011
Showing with 35 additions and 43 deletions.
  1. +1 −6 Gemfile
  2. +2 −1 bin/showoff
  3. +26 −29 lib/showoff.rb
  4. +3 −1 lib/showoff_utils.rb
  5. +3 −3 showoff.gemspec
  6. +0 −3 test/utils_test.rb
View
@@ -1,11 +1,6 @@
source :rubygems
-gem "sinatra"
-gem "bluecloth"
-gem "nokogiri"
-gem "json"
-gem "gli",">= 1.2.5"
-gem "parslet"
+gemspec
group :development do
gem "mg"
View
@@ -2,12 +2,13 @@
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'showoff'
+require 'showoff/version'
require 'rubygems'
require 'gli'
include GLI
-version ShowOff::Version
+version SHOWOFF_VERSION
desc 'Create new showoff presentation'
arg_name 'dir_name'
View
@@ -21,13 +21,7 @@
$stderr.puts 'pdf generation disabled - install pdfkit'
end
-begin
- require 'rdiscount'
-rescue LoadError
- require 'bluecloth'
- Object.send(:remove_const,:Markdown)
- Markdown = BlueCloth
-end
+require 'tilt'
class ShowOff < Sinatra::Application
@@ -47,18 +41,18 @@ 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
# Load configuration for page size and template from the
@@ -76,9 +70,12 @@ def initialize(app=nil)
@logger.debug options.pres_template
@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
+
+ # Default asset path
+ @asset_path = "./"
end
def self.pres_dir_current
@@ -87,12 +84,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
@@ -103,16 +100,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
@@ -211,7 +208,7 @@ def process_markdown(name, content, static=false, pdf=false)
else
content += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}\">\n"
end
- sl = Markdown.new(slide.text).to_html
+ sl = Tilt[:markdown].new { slide.text }.render
sl = update_image_paths(name, sl, static, pdf)
content += sl
content += "</div>\n"
@@ -260,7 +257,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="#{@asset_path}image/#{path})
slide.gsub(/img src=\"([^\/].*?)\"/) do |s|
img_path = File.join(path, $1)
@@ -339,7 +336,7 @@ def update_commandline_code(slide)
def get_slides_html(static=false, pdf=false)
@slide_count = 0
- sections = ShowOffUtils.showoff_sections(options.pres_dir, @logger)
+ sections = ShowOffUtils.showoff_sections(settings.pres_dir, @logger)
files = []
if sections
data = ''
@@ -353,7 +350,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
@@ -368,7 +365,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
@@ -382,7 +379,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
@@ -440,10 +437,10 @@ def assets_needed
assets << href if href
end
- css = Dir.glob("#{options.public_folder}/**/*.css").map { |path| path.gsub(options.public_folder + '/', '') }
+ css = Dir.glob("#{settings.public_folder}/**/*.css").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << css
- js = Dir.glob("#{options.public_folder}/**/*.js").map { |path| path.gsub(options.public_folder + '/', '') }
+ js = Dir.glob("#{settings.public_folder}/**/*.js").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << js
assets.uniq.join("\n")
@@ -527,7 +524,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|
@@ -569,7 +566,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
View
@@ -317,6 +317,8 @@ def self.get_config_option(dir, option, default = nil)
data[option] || default
end
end
+ else
+ default
end
end
@@ -332,7 +334,7 @@ def self.lang(source_file)
EXTENSIONS[ext] || ext
end
- REQUIRED_GEMS = %w(bluecloth nokogiri showoff gli heroku)
+ REQUIRED_GEMS = %w(redcarpet showoff heroku)
# Creates the file that lists the gems for heroku
#
View
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
s.files += Dir.glob("bin/**/*")
s.files += Dir.glob("views/**/*")
s.files += Dir.glob("public/**/*")
- s.add_dependency "sinatra"
- s.add_dependency "bluecloth"
+ s.add_dependency "sinatra", "~> 1.3"
+ s.add_dependency "redcarpet"
s.add_dependency "nokogiri"
s.add_dependency "json"
- s.add_dependency("gli",">= 1.3.2")
+ s.add_dependency "gli",">= 1.3.2"
s.add_dependency "parslet"
s.add_development_dependency "mg"
s.description = <<-desc
View
@@ -21,10 +21,7 @@
ShowOffUtils.heroku('test')
files = Dir.glob('**/*')
content = File.read('Gemfile')
- assert_match 'bluecloth', content
- assert_match 'nokogiri', content
assert_match 'showoff', content
- assert_match 'gli', content
assert_match 'heroku', content
end
assert files.include?('config.ru')

0 comments on commit 842c00b

Please sign in to comment.