Skip to content

Commit

Permalink
Make it possible to run ShowOff apps under Rack::Map.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Oct 1, 2011
1 parent 335e142 commit 950fc57
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/showoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def update_image_paths(path, slide, static=false, pdf=false)
path = paths.join('/')
replacement_prefix = static ?
( pdf ? %(img src="file://#{options.pres_dir}/#{path}) : %(img src="./file/#{path}) ) :
%(img src="/image/#{path})
%(img src="#{@asset_path}image/#{path})
slide.gsub(/img src=\"([^\/].*?)\"/) do |s|
img_path = File.join(path, $1)
w, h = get_image_size(img_path)
Expand All @@ -203,7 +203,7 @@ def update_image_paths(path, slide, static=false, pdf=false)
if defined?(Magick)
def get_image_size(path)
if !cached_image_size.key?(path)
img = Magick::Image.ping(path).first
img = Magick::Image.ping(File.join(@asset_path, path)).first
# don't set a size for svgs so they can expand to fit their container
if img.mime_type == 'image/svg+xml'
cached_image_size[path] = [nil, nil]
Expand Down Expand Up @@ -483,6 +483,7 @@ def eval_ruby code
@title = ShowOffUtils.showoff_title
what = params[:captures].first
what = 'index' if "" == what
@asset_path = (env['SCRIPT_NAME'] || '').gsub(/\/?$/, '/').gsub(/^\//, '')
if (what != "favicon.ico")
data = send(what)
if data.is_a?(File)
Expand Down
2 changes: 1 addition & 1 deletion public/js/showoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function setupPreso(load_slides, prefix) {
function loadSlides(load_slides, prefix) {
//load slides offscreen, wait for images and then initialize
if (load_slides) {
$("#slides").load("slides", false, function(){
$("#slides").load(loadSlidesPrefix + "slides", false, function(){
$("#slides img").batchImageLoad({
loadingCompleteCallback: initializePresentation(prefix)
})
Expand Down
4 changes: 2 additions & 2 deletions views/header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<link type="text/css" href="<%= @asset_path %>css/sh_style.css" rel="stylesheet" >

<% css_files.each do |css_file| %>
<link rel="stylesheet" href="file/<%= css_file %>" type="text/css"/>
<link rel="stylesheet" href="<%= @asset_path %>file/<%= css_file %>" type="text/css"/>
<% end %>
<% js_files.each do |js_file| %>
<script type="text/javascript" src="file/<%= js_file %>"></script>
<script type="text/javascript" src="<%= @asset_path %>file/<%= js_file %>"></script>
<% end %>

<script type="text/javascript">
Expand Down

0 comments on commit 950fc57

Please sign in to comment.