Permalink
Browse files

Merge pull request #63 from badboy/showoff

Conflicts:
	bin/showoff
	lib/showoff.rb
  • Loading branch information...
schacon committed Dec 28, 2010
2 parents f3ed049 + 89d5994 commit 769bc24a17f179e27eb0ce454187fbe1673c6663
Showing with 24 additions and 7 deletions.
  1. +24 −7 lib/showoff.rb
View
@@ -9,13 +9,13 @@
begin
require 'RMagick'
rescue LoadError
- puts 'image sizing disabled - install RMagick'
+ $stderr.puts 'image sizing disabled - install RMagick'
end
begin
require 'pdfkit'
rescue LoadError
- puts 'pdf generation disabled - install PDFKit'
+ $stderr.puts 'pdf generation disabled - install PDFKit'
end
begin
@@ -125,7 +125,7 @@ def update_image_paths(path, slide, static=false)
paths.pop
path = paths.join('/')
replacement_prefix = static ?
- %(img src="file://#{options.pres_dir}/#{path}) :
+ %(img src="./file/#{path}) :
%(img src="/image/#{path})
slide.gsub(/img src=\"(.*?)\"/) do |s|
img_path = File.join(path, $1)
@@ -241,7 +241,7 @@ def index(static=false)
if static
@title = ShowOffUtils.showoff_title
@slides = get_slides_html(static)
- @asset_path = "."
+ @asset_path = "./"
end
erb :index
end
@@ -273,14 +273,14 @@ def assets_needed
href = clean_link(link['src'])
assets << href if href
end
-
+
css = Dir.glob("#{options.public}/**/*.css").map { |path| path.gsub(options.public + '/', '') }
assets << css
js = Dir.glob("#{options.public}/**/*.js").map { |path| path.gsub(options.public + '/', '') }
assets << js
- assets.uniq.join("\n")
+ assets.uniq.join("\n")
end
def slides(static=false)
@@ -325,7 +325,7 @@ def self.do_static(what)
else
out = "#{path}/#{name}/static"
# First make a directory
- FileUtils.makedirs("#{out}")
+ FileUtils.makedirs(out)
# Then write the html
file = File.new("#{out}/index.html", "w")
file.puts(data)
@@ -342,6 +342,23 @@ def self.do_static(what)
next unless File.directory?(subpath) || base.match(/\.(css|js)$/)
FileUtils.copy_entry(subpath, "#{out}/#{base}")
}
+
+ # Set up file dir
+ file_dir = File.join(out, 'file')
+ FileUtils.makedirs(file_dir)
+ pres_dir = showoff.options.pres_dir
+
+ # ..., copy all user-defined styles and javascript files
+ Dir.glob("#{pres_dir}/*.{css,js}").each { |path|
+ FileUtils.copy(path, File.join(file_dir, File.basename(path)))
+ }
+
+ # ... and copy all needed image files
+ data.scan(/img src=\".\/file\/(.*?)\"/).flatten.each do |path|
+ dir = File.dirname(path)
+ FileUtils.makedirs(File.join(file_dir, dir))
+ FileUtils.copy(File.join(pres_dir, path), File.join(file_dir, path))
+ end
end
end

0 comments on commit 769bc24

Please sign in to comment.