Skip to content

Commit

Permalink
PDF with PDFKit: clean up previous hack, properly load all sh_lang fi…
Browse files Browse the repository at this point in the history
…les from directory
  • Loading branch information
Scott Bale committed Nov 24, 2010
1 parent 105647c commit 081ce0e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
23 changes: 4 additions & 19 deletions lib/showoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
puts 'image sizing disabled - install RMagick'
end

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

begin
require 'pdfkit'
rescue LoadError
Expand Down Expand Up @@ -239,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 @@ -298,27 +296,14 @@ def pdf(static=false)
@slides = get_slides_html(static)
@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')
# kit.stylesheets << '/css/showoff.css'

# Git an inline PDF
# pdf = kit.to_pdf

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

# Add any kind of option through meta tags
# PDFKit.new('<html><head><meta name="pdfkit-page_size" content="Letter")


end

end
Expand Down
1 change: 0 additions & 1 deletion public/js/sh_html.min.js

This file was deleted.

1 change: 0 additions & 1 deletion public/js/sh_javascript.min.js

This file was deleted.

3 changes: 2 additions & 1 deletion views/onepage.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<% end %>
<% if !@no_js %>
<%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'sh_javascript.min.js', 'sh_html.min.js', 'core.js', 'showoffcore.js'], 'public/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 081ce0e

Please sign in to comment.