Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merging recent changes from schacon/master

  • Loading branch information...
commit 049e3b005e65d5b18a64e262353b5ea04bfe2323 2 parents 2f42a88 + 3a8b364
@grundprinzip grundprinzip authored
View
1  README.rdoc
@@ -221,6 +221,7 @@ custom event:
* *showoff:show* will be triggered as soon as you enter a page
* *showoff:next* will be triggered when you switch to the next page
+* *showoff:incr* will be triggered when you advance to the next increment on the page
* *showoff:prev* will be triggered when you switch to the previous page
These events are triggered on the "div.content" child of the slide, so you must
View
2  lib/commandline_parser.rb
@@ -4,7 +4,7 @@
class CommandlineParser < Parslet::Parser
rule(:prompt) do
- str('$') | str('#')
+ str('$') | str('#') | str('>>')
end
rule(:text) do
View
14 lib/showoff.rb
@@ -31,8 +31,6 @@
class ShowOff < Sinatra::Application
- Version = VERSION = '0.7.0'
-
attr_reader :cached_image_size
set :views, File.dirname(__FILE__) + '/../views'
@@ -263,7 +261,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)
@@ -278,7 +276,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,10 +479,7 @@ def pdf(static=true)
# PDFKit.new takes the HTML and any options for wkhtmltopdf
# run `wkhtmltopdf --extended-help` for a full list of options
- kit = PDFKit.new(html,
- :page_size => 'Letter', # This should be configurable
- :orientation => 'Landscape',
- :print_media_type => true )
+ kit = PDFKit.new(html, ShowOffUtils.showoff_pdf_options)
# Save the PDF to a file
file = kit.to_file('/tmp/preso.pdf')
@@ -504,7 +499,6 @@ def self.do_static(what)
name = showoff.instance_variable_get(:@pres_name)
path = showoff.instance_variable_get(:@root_path)
logger = showoff.instance_variable_get(:@logger)
-
data = showoff.send(what, true)
if data.is_a?(File)
@@ -584,6 +578,8 @@ def eval_ruby code
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)
View
3  lib/showoff/version.rb
@@ -0,0 +1,3 @@
+# No namespace here since ShowOff is a class and I'd have to inherit from
+# Sinatra::Application (which we don't want to load here)
+SHOWOFF_VERSION = '0.7.0'
View
13 lib/showoff_utils.rb
@@ -298,11 +298,18 @@ def self.showoff_sections(dir,logger)
end
def self.showoff_title(dir = '.')
- index = File.join(dir, ShowOffUtils.presentation_config_file )
- order = nil
+ get_config_option(dir, 'name', "Presentation")
+ end
+
+ def self.showoff_pdf_options(dir = '.')
+ get_config_option(dir, 'pdf_options', {:page_size => 'Letter', :orientation => 'Landscape', :print_media_type => true})
+ end
+
+ def self.get_config_option(dir, option, default = nil)
+ index = File.join(dir, ShowOffUtils.presentation_config_file)
if File.exists?(index)
data = JSON.parse(File.read(index))
- data.is_a?(Hash) && data['name'] || "Presentation"
+ data.is_a?(Hash) && data[option] || default
end
end
View
4 public/css/showoff.css
@@ -335,6 +335,10 @@ a.fg-button { float:left; }
background-color: yellow;
}
+.executing:hover {
+ cursor: pointer;
+}
+
#tips, #preshow_timer {
display:inline;
background-color:#000;
View
2  public/js/presenter.js
@@ -2,7 +2,7 @@
var w = null;
$(function(){
- w = window.open('/');
+ w = window.open('/' + window.location.search);
// side menu accordian crap
$("#preso").bind("showoff:loaded", function (event) {
$(".menu > ul ul").hide()
View
25 public/js/showoff.js
@@ -52,7 +52,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)
})
@@ -258,6 +258,16 @@ function determineIncremental()
})
}
+function showIncremental(incr)
+{
+ elem = incrElem.eq(incrCurr)
+ if (incrCode && elem.hasClass('command')) {
+ incrElem.eq(incrCurr).css('visibility', 'visible').jTypeWriter({duration:1.0})
+ } else {
+ incrElem.eq(incrCurr).css('visibility', 'visible')
+ }
+}
+
function prevStep()
{
@@ -283,13 +293,12 @@ function nextStep()
slidenum++
return showSlide()
} else {
- elem = incrElem.eq(incrCurr)
- if (incrCode && elem.hasClass('command')) {
- incrElem.eq(incrCurr).css('visibility', 'visible').jTypeWriter({duration:1.0})
- } else {
- incrElem.eq(incrCurr).css('visibility', 'visible')
- }
- incrCurr++
+ showIncremental(incrCurr);
+ var incrEvent = jQuery.Event("showoff:incr");
+ incrEvent.slidenum = slidenum;
+ incrEvent.incr = incrCurr;
+ $(currentSlide).find(".content").trigger(incrEvent);
+ incrCurr++;
}
}
View
6 showoff.gemspec
@@ -1,7 +1,9 @@
-require './lib/showoff'
+$:.unshift File.expand_path("../lib", __FILE__)
+require 'showoff/version'
+
Gem::Specification.new do |s|
s.name = "showoff"
- s.version = ShowOff::Version
+ s.version = SHOWOFF_VERSION
s.date = "2011-09-10"
s.summary = "The best damn presentation software a developer could ever love."
s.homepage = "http://github.com/schacon/showoff"
View
4 views/header.erb
@@ -32,11 +32,11 @@
<% end %>
<% 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.