Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #136 from jcoglan/master

Make ShowOff compatible with Rack::URLMap
  • Loading branch information...
commit 7116e022564931fd236ce26ec9bf77648bc63730 2 parents d8e5f0f + 950fc57
Gonçalo Silva goncalossilva authored
Showing with 6 additions and 5 deletions.
  1. +3 −2 lib/showoff.rb
  2. +1 −1  public/js/showoff.js
  3. +2 −2 views/header.erb
5 lib/showoff.rb
View
@@ -186,7 +186,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)
@@ -201,7 +201,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]
@@ -481,6 +481,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)
2  public/js/showoff.js
View
@@ -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)
})
4 views/header.erb
View
@@ -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">
Please sign in to comment.
Something went wrong with that request. Please try again.