showoff 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -47,8 +47,8 @@ ShowOff is meant to be run in a ShowOff formatted repository - that means that i
47
47
  $ cd (showoff-repo)
48
48
  $ showoff serve
49
49
 
50
- If you run 'showoff' in the ShowOff directory itself, it will show an example
51
- presentation from the 'example' subdirectory, so you can see what it's like.
50
+ If you run 'showoff' in the example subdirectory of ShowOff itself, it will
51
+ show an example presentation, so you can see what it's like.
52
52
 
53
53
  = Slide Format
54
54
 
@@ -150,10 +150,10 @@ You can manage the presentation with the following keys:
150
150
 
151
151
  = Preshow
152
152
 
153
- If you want to show a slideshow while you wait to speak, you can run a preshow. Add a `_preshow` directory
154
- to your project (I use a symlink, so I don't have to add all the images into Git), put a bunch of images in the `_preshow` directory and optionally add a `preshow.json` file that provides descriptions for any of the images.
153
+ If you want to show a slideshow while you wait to speak, you can run a preshow. Add a +_preshow+ directory
154
+ to your project (I use a symlink, so I don't have to add all the images into Git), put a bunch of images in the +_preshow+ directory and optionally add a +preshow+.+json+ file that provides descriptions for any of the images.
155
155
  If you then press 'p' at the beginning of your presentation, it will prompt you for a number of minutes until
156
- you start. Then it will count down the time until then, flipping through your pictures to entertain the
156
+ you start. Then it will count down the time until then, flipping through your pictures to entertain the
157
157
  audience in the meantime. Press 'p' again to stop, or wait until the timer runs out.
158
158
 
159
159
  = Custom JavaScript
@@ -213,6 +213,41 @@ press the right array key another time, you will switch to the next slide.
213
213
  The same applies to the *showoff:prev* event, of course.
214
214
 
215
215
 
216
+ = Custom Stylesheets
217
+
218
+ To insert custom Stylesheets into your presentation you can either place it into
219
+ a file (with extension .css) or into the root directory of your presentation or
220
+ you can embed a <+link+>-element directly into your slides. This stylesheet will
221
+ be applied as soon as it is loaded.
222
+
223
+ The content generated by the slide is wrapped with a +div+ with the class .+content+ like this.
224
+
225
+ <div ref="intro/01_slide/1" class="content" style="margin-top: 210px;">
226
+ <h1>jQuery &amp; Sinatra</h1>
227
+ <h2>A Classy Combination</h2>
228
+ </div>
229
+
230
+ This makes the .+content+ tag a perfect place to add additional styling if that
231
+ is your preference. An example of adding some styling is here.
232
+
233
+ .content {
234
+ color: black;
235
+ font-family: helvetica, arial;
236
+ }
237
+ h1, h2 {
238
+ color: rgb(79, 180, 226);
239
+ font-family: Georgia;
240
+ }
241
+ .content::after {
242
+ position: absolute;
243
+ right: 120px;
244
+ bottom: 120px;
245
+ content: url(jay_small.png);
246
+ }
247
+
248
+ Note that the example above uses CSS3 styling with ::+after+ and the +content+
249
+ -attribute to add an image to the slides.
250
+
216
251
  = Editor integration
217
252
 
218
253
  The "add slide" feature can allow you to add the necessary boilerplate from your editor. If you are using vim, you can
@@ -241,8 +276,8 @@ added where your cursor was. Binding this to a keybinding can allow you to add
241
276
  [<tt>create</tt>] Create new showoff presentation
242
277
  [<tt>help</tt>] Shows list of commands or help for one command
243
278
  [<tt>heroku</tt>] Setup your presentation to serve on Heroku
244
- [<tt>heroku_secure</tt>] Setup your presentation to serve on Heroku with password protection
245
279
  [<tt>serve</tt>] Serves the showoff presentation in the current directory
280
+ [<tt>static</tt>] Generate static version of presentation
246
281
 
247
282
  === <tt>add [title]</tt>
248
283
 
@@ -283,19 +318,28 @@ Shows list of commands or help for one command
283
318
 
284
319
  Setup your presentation to serve on Heroku
285
320
 
286
- === <tt>heroku_secure heroku_name password</tt>
321
+ Creates the Gemfile and config.ru file needed to push a showoff pres to heroku. It will then run heroku create for you to register the new project on heroku and add the remote for you. Then all you need to do is commit the new created files and run git push heroku to deploy.
287
322
 
288
- Setup your presentation to serve on Heroku with password protection using HTTP Authentication
323
+ ==== Options
324
+ These options are specified *after* the command.
289
325
 
326
+ [<tt>-f, --force</tt>] force overwrite of existing Gemfile/.gems and config.ru files if they exist
327
+ [<tt>-g, --dotgems</tt>] Use older-style .gems file instead of bundler-style Gemfile
328
+ [<tt>-p, --password=arg</tt>] add password protection to your heroku site
290
329
  === <tt>serve </tt>
291
330
 
292
331
  Serves the showoff presentation in the current directory
293
332
 
294
333
 
334
+
295
335
  ==== Options
296
336
  These options are specified *after* the command.
297
337
 
338
+ [<tt>-h, --host=arg</tt>] Host or ip to run on <i>( default: <tt>localhost</tt>)</i>
298
339
  [<tt>-p, --port=arg</tt>] Port on which to run <i>( default: <tt>9090</tt>)</i>
340
+ === <tt>static name</tt>
341
+
342
+ Generate static version of presentation
299
343
 
300
344
  === ZSH completion
301
345
  You can complete commands and options in ZSH, by installing a script:
@@ -327,7 +371,7 @@ So far, ShowOff has been used in the following presentations (and many others):
327
371
  * Red Dirt Ruby Conference May 2010 - Plain Old Tokyo Storage - Jeremy Hinegardner
328
372
  http://github.com/copiousfreetime/plain-old-tokyo-storage-presentation
329
373
  http://plain-old-tokyo-storage.heroku.com/
330
- * Lambda Lounge - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
374
+ * Lambda Lounge and StrangeLoop 2010 - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
331
375
  http://github.com/scottbale/JavaScript-Function-Idioms
332
376
  * Open Source Bridge 2010 - Creating a low-cost clustered virtualization environment w/ Ganeti - Lance Albertson
333
377
  http://github.com/ramereth/presentation-ganeti
@@ -379,6 +423,7 @@ etc).
379
423
  * json
380
424
  * GLI gem
381
425
  * Firefox or Chrome to present
426
+ * PDFKit (optional, for generating PDF of presentation) https://github.com/jdpace/PDFKit
382
427
 
383
428
  = Contributing
384
429
 
data/bin/showoff CHANGED
@@ -25,26 +25,24 @@ command [:create,:init] do |c|
25
25
  end
26
26
  end
27
27
 
28
- desc 'Same as heroku create, but also adds password protection'
29
- arg_name 'heroku_name password'
30
- long_desc 'Creates the .gems file and config.ru file needed to push a showoff pres to heroku with password protection. it will then run ''heroku create'' for you to register the new project on heroku and add the remote for you. then all you need to do is commit the new created files and run ''git push heroku'' to deploy.'
31
- command :heroku_secure do |c|
32
- c.action do |global_options,options,args|
33
- p args
34
- raise "heroku_name is required" if args.empty?
35
- raise "password is required" if args.length == 1
36
- ShowOffUtils.heroku_secure(args[0], args[1])
37
- end
38
- end
39
-
40
28
  desc 'Serves the showoff presentation in the current directory'
41
29
  desc 'Setup your presentation to serve on Heroku'
42
30
  arg_name 'heroku_name'
43
- long_desc 'Creates the .gems file and config.ru file needed to push a showoff pres to heroku. it will then run ''heroku create'' for you to register the new project on heroku and add the remote for you. then all you need to do is commit the new created files and run ''git push heroku'' to deploy.'
31
+ long_desc 'Creates the Gemfile and config.ru file needed to push a showoff pres to heroku. It will then run ''heroku create'' for you to register the new project on heroku and add the remote for you. Then all you need to do is commit the new created files and run ''git push heroku'' to deploy.'
44
32
  command :heroku do |c|
33
+
34
+ c.desc 'add password protection to your heroku site'
35
+ c.flag [:p,:password]
36
+
37
+ c.desc 'force overwrite of existing Gemfile/.gems and config.ru files if they exist'
38
+ c.switch [:f,:force]
39
+
40
+ c.desc 'Use older-style .gems file instead of bundler-style Gemfile'
41
+ c.switch [:g,:dotgems]
42
+
45
43
  c.action do |global_options,options,args|
46
44
  raise "heroku_name is required" if args.empty?
47
- ShowOffUtils.heroku(args[0])
45
+ ShowOffUtils.heroku(args[0],options[:f],options[:p],options[:g])
48
46
  end
49
47
  end
50
48
 
data/lib/showoff.rb CHANGED
@@ -13,9 +13,9 @@ rescue LoadError
13
13
  end
14
14
 
15
15
  begin
16
- require 'princely'
16
+ require 'pdfkit'
17
17
  rescue LoadError
18
- puts 'pdf generation disabled - install princely'
18
+ puts 'pdf generation disabled - install PDFKit'
19
19
  end
20
20
 
21
21
  begin
@@ -233,6 +233,10 @@ class ShowOff < Sinatra::Application
233
233
  js_content
234
234
  end
235
235
 
236
+ def inline_all_js(jses_directory)
237
+ inline_js(Dir.entries(File.join(File.dirname(__FILE__), '..', jses_directory)).find_all{|filename| filename.length > 2 }, jses_directory)
238
+ end
239
+
236
240
  def index(static=false)
237
241
  if static
238
242
  @title = ShowOffUtils.showoff_title
@@ -288,14 +292,18 @@ class ShowOff < Sinatra::Application
288
292
  erb :onepage
289
293
  end
290
294
 
291
- def pdf(static=false)
295
+ def pdf(static=true)
292
296
  @slides = get_slides_html(static)
293
- @no_js = true
297
+ @no_js = false
294
298
  html = erb :onepage
295
- p = Princely.new
296
299
  # TODO make a random filename
297
- p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
298
- File.new('/tmp/preso.pdf')
300
+
301
+ # PDFKit.new takes the HTML and any options for wkhtmltopdf
302
+ # run `wkhtmltopdf --extended-help` for a full list of options
303
+ kit = PDFKit.new(html, :page_size => 'Letter', :orientation => 'Landscape')
304
+
305
+ # Save the PDF to a file
306
+ file = kit.to_file('/tmp/preso.pdf')
299
307
  end
300
308
 
301
309
  end
data/lib/showoff_utils.rb CHANGED
@@ -28,69 +28,67 @@ class ShowOffUtils
28
28
  end
29
29
  end
30
30
 
31
+ HEROKU_GEMS_FILE = '.gems'
32
+ HEROKU_BUNDLER_GEMS_FILE = 'Gemfile'
33
+ HEROKU_CONFIG_FILE = 'config.ru'
34
+
31
35
  # Setup presentation to run on Heroku
32
- def self.heroku(name)
36
+ #
37
+ # name - String containing heroku name
38
+ # force - boolean if .gems/Gemfile and config.ru should be overwritten if they don't exist
39
+ # password - String containing password to protect your heroku site; nil means no password protection
40
+ # use_dot_gems - boolea that, if true, indicates we should use the old, deprecated .gems file instead of Bundler
41
+ def self.heroku(name,force,password,use_dot_gems)
33
42
  if !File.exists?(SHOWOFF_JSON_FILE)
34
43
  puts "fail. not a showoff directory"
35
44
  return false
36
45
  end
37
- # create .gems file
38
- File.open('.gems', 'w+') do |f|
39
- f.puts "bluecloth"
40
- f.puts "nokogiri"
41
- f.puts "showoff"
42
- f.puts "gli"
43
- end if !File.exists?('.gems')
44
-
45
- # create config.ru file
46
- File.open('config.ru', 'w+') do |f|
47
- f.puts 'require "showoff"'
48
- f.puts 'run ShowOff.new'
49
- end if !File.exists?('config.ru')
50
-
51
- puts "herokuized. run something like this to launch your heroku presentation:
52
-
53
- heroku create #{name}
54
- git add .gems config.ru
55
- git commit -m 'herokuized'
56
- git push heroku master
57
- "
58
- end
59
46
 
60
- # Setup the presentation to run on Heroku with password protection
61
- def self.heroku_secure(name, password)
62
- if !File.exists?(SHOWOFF_JSON_FILE)
63
- puts "fail. not a showoff directory"
64
- return false
47
+ modified_something = false
48
+
49
+ if use_dot_gems
50
+ modified_something = create_gems_file(HEROKU_GEMS_FILE,
51
+ !password.nil?,
52
+ force,
53
+ lambda{ |gem| gem })
54
+ else
55
+ modified_something = create_gems_file(HEROKU_BUNDLER_GEMS_FILE,
56
+ !password.nil?,
57
+ force,
58
+ lambda{ |gem| "gem '#{gem}'" },
59
+ lambda{ "source :rubygems" })
60
+ end
61
+
62
+ create_file_if_needed(HEROKU_CONFIG_FILE,force) do |file|
63
+ modified_something = true
64
+ file.puts 'require "showoff"'
65
+ if password.nil?
66
+ file.puts 'run ShowOff.new'
67
+ else
68
+ file.puts 'require "rack"'
69
+ file.puts 'showoff_app = ShowOff.new'
70
+ file.puts 'protected_showoff = Rack::Auth::Basic.new(showoff_app) do |username, password|'
71
+ file.puts "\tpassword == '#{password}'"
72
+ file.puts 'end'
73
+ file.puts 'run protected_showoff'
74
+ end
65
75
  end
66
- # create .gems file
67
- File.open('.gems', 'w+') do |f|
68
- f.puts "bluecloth"
69
- f.puts "nokogiri"
70
- f.puts "showoff"
71
- f.puts "gli"
72
- f.puts "rack"
73
- end if !File.exists?('.gems')
74
-
75
- # create config.ru file
76
- File.open('config.ru', 'w+') do |f|
77
- f.puts 'require "rack"'
78
- f.puts 'require "showoff"'
79
- f.puts 'showoff_app = ShowOff.new'
80
- f.puts 'protected_showoff = Rack::Auth::Basic.new(showoff_app) do |username, password|'
81
- f.puts "\tpassword == '#{password}'"
82
- f.puts 'end'
83
- f.puts 'run protected_showoff'
84
-
85
- end if !File.exists?('config.ru')
86
-
87
- puts "herokuized. run something like this to launch your heroku presentation:
88
-
89
- heroku create #{name}
90
- git add .gems config.ru
91
- git commit -m 'herokuized'
76
+
77
+ if modified_something
78
+ puts "herokuized. run something like this to launch your heroku presentation:
79
+
80
+ heroku create #{name}"
81
+
82
+ if use_dot_gems
83
+ puts " git add #{HEROKU_GEMS_FILE} #{HEROKU_CONFIG_FILE}"
84
+ else
85
+ puts " bundle install
86
+ git add Gemfile.lock #{HEROKU_GEMS_FILE} #{HEROKU_CONFIG_FILE}"
87
+ end
88
+ puts " git commit -m 'herokuized'
92
89
  git push heroku master
93
- "
90
+ "
91
+ end
94
92
  end
95
93
 
96
94
  # Makes a slide as a string.
@@ -293,4 +291,52 @@ class ShowOffUtils
293
291
  ext = File.extname(source_file).gsub(/^\./,'')
294
292
  EXTENSIONS[ext] || ext
295
293
  end
294
+
295
+ REQUIRED_GEMS = %w(bluecloth nokogiri showoff gli)
296
+
297
+ # Creates the file that lists the gems for heroku
298
+ #
299
+ # filename - String name of the file
300
+ # password - Boolean to indicate if we are setting a password
301
+ # force - Boolean to indicate if we should overwrite the existing file
302
+ # formatter - Proc/lambda that takes 1 argument, the gem name, and formats it for the file
303
+ # This is so we can support both the old .gems and the new bundler Gemfile
304
+ # header - Proc/lambda that creates any header information in the file
305
+ #
306
+ # Returns a boolean indicating that we had to create the file or not.
307
+ def self.create_gems_file(filename,password,force,formatter,header=nil)
308
+ create_file_if_needed(filename,force) do |file|
309
+ file.puts header.call unless header.nil?
310
+ REQUIRED_GEMS.each { |gem| file.puts formatter.call(gem) }
311
+ file.puts formatter.call("rack") if password
312
+ end
313
+ end
314
+
315
+ # Creates the given filename if it doesn't exist or if force is true
316
+ #
317
+ # filename - String name of the file to create
318
+ # force - if true, the file will always be created, if false, only create
319
+ # if it's not there
320
+ # block - takes a block that will be given the file handle to write
321
+ # data into the file IF it's being created
322
+ #
323
+ # Examples
324
+ #
325
+ # create_file_if_needed("config.ru",false) do |file|
326
+ # file.puts "require 'showoff'"
327
+ # file.puts "run ShowOff.new"
328
+ # end
329
+ #
330
+ # Returns true if the file was created
331
+ def self.create_file_if_needed(filename,force)
332
+ if !File.exists?(filename) || force
333
+ File.open(filename, 'w+') do |f|
334
+ yield f
335
+ end
336
+ true
337
+ else
338
+ puts "#{filename} exists; not overwriting (see showoff help heroku)"
339
+ false
340
+ end
341
+ end
296
342
  end
data/public/js/showoff.js CHANGED
@@ -86,6 +86,7 @@ function initializePresentation(prefix) {
86
86
  }
87
87
  setupSlideParamsCheck();
88
88
  sh_highlightDocument(prefix+'/js/sh_lang/', '.min.js')
89
+ $(".preso").trigger("showoff:loaded");
89
90
  }
90
91
 
91
92
  function centerSlides(slides) {
data/views/onepage.erb CHANGED
@@ -18,6 +18,7 @@
18
18
 
19
19
  <% if !@no_js %>
20
20
  <%= 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') %>
21
+ <%= inline_all_js('public/js/sh_lang') %>
21
22
  <script type="text/javascript">
22
23
  $(document).ready(function() {
23
24
  setupOnePage()
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showoff
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Chacon