Skip to content

Commit

Permalink
Merge pull request #59 from scottbale/showoff
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Dec 28, 2010
2 parents 12c4463 + 41e0567 commit bd33f92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.rdoc
Expand Up @@ -371,7 +371,7 @@ So far, ShowOff has been used in the following presentations (and many others):
* Red Dirt Ruby Conference May 2010 - Plain Old Tokyo Storage - Jeremy Hinegardner
http://github.com/copiousfreetime/plain-old-tokyo-storage-presentation
http://plain-old-tokyo-storage.heroku.com/
* Lambda Lounge - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
* Lambda Lounge and StrangeLoop 2010 - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
http://github.com/scottbale/JavaScript-Function-Idioms
* Open Source Bridge 2010 - Creating a low-cost clustered virtualization environment w/ Ganeti - Lance Albertson
http://github.com/ramereth/presentation-ganeti
Expand Down Expand Up @@ -423,6 +423,7 @@ etc).
* json
* GLI gem
* Firefox or Chrome to present
* PDFKit (optional, for generating PDF of presentation) https://github.com/jdpace/PDFKit

= Contributing

Expand Down
22 changes: 15 additions & 7 deletions lib/showoff.rb
Expand Up @@ -13,9 +13,9 @@
end

begin
require 'princely'
require 'pdfkit'
rescue LoadError
puts 'pdf generation disabled - install princely'
puts 'pdf generation disabled - install PDFKit'
end

begin
Expand Down Expand Up @@ -233,6 +233,10 @@ def inline_js(jses, pre = nil)
js_content
end

def inline_all_js(jses_directory)
inline_js(Dir.entries(File.join(File.dirname(__FILE__), '..', jses_directory)).find_all{|filename| filename.length > 2 }, jses_directory)
end

def index(static=false)
if static
@title = ShowOffUtils.showoff_title
Expand Down Expand Up @@ -288,14 +292,18 @@ def onepage(static=false)
erb :onepage
end

def pdf(static=false)
def pdf(static=true)
@slides = get_slides_html(static)
@no_js = true
@no_js = false
html = erb :onepage
p = Princely.new
# TODO make a random filename
p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
File.new('/tmp/preso.pdf')

# 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', :orientation => 'Landscape')

# Save the PDF to a file
file = kit.to_file('/tmp/preso.pdf')
end

end
Expand Down
1 change: 1 addition & 0 deletions views/onepage.erb
Expand Up @@ -18,6 +18,7 @@
<% if !@no_js %>
<%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'], 'public/js') %>
<%= inline_all_js('public/js/sh_lang') %>
<script type="text/javascript">
$(document).ready(function() {
setupOnePage()
Expand Down

0 comments on commit bd33f92

Please sign in to comment.