deckrb 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -62,6 +62,8 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
62
62
  * code syntax highlighting using Coderay
63
63
  * specify language at the top of the block using either ::: or @@@
64
64
  * e.g. `@@@ ruby`
65
+ * there's a simple table of contents (click the [toc] link on lower left to toggle)
66
+ * this is currently very primitive and should be redone and/or integrated into deck.js
65
67
 
66
68
  ## Command-Line API
67
69
 
@@ -79,6 +81,13 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
79
81
  --version, -v: Print version and exit
80
82
  --help, -h: Show this message
81
83
 
84
+ ## Known Issues
85
+
86
+ * If you're running Webrick, you may not be able to kill the server with Ctrl-C. This is a bug in recent versions of Webrick.
87
+ * Workaround: `gem install thin` -- if thin is installed, deck will use it instead of webrick
88
+
89
+ Report bugs on <http://github.com/alexch/deck.rb/issues>
90
+
82
91
  ## Credits
83
92
 
84
93
  * deck.js by Caleb at <http://imakewebthings.com>
@@ -140,6 +149,10 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
140
149
  * rewrite internal links to files and serve them relative to current dir, not slide dir
141
150
  * custom `.css`, `.scss`, and `.js` files, which will get imported into all slides
142
151
  * support some more extensions https://github.com/imakewebthings/deck.js/wiki
152
+ * improve table of contents
153
+ * nested sections
154
+ * disappear when clicked outside of, esc pressed, etc.
155
+ * close box
143
156
 
144
157
  ## TODO (community)
145
158
 
@@ -147,6 +160,7 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
147
160
  * mix with keydown https://github.com/infews/keydown
148
161
  * gh-pages documentation site
149
162
  * integrate with slideshow https://github.com/geraldb/slideshow-deck.js
163
+ * make it a proper Rack middleware thingy and add to https://github.com/rack/rack/wiki/List-of-Middleware
150
164
 
151
165
  # License
152
166
 
data/bin/deck CHANGED
@@ -27,11 +27,11 @@ if options[:build]
27
27
  # output_dir ||= File.dirname(arg)
28
28
  basename ||= File.basename(arg, ".md")
29
29
  output_path ||= "#{output_dir}/#{basename}.html"
30
- slides += Slide.from_file arg
30
+ slides += Deck::Slide.from_file arg
31
31
  end
32
32
 
33
33
  File.open(output_path, "w") do |file|
34
- deck = SlideDeck.new :slides => slides
34
+ deck = Deck::SlideDeck.new :slides => slides
35
35
  # deck.to_pretty(:output => file) # todo: figure out why this doesn't work
36
36
  file.write deck.to_pretty
37
37
  end
data/lib/deck/slide.rb CHANGED
@@ -101,6 +101,12 @@ module Deck
101
101
  @markdown_text.strip == ""
102
102
  end
103
103
 
104
+ def title
105
+ lines = @markdown_text.split("\n")
106
+ raise "an empty slide has no id" if lines.empty?
107
+ lines.first.gsub(/^[#=]*/, '').strip
108
+ end
109
+
104
110
  def slide_id
105
111
  @slide_id ||= begin
106
112
  lines = @markdown_text.split("\n")
@@ -55,8 +55,6 @@ module Deck
55
55
  meta :name => "description", :content=> @description if @description
56
56
  meta :name => "author", :content=> @author if @author
57
57
 
58
- stylesheet public_asset("coderay.css")
59
-
60
58
  # <!-- Core and extension CSS files -->
61
59
  stylesheet public_asset("deck.js/core/deck.core.css")
62
60
  extensions.each do |extension|
@@ -65,6 +63,10 @@ module Deck
65
63
 
66
64
  # <!-- Theme CSS files (menu swaps these out) -->
67
65
  stylesheet public_asset("deck.js/themes/style/swiss.css"), :id=>"style-theme-link"
66
+
67
+ stylesheet public_asset("coderay.css")
68
+ stylesheet public_asset("tables.css")
69
+ stylesheet public_asset("toc.css")
68
70
  end
69
71
 
70
72
  def scripts
@@ -74,6 +76,12 @@ module Deck
74
76
  # script :src => '//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js'
75
77
  script :src => public_asset('deck.js/jquery-1.7.min.js')
76
78
 
79
+ jquery <<-JAVASCRIPT
80
+ $('.slide_toc .toggle').click(function(){
81
+ $('.slide_toc ul').toggle();
82
+ });
83
+ JAVASCRIPT
84
+
77
85
  comment 'Deck Core and extensions'
78
86
  script :type => "text/javascript", :src => public_asset('deck.js/core/deck.core.js')
79
87
 
@@ -93,6 +101,7 @@ module Deck
93
101
  def body_content
94
102
  slides
95
103
  slide_navigation
104
+ toc
96
105
  deck_status
97
106
  goto_slide
98
107
  permalink
@@ -138,6 +147,21 @@ module Deck
138
147
  end
139
148
  end
140
149
 
150
+ def toc
151
+ div.slide_toc do
152
+ div.toggle "[toc]"
153
+ ul do
154
+ if @slides
155
+ @slides.each do |slide|
156
+ li do
157
+ a slide.title, :href => "##{slide.slide_id}"
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
164
+
141
165
  def deck_status
142
166
  p :class => 'deck-status' do
143
167
  span :class => 'deck-status-current' do
data/lib/deck/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Deck
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/public/tables.css ADDED
@@ -0,0 +1,29 @@
1
+ .slide table {
2
+ display: table;
3
+ border-collapse: collapse;
4
+ border-spacing: 2px;
5
+ border-color: gray;
6
+ margin: 15px 0;
7
+ }
8
+
9
+ .slide table tr {
10
+ border-top: 1px solid #CCC;
11
+ background-color: white;
12
+ margin: 0;
13
+ padding: 0;
14
+ }
15
+
16
+ .slide table tr th, .slide table tr td {
17
+ border: 1px solid #CCC;
18
+ text-align: left;
19
+ margin: 0;
20
+ padding: 6px 13px;
21
+ }
22
+
23
+ .slide table thead tr {
24
+ background-color: #F2F2F8;
25
+ }
26
+
27
+ .slide table tr:nth-child(2n) {
28
+ background-color: #F8F8F8;
29
+ }
data/public/toc.css ADDED
@@ -0,0 +1,37 @@
1
+ .deck-container .slide_toc {
2
+ position:fixed;
3
+ bottom:4px;
4
+ left:4px;
5
+ height: 80%;
6
+ color:#888;
7
+ z-index:3;
8
+ margin:0;
9
+ }
10
+
11
+ .deck-container .slide_toc .toggle {
12
+ position: absolute;
13
+ bottom: 0px;
14
+ cursor: pointer;
15
+ }
16
+
17
+ .deck-container .slide_toc ul {
18
+ display: none;
19
+ position: absolute;
20
+ width: 20em;
21
+ bottom: 1em;
22
+
23
+ border: 1px solid black;
24
+ padding: 4px;
25
+ margin: 4px 0 2em;
26
+ background: white;
27
+ overflow-y: auto;
28
+ color: black;
29
+
30
+ height: 100%;
31
+ }
32
+
33
+ @media print {
34
+ .slide_toc {
35
+ display:none;
36
+ }
37
+ }
@@ -41,5 +41,19 @@ module Deck
41
41
  }
42
42
  end
43
43
 
44
+ it "includes a table of contents" do
45
+ deck_widget :slides => Slide.split("# Foo\n\n# Bar\n")
46
+ toc = doc.css('.slide_toc')
47
+ assert { toc.size == 1 }
48
+ assert { noko_html(toc.first) == "<div class=\"slide_toc\">" +
49
+ "<div class=\"toggle\">[toc]</div>" +
50
+ "<ul>" +
51
+ "<li><a href=\"#foo\">Foo</a></li>" +
52
+ "<li><a href=\"#bar\">Bar</a></li>" +
53
+ "</ul>" +
54
+ "</div>"
55
+ }
56
+ end
57
+
44
58
  end
45
59
  end
data/spec/slide_spec.rb CHANGED
@@ -180,7 +180,7 @@ Two
180
180
  Slide.split(markdown_text).first
181
181
  end
182
182
 
183
- describe "sets the slide's id" do
183
+ describe "has an id" do
184
184
  it "based on the first header" do
185
185
  assert { slide_from("# foo").slide_id == "foo" }
186
186
  end
@@ -195,6 +195,20 @@ Two
195
195
  end
196
196
  end
197
197
 
198
+ describe "has a title" do
199
+ it "based on the first header" do
200
+ assert { slide_from("# Foo").title == "Foo" }
201
+ end
202
+
203
+ it "preserves punctuation" do
204
+ assert { slide_from("# Don't tread on me!").title == "Don't tread on me!" }
205
+ end
206
+
207
+ it "strips whitespace" do
208
+ assert { slide_from("# hi there ").title == "hi there" }
209
+ end
210
+ end
211
+
198
212
  describe "renders deck.js-compatible HTML" do
199
213
  it "leaves a solo H1 as an H1" do
200
214
  html = slide_from(<<-MARKDOWN).to_pretty
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deckrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000 Z
12
+ date: 2012-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erector
@@ -224,6 +224,8 @@ files:
224
224
  - public/deck.js/themes/transition/vertical-slide.css
225
225
  - public/deck.js/themes/transition/vertical-slide.scss
226
226
  - public/favicon.ico
227
+ - public/tables.css
228
+ - public/toc.css
227
229
  - README.md
228
230
  - spec/javascripts/support/jasmine_config.rb
229
231
  - spec/javascripts/support/jasmine_runner.rb
@@ -247,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
249
  version: '0'
248
250
  segments:
249
251
  - 0
250
- hash: 1200341781470137723
252
+ hash: 1497059126395334120
251
253
  required_rubygems_version: !ruby/object:Gem::Requirement
252
254
  none: false
253
255
  requirements:
@@ -256,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
258
  version: '0'
257
259
  segments:
258
260
  - 0
259
- hash: 1200341781470137723
261
+ hash: 1497059126395334120
260
262
  requirements: []
261
263
  rubyforge_project:
262
264
  rubygems_version: 1.8.21