Skip to content

Commit 6312d4c

Browse files
committed
Merge pull request binford2k#88 from alexch/showoff
--- including documentation for new features Conflicts: README.rdoc
2 parents c05e297 + d389688 commit 6312d4c

12 files changed

+176
-73
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tmtags
1616
## PROJECT::GENERAL
1717
coverage
1818
rdoc
19+
doc
1920
pkg
2021
*.gem
2122
.bundle

Gemfile

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
source :rubygems
2-
gemspec
2+
3+
gem "sinatra"
4+
gem "bluecloth"
5+
gem "nokogiri"
6+
gem "json"
7+
gem "gli",">= 1.2.5"
8+
9+
group :development do
10+
gem "mg"
11+
end
312

413
group :optional do
514
gem "rmagick"

README.rdoc

+61-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hatred in my heart for Keynote and yet it is by far the best in the field.
77

88
The idea is that you setup your markdown slide files in section subdirectories
99
and then startup the showoff server in that directory. It will read in your
10-
showoff.json file for which sections go in which order and then will give
10+
<tt>showoff.json</tt> file for which sections go in which order and then will give
1111
you a URL to present from.
1212

1313
It can:
@@ -26,21 +26,24 @@ It might will can:
2626

2727
* show a timer - elapsed / remaining
2828
* perform simple animations of images moving between keyframes
29-
* show syncronized, hidden notes on another browser (like an iphone)
29+
* show synchronized, hidden notes on another browser (like an iphone)
3030
* show audience questions / comments (twitter or direct)
3131
* let audience members go back / catch up as you talk
3232
* let audience members vote on sections (?)
3333
* broadcast itself on Bonjour
3434
* let audience members download slides, code samples or other supplementary material
3535
* let you write on the slide with your mouse, madden-style via canvas
36+
* automatically resize text to fit screen
3637

3738
Some of the nice things are that you can easily version control it, you
3839
can easily move sections between presentations, and you can rearrange or
3940
remove sections easily.
4041

4142
= Usage
4243

43-
ShowOff is meant to be run in a ShowOff formatted repository - that means that it has a showoff.json file and a number of sections (subdirectories) with markdown files for the slides you're presenting.
44+
ShowOff is meant to be run in a ShowOff formatted repository - that means that
45+
it has a <tt>showoff.json</tt> file and a number of sections (subdirectories) with
46+
markdown files for the slides you're presenting.
4447

4548
$ gem install showoff
4649
$ git clone (showoff-repo)
@@ -50,11 +53,16 @@ ShowOff is meant to be run in a ShowOff formatted repository - that means that i
5053
If you run 'showoff' in the example subdirectory of ShowOff itself, it will
5154
show an example presentation, so you can see what it's like.
5255

56+
You can also run 'showoff serve' inside a section subdirectory. If there is no
57+
<tt>showoff.json</tt> file then it will make its best guess, creating a presentation
58+
from all `.md` files in alphabetical order in the given (or current)
59+
directory.
60+
5361
= Slide Format
5462

5563
You can break your slides up into sections of however many subdirectories deep
5664
you need. ShowOff will recursively check all the directories mentioned in
57-
your showoff.json file for any markdown files (.md). Each markdown file can
65+
your <tt>showoff.json</tt> file for any markdown files (.md). Each markdown file can
5866
have any number of slides in it, separating each slide with the '!SLIDE'
5967
keyword and optional slide styles.
6068

@@ -77,7 +85,7 @@ the following contents:
7785
That represents two slides, the first contains just a large title, and the
7886
second is faded into view showing the title and three bullets that are then
7987
incrementally shown. In order for ShowOff to see those slides, your
80-
showoff.json file needs to look something like this:
88+
<tt>showoff.json</tt> file needs to look something like this:
8189

8290
[
8391
{"section":"one"}
@@ -147,13 +155,20 @@ The transitions are provided by jQuery Cycle plugin. See http://www.malsup.com/j
147155
You can manage the presentation with the following keys:
148156

149157
* space, cursor right: next slide
150-
* cursor left: previous slide
158+
* shift-space, cursor left: previous slide
151159
* d: debug mode
152-
* c: table of contents (vi)
160+
* c, t: table of contents (vi)
153161
* f: toggle footer
154-
* z: toggle help
162+
* z, ?: toggle help
155163
* p: toggle preshow
156164

165+
= Showing plain old markdown
166+
167+
If a markdown file has no !SLIDE keywords, then showoff will treat every line
168+
beginning with a single hash -- i.e. every H1 -- as a new slide in "bullets"
169+
style. Remember that you can't specify classes or transitions in this mode,
170+
and as soon as you add one !SLIDE you need them everywhere.
171+
157172
= Preshow
158173

159174
If you want to show a slideshow while you wait to speak, you can run a preshow. Add a +_preshow+ directory
@@ -166,7 +181,7 @@ audience in the meantime. Press 'p' again to stop, or wait until the timer runs
166181

167182
To insert custom JavaScript into your presentation you can either place it into
168183
a file (with extension .js) into the root directory of your presentation or you
169-
can embed a <script>-element directly into your slides. This JavaScript will be
184+
can embed a <+script+> element directly into your slides. This JavaScript will be
170185
executed—as usually—as soon as it is loaded.
171186

172187
If you want to trigger some JavaScript as soon as a certain page is shown or
@@ -223,7 +238,7 @@ The same applies to the *showoff:prev* event, of course.
223238

224239
To insert custom Stylesheets into your presentation you can either place it into
225240
a file (with extension .css) into the root directory of your presentation or
226-
you can embed a <+link+>-element directly into your slides. This stylesheet will
241+
you can embed a <+link+> element directly into your slides. This stylesheet will
227242
be applied as soon as it is loaded.
228243

229244
The content generated by the slide is wrapped with a +div+ with the class .+content+ like this.
@@ -311,27 +326,34 @@ added where your cursor was. Binding this to a keybinding can allow you to add
311326
[<tt>help</tt>] Shows list of commands or help for one command
312327
[<tt>heroku</tt>] Setup your presentation to serve on Heroku
313328
[<tt>github</tt>] Setup your presentation to serve on GitHub Pages
314-
[<tt>serve</tt>] Serves the showoff presentation in the current directory
329+
[<tt>serve</tt>] Serves the showoff presentation in the current directory (or a given dir)
315330
[<tt>static</tt>] Generate static version of presentation
316331

317-
=== <tt>add [title]</tt>
332+
333+
== <tt>showoff add [title]</tt>
318334

319335
Add a new slide at the end in a given dir
320336

321337
*Aliases*
322338
* <tt><b>new</b></tt>
323339

324-
Outputs or creates a new slide. With -d and -n, a new slide is created in the given dir, numbered to appear as the last slide in that dir (use -u to avoid numbering). Without those, outputs the slide markdown to stdout (useful for shelling out from your editor). You may also specify a source file to use for a code slide
340+
Outputs or creates a new slide. With -d and -n, a new slide is created in the given dir, numbered to appear
341+
as the last slide in that dir (use -u to avoid numbering). Without those, outputs the slide markdown to
342+
stdout (useful for shelling out from your editor). You may also specify a source file to use for a code
343+
slide.
344+
345+
=== options for add
325346

326-
==== Options
327347
These options are specified *after* the command.
328348

329349
[<tt>-d, --dir=dir</tt>] Slide dir (where to put a new slide file)
330350
[<tt>-n, --name=basename</tt>] Slide name (name of the new slide file)
331351
[<tt>-s, --source=path to file</tt>] Include code from the given file as the slide body
332352
[<tt>-t, --style, --type=valid showoff style/type</tt>] Slide Type/Style <i>( default: <tt>title</tt>)</i>
333353
[<tt>-u, --nonumber</tt>] Dont number the slide, use the given name verbatim
334-
=== <tt>create dir_name</tt>
354+
355+
356+
== <tt>showoff create dir_name</tt>
335357

336358
Create new showoff presentation
337359

@@ -340,57 +362,68 @@ Create new showoff presentation
340362

341363
This command helps start a new showoff presentation by setting up the proper directory structure for you. It takes the directory name you would like showoff to create for you.
342364

343-
==== Options
365+
=== options for create
366+
344367
These options are specified *after* the command.
345368

346369
[<tt>-d, --slidedir=arg</tt>] sample slide directory name <i>( default: <tt>one</tt>)</i>
347370
[<tt>-n, --nosamples</tt>] Dont create sample slides
348-
=== <tt>help [command]</tt>
371+
372+
373+
== <tt>showoff help [command]</tt>
349374

350375
Shows list of commands or help for one command
351376

352-
=== <tt>heroku heroku_name</tt>
377+
378+
== <tt>showoff heroku heroku_name</tt>
353379

354380
Setup your presentation to serve on Heroku
355381

356382
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.
357383

358-
=== <tt>github</tt>
384+
385+
== <tt>showoff github</tt>
359386

360387
Generates a static version of your site and puts it in a gh-pages branch for static serving on GitHub.
361388

362-
==== Options
389+
=== options for github
363390
These options are specified *after* the command.
364391

365392
[<tt>-f, --force</tt>] force overwrite of existing Gemfile/.gems and config.ru files if they exist
366393
[<tt>-g, --dotgems</tt>] Use older-style .gems file instead of bundler-style Gemfile
367394
[<tt>-p, --password=arg</tt>] add password protection to your heroku site
368-
=== <tt>serve </tt>
369395

370-
Serves the showoff presentation in the current directory
371396

397+
== <tt>showoff serve </tt>
372398

399+
Serves the showoff presentation in the current directory
373400

374-
==== Options
401+
==== options for serve
375402
These options are specified *after* the command.
376403

404+
[<tt>-f, --pres_file=arg</tt>] Presentation file <i>(default: <tt>showoff.json</tt>)</i>
377405
[<tt>-h, --host=arg</tt>] Host or ip to run on <i>( default: <tt>localhost</tt>)</i>
378406
[<tt>-p, --port=arg</tt>] Port on which to run <i>( default: <tt>9090</tt>)</i>
379-
=== <tt>static name</tt>
407+
408+
409+
== <tt>showoff static name</tt>
380410

381411
Generate static version of presentation
382412

383-
=== PDF
413+
414+
= PDF
384415
Append a "/pdf" to the end of your presentation URL, and a PDF will be generated within the browser. For example,
385416
http://localhost:9090/pdf
386417

387-
=== ZSH completion
418+
419+
= ZSH completion
388420
You can complete commands and options in ZSH, by installing a script:
389421

390422
mkdir -p $HOME/.zsh/Completion
391423
cp script/_showoff $HOME/.zsh/Completion
392424
echo 'fpath=(~/.zsh/Completion $fpath)' >> $HOME/.zshrc
393425

426+
394427
= Real World Usage
395428

396429
So far, ShowOff has been used in the following presentations (and many others):
@@ -426,6 +459,8 @@ So far, ShowOff has been used in the following presentations (and many others):
426459
http://github.com/nono/Presentations/tree/master/20100708_RMLL_Ruby_1.9/
427460
* Lone Star PHP 2011 - Drupal - Chris Christensen
428461
https://github.com/christianchristensen/Presentations/tree/master/20110611-lonestarphp-drupal
462+
* Railsbridge Open Workshops - Sarah Allen, Sarah Mei, and Alex Chaffee
463+
http://github.com/alexch/workshop
429464

430465

431466
If you use it for something, please let me know so I can add it.

TODO.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ TODO
1313
- questions / comments system
1414
- audience vote-based presentation builder, results live view
1515
- simple animations (image from A to B)
16+
- squeeze-to-fit style
17+
- extract Version into a separate file, so we can include it in gemspec without pulling in the universe

bin/showoff

+9-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ command :heroku do |c|
5656
end
5757
end
5858

59-
desc 'Serves the showoff presentation in the current directory'
59+
desc 'Serves the showoff presentation in the specified (or current) directory'
60+
arg_name "[pres_dir]"
61+
default_value "."
6062
command :serve do |c|
6163

6264
c.desc 'Port on which to run'
@@ -65,10 +67,14 @@ command :serve do |c|
6567

6668
c.desc 'Host or ip to run on'
6769
c.default_value "localhost"
68-
c.flag [:h,:host]
70+
c.flag [:h,:host]
71+
72+
c.desc 'JSON file used to describe presentation'
73+
c.default_value "showoff.json"
74+
c.flag [:f, :pres_file]
6975

7076
c.action do |global_options,options,args|
71-
ShowOff.run! :host => options[:h], :port => options[:p].to_i
77+
ShowOff.run! :host => options[:h], :port => options[:p].to_i, :pres_file => options[:f], :pres_dir => args[0]
7278
end
7379
end
7480

example/one/slidesA.md

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
* a fourth thing
1515
* a fifth thing
1616

17+
<!SLIDE bullets>
18+
# Third Slide
19+
20+
* Sometimes bullet items
21+
* Have sublists
22+
* And some sublist items
23+
* Have some of their own
24+
* And so on
25+
* But top-level "bullet items" have no bullets
26+
* isn't that odd?
27+
28+
Also, sometimes you just want to have plain text sitting in the middle
29+
of the screen. The quick brown fox jumps over the lazy dog.
30+
1731
!SLIDE center transition=scrollUp
1832
.notes another dark side
1933

lib/showoff.rb

+17-10
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,30 @@
3131

3232
class ShowOff < Sinatra::Application
3333

34-
Version = VERSION = '0.4.2'
34+
Version = VERSION = '0.5.0'
3535

3636
attr_reader :cached_image_size
3737

3838
set :views, File.dirname(__FILE__) + '/../views'
3939
set :public, File.dirname(__FILE__) + '/../public'
40-
set :pres_dir, 'example'
4140

4241
def initialize(app=nil)
4342
super(app)
44-
puts dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
45-
if Dir.pwd == dir
46-
options.pres_dir = dir + '/example'
43+
showoff_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
44+
if Dir.pwd == showoff_dir
45+
options.pres_dir = "#{showoff_dir}/example"
4746
@root_path = "."
4847
else
49-
options.pres_dir = Dir.pwd
48+
options.pres_dir ||= Dir.pwd
5049
@root_path = ".."
5150
end
51+
options.pres_dir = File.expand_path(options.pres_dir)
52+
if (options.pres_file)
53+
puts "Using #{options.pres_file}"
54+
ShowOffUtils.presentation_config_file = options.pres_file
55+
end
56+
puts "Serving presentation from #{options.pres_dir}"
5257
@cached_image_size = {}
53-
puts options.pres_dir
5458
@pres_name = options.pres_dir.split('/').pop
5559
require_ruby_files
5660
end
@@ -81,6 +85,12 @@ def preshow_files
8185
end
8286

8387
def process_markdown(name, content, static=false, pdf=false)
88+
89+
# if there are no !SLIDE markers, then make every H1 define a new slide
90+
unless content =~ /^\<?!SLIDE/m
91+
content = content.gsub(/^# /m, "<!SLIDE bullets>\n# ")
92+
end
93+
8494
slides = content.split(/^<?!SLIDE/)
8595
slides.delete('')
8696
final = ''
@@ -101,9 +111,6 @@ def process_markdown(name, content, static=false, pdf=false)
101111
# extract id, defaulting to none
102112
id = nil
103113
content_classes.delete_if { |x| x =~ /^#([\w-]+)/ && id = $1 }
104-
puts "id: #{id}" if id
105-
puts "classes: #{content_classes.inspect}"
106-
puts "transition: #{transition}"
107114
# create html
108115
md += "<div"
109116
md += " id=\"#{id}\"" if id

0 commit comments

Comments
 (0)