deckrb 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +38 -10
- data/bin/deck +11 -4
- data/lib/deck/rack_app.rb +42 -22
- data/lib/deck/slide.rb +5 -4
- data/lib/deck/slide_deck.rb +142 -135
- data/lib/deck/version.rb +1 -1
- data/public/deck.js/GPL-license.txt +0 -0
- data/public/deck.js/MIT-license.txt +0 -0
- data/public/deck.js/README.md +10 -4
- data/public/deck.js/boilerplate.html +96 -0
- data/public/deck.js/core/deck.core.css +10 -7
- data/public/deck.js/core/deck.core.js +5 -5
- data/public/deck.js/core/deck.core.scss +10 -7
- data/public/deck.js/extensions/goto/deck.goto.css +0 -0
- data/public/deck.js/extensions/goto/deck.goto.html +0 -0
- data/public/deck.js/extensions/goto/deck.goto.js +0 -0
- data/public/deck.js/extensions/hash/deck.hash.css +0 -0
- data/public/deck.js/extensions/hash/deck.hash.html +0 -0
- data/public/deck.js/extensions/hash/deck.hash.js +16 -3
- data/public/deck.js/extensions/hash/deck.hash.scss +0 -0
- data/public/deck.js/extensions/menu/deck.menu.css +0 -0
- data/public/deck.js/extensions/menu/deck.menu.js +0 -0
- data/public/deck.js/extensions/navigation/deck.navigation.css +0 -0
- data/public/deck.js/extensions/navigation/deck.navigation.html +0 -0
- data/public/deck.js/extensions/navigation/deck.navigation.js +4 -3
- data/public/deck.js/extensions/scale/deck.scale.css +4 -1
- data/public/deck.js/extensions/scale/deck.scale.js +0 -0
- data/public/deck.js/extensions/scale/deck.scale.scss +5 -1
- data/public/deck.js/extensions/status/deck.status.css +0 -0
- data/public/deck.js/extensions/status/deck.status.html +0 -0
- data/public/deck.js/extensions/status/deck.status.js +0 -0
- data/public/deck.js/introduction/index.html +8 -2
- data/public/deck.js/jquery-1.7.2.min.js +4 -0
- data/public/deck.js/modernizr.custom.js +0 -0
- data/public/deck.js/test/fixtures/complex.html +0 -0
- data/public/deck.js/test/fixtures/empty.html +0 -0
- data/public/deck.js/test/fixtures/iframe_simple.html +0 -0
- data/public/deck.js/test/fixtures/iframes.html +0 -0
- data/public/deck.js/test/fixtures/nesteds.html +0 -0
- data/public/deck.js/test/fixtures/standard.html +0 -0
- data/public/deck.js/test/index.html +1 -1
- data/public/deck.js/test/spec.core.js +3 -1
- data/public/deck.js/test/spec.goto.js +0 -0
- data/public/deck.js/test/spec.hash.js +2 -2
- data/public/deck.js/test/spec.menu.js +0 -0
- data/public/deck.js/test/spec.navigation.js +4 -4
- data/public/deck.js/test/spec.scale.js +0 -0
- data/public/deck.js/test/spec.status.js +0 -0
- data/public/deck.js/themes/style/neon.css +7 -1
- data/public/deck.js/themes/style/neon.scss +11 -1
- data/public/deck.js/themes/style/swiss.css +7 -1
- data/public/deck.js/themes/style/swiss.scss +11 -1
- data/public/deck.js/themes/style/web-2.0.css +7 -1
- data/public/deck.js/themes/style/web-2.0.scss +11 -1
- data/public/deck.js/themes/transition/fade.css +0 -0
- data/public/deck.js/themes/transition/fade.scss +0 -0
- data/public/deck.js/themes/transition/horizontal-slide.css +0 -0
- data/public/deck.js/themes/transition/horizontal-slide.scss +0 -0
- data/public/deck.js/themes/transition/vertical-slide.css +0 -0
- data/public/deck.js/themes/transition/vertical-slide.scss +0 -0
- data/public/toc.css +60 -27
- data/spec/rack_app_spec.rb +45 -1
- data/spec/slide_deck_spec.rb +77 -43
- data/spec/slide_spec.rb +19 -0
- metadata +22 -8
- data/public/deck.js/core/deck.core.html +0 -39
- data/public/deck.js/extensions/theme-picker/deck.theme-picker.css +0 -55
- data/public/deck.js/extensions/theme-picker/deck.theme-picker.js +0 -13
- data/public/deck.js/jquery-1.7.min.js +0 -4
data/README.md
CHANGED
@@ -54,7 +54,8 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
|
|
54
54
|
* links to image files are resolved relative to the source file -- no more broken images in markdown previews, and no need to put all your images in a separate directory!
|
55
55
|
* add CSS classes to slides inside the slide directive - - e.g. `<!SLIDE center>` gives `<section class="slide center">`
|
56
56
|
* generated HTML is pretty-printed for easier "view source"
|
57
|
-
* uses deck.js' "swiss"
|
57
|
+
* uses deck.js' "swiss" and "horizontal-slide" themes (configurable)
|
58
|
+
* uses several deck.js extensions, including `goto`, `menu`, `navigation`, `status`, `hash`, and `scale`
|
58
59
|
* uses RedCarpet markdown extensions, including
|
59
60
|
* tables <http://michelf.com/projects/php-markdown/extra/#table>
|
60
61
|
* fenced code blocks <http://michelf.com/projects/php-markdown/extra/#fenced-code-blocks>
|
@@ -63,8 +64,9 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
|
|
63
64
|
* code syntax highlighting using Coderay
|
64
65
|
* specify language at the top of the block using either ::: or @@@
|
65
66
|
* e.g. `@@@ ruby`
|
66
|
-
* there's a simple table of contents (click the [
|
67
|
+
* there's a simple table of contents (click the [contents] link on lower left to toggle)
|
67
68
|
* this is currently very primitive and should be redone and/or integrated into deck.js
|
69
|
+
* lines beginning with `.notes ` are skipped
|
68
70
|
|
69
71
|
## Command-Line API
|
70
72
|
|
@@ -77,10 +79,30 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
|
|
77
79
|
|
78
80
|
### Options
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
--port, -p <i>: Specify alternate port (default: 4333)
|
83
|
+
--build, -b: Build an HTML file instead of launching a server (WARNING: not very useful yet)
|
84
|
+
--style, -s <s>: Specify the style theme from deck.js/themes/style/ (default: swiss)
|
85
|
+
--transition, -t <s>: Specify the transition theme from deck.js/themes/transition/ (default: horizontal-slide)
|
86
|
+
--version, -v: Print version and exit
|
87
|
+
--help, -h: Show this message
|
88
|
+
|
89
|
+
## Themes
|
90
|
+
|
91
|
+
`deck.js` has several themes for styling and animating your presentation.
|
92
|
+
You can select these from the command line or from a `showoff.json` file with the `style` and `transition` options.
|
93
|
+
Currently the following themes are available:
|
94
|
+
|
95
|
+
### Style Themes
|
96
|
+
|
97
|
+
* neon
|
98
|
+
* swiss
|
99
|
+
* web-2.0
|
100
|
+
|
101
|
+
### Transition Themes
|
102
|
+
|
103
|
+
* fade
|
104
|
+
* horizontal-slide
|
105
|
+
* vertical-slide
|
84
106
|
|
85
107
|
## Deploying to Heroku
|
86
108
|
|
@@ -101,20 +123,24 @@ and a `Gemfile` like this:
|
|
101
123
|
|
102
124
|
Then deploy to Heroku as usual (e.g. `heroku apps:create`).
|
103
125
|
|
104
|
-
|
126
|
+
Note that `Deck::RackApp.build` can accept either a filename or an array of filenames.
|
127
|
+
It also accepts options, e.g.
|
128
|
+
|
129
|
+
run Deck::RackApp.build('slides.md', transition: 'fade')
|
130
|
+
|
105
131
|
|
106
132
|
## Known Issues (Bugs and Limitations)
|
107
133
|
|
108
134
|
* If you're running Webrick, you may not be able to kill the server with Ctrl-C. This is apparently due to a bug in recent versions of Webrick.
|
109
135
|
* Workaround: `gem install thin` -- if thin is installed, deck will use it instead of webrick
|
110
|
-
*
|
136
|
+
* Auxiliary files (e.g. images) are interleaved in URL path space, so overlapping file names might not resolve to the right file.
|
111
137
|
* todo: rewrite internal links to files and serve them relative to current dir, not slide dir
|
112
138
|
* H1s (which split slides) are converted to H2s for compatibility with deck.js's CSS themes
|
113
139
|
* unless they're the only item on the slide, in which case they remain H1s
|
114
|
-
*
|
140
|
+
* We use RedCarpet to process markdown, which doesn't work exactly the same as RDiscount... for example:
|
115
141
|
* indented code blocks under a bullet point may need to be indented more
|
116
142
|
* code blocks must be separated from the previous text by a newline
|
117
|
-
*
|
143
|
+
* Slide scaling isn't perfect; sometimes either resizing or reloading will improve the layout.
|
118
144
|
|
119
145
|
Report bugs on <http://github.com/alexch/deck.rb/issues>
|
120
146
|
|
@@ -123,6 +149,8 @@ Report bugs on <http://github.com/alexch/deck.rb/issues>
|
|
123
149
|
* deck.js by Caleb at <http://imakewebthings.com>
|
124
150
|
* deck.rb by Alex Chaffee <http://alexchaffee.com>, with help from
|
125
151
|
* Steven! Ragnarök <http://nuclearsandwich.com>
|
152
|
+
* David Doolin <http://dool.in>
|
153
|
+
* and other awesome patchers
|
126
154
|
|
127
155
|
### See Also
|
128
156
|
|
data/bin/deck
CHANGED
@@ -8,6 +8,7 @@ require "rack"
|
|
8
8
|
require "deck"
|
9
9
|
require "deck/rack_app"
|
10
10
|
require "deck/version"
|
11
|
+
require "thin" # i hate webrick
|
11
12
|
|
12
13
|
options = Trollop.options do
|
13
14
|
version "deck v#{Deck::VERSION}"
|
@@ -16,9 +17,11 @@ options = Trollop.options do
|
|
16
17
|
banner "(see http://github.com/alexch/deck.rb README for more help)"
|
17
18
|
opt :port, "Specify alternate port", :default => 4333
|
18
19
|
opt :build, "Build an HTML file instead of launching a server (WARNING: not very useful yet)"
|
20
|
+
opt :style, "Specify the style theme from deck.js/themes/style/", default: "swiss"
|
21
|
+
opt :transition, "Specify the transition theme from deck.js/themes/transition/", default: "horizontal-slide"
|
19
22
|
end
|
20
23
|
|
21
|
-
if options
|
24
|
+
if options.delete(:build)
|
22
25
|
slides = []
|
23
26
|
output_path = nil
|
24
27
|
output_dir = "." # for now, since deck.js is relative to the project root
|
@@ -31,14 +34,18 @@ if options[:build]
|
|
31
34
|
end
|
32
35
|
|
33
36
|
File.open(output_path, "w") do |file|
|
34
|
-
deck = Deck::SlideDeck.new :slides => slides
|
37
|
+
deck = Deck::SlideDeck.new :slides => slides #todo: pass theme options
|
35
38
|
# deck.to_pretty(:output => file) # todo: figure out why this doesn't work
|
36
39
|
file.write deck.to_pretty
|
37
40
|
end
|
38
41
|
|
39
42
|
else
|
40
43
|
|
41
|
-
port = options
|
44
|
+
port = options.delete(:port)
|
42
45
|
slide_files = ARGV
|
43
|
-
|
46
|
+
options = {
|
47
|
+
style: options[:style],
|
48
|
+
transition: options[:transition],
|
49
|
+
}
|
50
|
+
Rack::Handler.default.run Deck::RackApp.build(slide_files, options), :Port => port
|
44
51
|
end
|
data/lib/deck/rack_app.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
here = File.expand_path File.dirname(__FILE__)
|
2
|
-
|
3
1
|
require 'json'
|
4
2
|
require 'coderay'
|
5
3
|
require 'rack/codehighlighter'
|
@@ -16,12 +14,8 @@ module Deck
|
|
16
14
|
Rack::File.new("#{app_root}/public")
|
17
15
|
end
|
18
16
|
|
19
|
-
def self.build slide_files
|
20
|
-
|
21
|
-
if require "thin/logging"
|
22
|
-
Thin::Logging.debug = true
|
23
|
-
end
|
24
|
-
end
|
17
|
+
def self.build slide_files, options = {}
|
18
|
+
enable_thin_logging()
|
25
19
|
|
26
20
|
Rack::Builder.app do
|
27
21
|
use Rack::ShowExceptions
|
@@ -30,25 +24,24 @@ module Deck
|
|
30
24
|
:element => "pre>code",
|
31
25
|
:markdown => true,
|
32
26
|
:pattern => /\A[:@]{3}\s?(\w+)\s*(\n|
)/i
|
33
|
-
run ::Deck::RackApp.new(slide_files)
|
27
|
+
run ::Deck::RackApp.new(slide_files, options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.enable_thin_logging
|
32
|
+
if const_defined?(:Thin)
|
33
|
+
if require "thin/logging"
|
34
|
+
Thin::Logging.debug = true
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
|
-
def initialize slide_files
|
39
|
+
def initialize slide_files, options = {}
|
40
|
+
@options = options
|
38
41
|
@slide_files = [slide_files].flatten.map do |slide_file|
|
39
42
|
case slide_file
|
40
43
|
when /\/?showoff(.*)\.json$/
|
41
|
-
|
42
|
-
json_file = slide_file
|
43
|
-
config = JSON.parse(File.read(json_file))
|
44
|
-
config['sections'].map do |markdown_file|
|
45
|
-
if markdown_file =~ /^# / # you can use literal markdown instead of a file name
|
46
|
-
s = Slide.split(markdown_file)
|
47
|
-
s
|
48
|
-
else
|
49
|
-
File.new(json_file_dir + '/' + markdown_file)
|
50
|
-
end
|
51
|
-
end
|
44
|
+
parse_showoff_json(slide_file)
|
52
45
|
else
|
53
46
|
File.new(slide_file)
|
54
47
|
end
|
@@ -63,6 +56,33 @@ module Deck
|
|
63
56
|
end
|
64
57
|
end
|
65
58
|
|
59
|
+
def parse_showoff_json(slide_file)
|
60
|
+
json_file_dir = File.expand_path(File.dirname(slide_file))
|
61
|
+
json_file = slide_file
|
62
|
+
config = JSON.parse(File.read(json_file))
|
63
|
+
extract_options(config)
|
64
|
+
extract_slides(config, json_file_dir)
|
65
|
+
end
|
66
|
+
|
67
|
+
def extract_slides(config, json_file_dir)
|
68
|
+
config['sections'].map do |markdown_file|
|
69
|
+
if markdown_file =~ /^# / # you can use literal markdown instead of a file name
|
70
|
+
s = Slide.split(markdown_file)
|
71
|
+
s
|
72
|
+
else
|
73
|
+
File.new(json_file_dir + '/' + markdown_file)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def extract_options(config)
|
79
|
+
["style", "transition"].each do |key|
|
80
|
+
if config[key] and !@options[key.to_sym]
|
81
|
+
@options[key.to_sym] = config[key]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
66
86
|
def call env
|
67
87
|
request = Rack::Request.new(env)
|
68
88
|
if request.path == "/"
|
@@ -78,7 +98,7 @@ module Deck
|
|
78
98
|
end
|
79
99
|
|
80
100
|
def deck
|
81
|
-
SlideDeck.new
|
101
|
+
SlideDeck.new({:slides => slides}.merge(@options))
|
82
102
|
end
|
83
103
|
|
84
104
|
def slides
|
data/lib/deck/slide.rb
CHANGED
@@ -35,6 +35,9 @@ module Deck
|
|
35
35
|
slides << (slide = Slide.new)
|
36
36
|
slide << line
|
37
37
|
|
38
|
+
elsif line =~ /^\.notes/
|
39
|
+
# don't include notes
|
40
|
+
|
38
41
|
else
|
39
42
|
slide << line
|
40
43
|
end
|
@@ -107,16 +110,14 @@ module Deck
|
|
107
110
|
end
|
108
111
|
|
109
112
|
def title
|
110
|
-
lines = @markdown_text.split("\n")
|
113
|
+
lines = @markdown_text.strip.split("\n")
|
111
114
|
raise "an empty slide has no id" if lines.empty?
|
112
115
|
lines.first.gsub(/^[#=]*/, '').strip
|
113
116
|
end
|
114
117
|
|
115
118
|
def slide_id
|
116
119
|
@slide_id ||= begin
|
117
|
-
|
118
|
-
raise "an empty slide has no id" if lines.empty?
|
119
|
-
lines.first.downcase.gsub(/[^\w\s]/, '').strip.gsub(/\s/, '_')
|
120
|
+
title.downcase.gsub(/[^\w\s]/, '').strip.gsub(/\s/, '_')
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
data/lib/deck/slide_deck.rb
CHANGED
@@ -4,31 +4,34 @@ require 'redcarpet'
|
|
4
4
|
require "deck/slide"
|
5
5
|
|
6
6
|
module Deck
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# 'theme-picker',
|
7
|
+
class SlideDeck < Erector::Widgets::Page
|
8
|
+
needs :title => "deck.rb presentation",
|
9
|
+
:description => nil,
|
10
|
+
:author => nil
|
11
|
+
needs :extensions => [
|
12
|
+
'goto',
|
13
|
+
'menu',
|
14
|
+
'navigation',
|
15
|
+
'status',
|
16
|
+
'hash',
|
17
|
+
'scale',
|
19
18
|
]
|
20
|
-
|
21
|
-
attr_reader :extensions
|
19
|
+
needs :slides => nil
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
21
|
+
needs :style => "swiss"
|
22
|
+
needs :transition => "horizontal-slide"
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
attr_reader :extensions
|
25
|
+
|
26
|
+
def page_title
|
27
|
+
@title
|
28
|
+
end
|
29
|
+
|
30
|
+
# todo: promote into Text
|
31
|
+
# todo: support numbers a la 'Ӓ'
|
32
|
+
def entity entity_id
|
33
|
+
raw("&#{entity_id};")
|
34
|
+
end
|
32
35
|
|
33
36
|
# left over from deck.js' introduction/index.html
|
34
37
|
|
@@ -38,155 +41,159 @@ module Deck
|
|
38
41
|
# <!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]-->
|
39
42
|
# <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def public_asset path
|
47
|
-
"/#{path}"
|
48
|
-
end
|
49
|
-
|
50
|
-
def head_content
|
51
|
-
super
|
52
|
-
meta 'charset' => 'utf-8'
|
53
|
-
meta 'http-equiv'=>"X-UA-Compatible", 'content'=>"IE=edge,chrome=1"
|
54
|
-
meta :name => "viewport", :content=> "width=1024, user-scalable=no"
|
55
|
-
meta :name => "description", :content=> @description if @description
|
56
|
-
meta :name => "author", :content=> @author if @author
|
44
|
+
# todo: promote into Page
|
45
|
+
def stylesheet src, attributes = {}
|
46
|
+
link({:rel => "stylesheet", :href => src}.merge(attributes))
|
47
|
+
end
|
57
48
|
|
58
|
-
|
59
|
-
|
60
|
-
extensions.each do |extension|
|
61
|
-
stylesheet public_asset("deck.js/extensions/#{extension}/deck.#{extension}.css")
|
49
|
+
def public_asset path
|
50
|
+
"/#{path}"
|
62
51
|
end
|
63
52
|
|
64
|
-
|
65
|
-
|
53
|
+
def head_content
|
54
|
+
super
|
55
|
+
meta 'charset' => 'utf-8'
|
56
|
+
meta 'http-equiv' => "X-UA-Compatible", 'content' => "IE=edge,chrome=1"
|
57
|
+
meta :name => "viewport", :content => "width=1024, user-scalable=no"
|
58
|
+
meta :name => "description", :content => @description if @description
|
59
|
+
meta :name => "author", :content => @author if @author
|
60
|
+
|
61
|
+
# <!-- Core and extension CSS files -->
|
62
|
+
stylesheet public_asset("deck.js/core/deck.core.css")
|
63
|
+
extensions.each do |extension|
|
64
|
+
stylesheet public_asset("deck.js/extensions/#{extension}/deck.#{extension}.css")
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
# <!-- Theme CSS files -->
|
68
|
+
stylesheet public_asset("deck.js/themes/style/#{@style}.css"), :id => "style-theme-link"
|
69
|
+
stylesheet public_asset("deck.js/themes/transition/#{@transition}.css"), :id => "transition-theme-link"
|
70
|
+
|
71
|
+
stylesheet public_asset("coderay.css")
|
72
|
+
stylesheet public_asset("tables.css")
|
73
|
+
stylesheet public_asset("toc.css")
|
74
|
+
end
|
71
75
|
|
72
|
-
|
73
|
-
|
76
|
+
def scripts
|
77
|
+
script :src => public_asset("deck.js/modernizr.custom.js")
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
# comment 'Grab CDN jQuery, with a protocol relative URL; fall back to local if offline'
|
80
|
+
# script :src => '//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js'
|
81
|
+
script :src => public_asset('deck.js/jquery-1.7.2.min.js')
|
78
82
|
|
79
|
-
|
83
|
+
jquery <<-JAVASCRIPT
|
80
84
|
$('.slide_toc .toggle').click(function(){
|
81
|
-
$('.slide_toc
|
85
|
+
$('.slide_toc .table').toggle();
|
82
86
|
});
|
83
|
-
|
87
|
+
JAVASCRIPT
|
84
88
|
|
85
|
-
|
86
|
-
|
89
|
+
comment 'Deck Core and extensions'
|
90
|
+
script :type => "text/javascript", :src => public_asset('deck.js/core/deck.core.js')
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
|
92
|
+
extensions.each do |extension|
|
93
|
+
script :type => "text/javascript", :src => public_asset("deck.js/extensions/#{extension}/deck.#{extension}.js")
|
94
|
+
end
|
91
95
|
|
92
|
-
|
93
|
-
|
96
|
+
# fire up deck.js
|
97
|
+
script "$(function(){$.deck('.slide');});"
|
94
98
|
|
95
|
-
|
96
|
-
|
97
|
-
def body_attributes
|
98
|
-
{:class=>"deck-container"}
|
99
|
-
end
|
99
|
+
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
toc
|
105
|
-
deck_status
|
106
|
-
goto_slide
|
107
|
-
permalink
|
108
|
-
scripts
|
109
|
-
end
|
101
|
+
def body_attributes
|
102
|
+
{:class => "deck-container"}
|
103
|
+
end
|
110
104
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
105
|
+
def body_content
|
106
|
+
slides
|
107
|
+
slide_navigation
|
108
|
+
toc
|
109
|
+
deck_status
|
110
|
+
goto_slide
|
111
|
+
permalink
|
112
|
+
scripts
|
116
113
|
end
|
117
|
-
end
|
118
114
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
def slide slide_id
|
116
|
+
# todo: use Slide object, but without markdown
|
117
|
+
# slide = Slide.new(:slide_id => slide_id)
|
118
|
+
section.slide :id => slide_id do
|
119
|
+
yield
|
123
120
|
end
|
124
|
-
else
|
125
|
-
default_slide
|
126
121
|
end
|
127
|
-
end
|
128
122
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
pre "erector --to-html ./deck.rb # generates deck.html"
|
123
|
+
def slides
|
124
|
+
if @slides
|
125
|
+
@slides.each do |slide|
|
126
|
+
widget slide
|
127
|
+
end
|
128
|
+
else
|
129
|
+
default_slide
|
130
|
+
end
|
138
131
|
end
|
139
|
-
end
|
140
132
|
|
141
|
-
|
142
|
-
|
143
|
-
|
133
|
+
def default_slide
|
134
|
+
slide 'readme' do
|
135
|
+
h2 "deck.rb"
|
136
|
+
ul {
|
137
|
+
li "based on deck.js"
|
138
|
+
li "create a subclass of Deck (see introduction.rb)"
|
139
|
+
li "run erector to build it"
|
140
|
+
}
|
141
|
+
pre "erector --to-html ./deck.rb # generates deck.html"
|
142
|
+
end
|
144
143
|
end
|
145
|
-
|
146
|
-
|
144
|
+
|
145
|
+
def slide_navigation
|
146
|
+
a :href => '#', :class => 'deck-prev-link', :title => 'Previous' do
|
147
|
+
character 8592
|
148
|
+
end
|
149
|
+
a :href => '#', :class => 'deck-next-link', :title => 'Next' do
|
150
|
+
character 8594
|
151
|
+
end
|
147
152
|
end
|
148
|
-
end
|
149
153
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
154
|
+
def toc
|
155
|
+
div.slide_toc do
|
156
|
+
div.toggle "[contents]"
|
157
|
+
div.table do
|
158
|
+
h2 @title
|
159
|
+
ul do
|
160
|
+
if @slides
|
161
|
+
@slides.each do |slide|
|
162
|
+
li do
|
163
|
+
a slide.title, :href => "##{slide.slide_id}"
|
164
|
+
end
|
165
|
+
end
|
158
166
|
end
|
159
167
|
end
|
160
168
|
end
|
161
169
|
end
|
162
170
|
end
|
163
|
-
end
|
164
171
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
172
|
+
def deck_status
|
173
|
+
p :class => 'deck-status' do
|
174
|
+
span :class => 'deck-status-current' do
|
175
|
+
end
|
176
|
+
text '/'
|
177
|
+
span :class => 'deck-status-total' do
|
178
|
+
end
|
171
179
|
end
|
172
180
|
end
|
173
|
-
end
|
174
181
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
+
def goto_slide
|
183
|
+
form :action => '.', :method => 'get', :class => 'goto-form' do
|
184
|
+
label :for => 'goto-slide' do
|
185
|
+
text 'Go to slide:'
|
186
|
+
end
|
187
|
+
input :type => 'text', :name => 'slidenum', :id => 'goto-slide', :list => 'goto-datalist'
|
188
|
+
datalist :id => 'goto-datalist' do
|
182
189
|
end
|
183
|
-
|
190
|
+
input :type => 'submit', :value => 'Go'
|
191
|
+
end
|
184
192
|
end
|
185
|
-
end
|
186
193
|
|
187
|
-
|
188
|
-
|
189
|
-
|
194
|
+
def permalink
|
195
|
+
a "#", :href => '.', :title => 'Permalink to this slide', :class => 'deck-permalink'
|
196
|
+
end
|
190
197
|
|
191
|
-
|
198
|
+
end
|
192
199
|
end
|