deckrb 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,7 +29,7 @@ Put this in a file named `meals.md`:
29
29
 
30
30
  then run this:
31
31
 
32
- deck run meals.md
32
+ deck meals.md
33
33
 
34
34
  and you'll get a web server running on `http://localhost:4333` serving up a slide presentation with four slides:
35
35
 
@@ -65,30 +65,19 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
65
65
 
66
66
  ## Command-Line API
67
67
 
68
- `deck run foo.md`
68
+ `deck foo.md`
69
69
 
70
70
  * start a local Rack server (probably Sinatra) on port 4333
71
71
  * http://localhost:4333/ serves the presentation built from `foo.md`
72
72
  * can specify multiple source files in a row
73
73
  * can also specify a showoff.json file to load multiple markdown files
74
74
 
75
- `deck build foo.md`
76
-
77
- * creates a static page `foo.html` in the current directory
78
- * unfortunately the `deck.js` source code will not be around so this won't really work yet
79
-
80
75
  ### Options
81
76
 
82
- * none yet :-)
83
-
84
- ## Command-Line API (proposed)
85
-
86
- `deck build foo.md`
87
-
88
- * create a static site
89
- * default output dir = ./public (even if foo.md is elsewhere)
90
- * copies (or inlines) deck.js source
91
- * also copies (or inlines) "img" directory if it exists
77
+ --port, -p <i>: Specify alternate port (default: 4333)
78
+ --build, -b: Build an HTML file instead of launching a server (WARNING: not very useful yet)
79
+ --version, -v: Print version and exit
80
+ --help, -h: Show this message
92
81
 
93
82
  ## Credits
94
83
 
@@ -130,7 +119,6 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
130
119
  * command-line options (overriding or complementing config file options)
131
120
  * --output dir
132
121
  * --config deck.json
133
- * --port portnum
134
122
  * --theme themename
135
123
  * more slide file types
136
124
  * Erector - `foo/bar_bar.rb` would expect `class BarBar < Deck::Slide` in there
@@ -139,7 +127,10 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
139
127
  * haml
140
128
  * tilt
141
129
  * option to render all JS and CSS inline, for a self-contained HTML doc
142
- * and maybe images too, base64-encoded
130
+ * `deck --build dir foo.md`
131
+ * create a self-contained static site inside dir
132
+ * copies (or inlines) deck.js source, generated html, and axiliary files e.g. images
133
+ * hell, maybe it should inline everything *including* images (using those base64 urls or whatever) into a single HTML file
143
134
  * build and push into a gh-pages branch
144
135
  * build and push into a heroku app
145
136
  * find any lines that start with a <p>.(something) and turn them into <p class="something">
@@ -156,3 +147,30 @@ and you'll get a web server running on `http://localhost:4333` serving up a slid
156
147
  * mix with keydown https://github.com/infews/keydown
157
148
  * gh-pages documentation site
158
149
  * integrate with slideshow https://github.com/geraldb/slideshow-deck.js
150
+
151
+ # License
152
+
153
+ The MIT License
154
+
155
+ deck.js Copyright (c) 2011 Caleb Troughton
156
+
157
+ deck.rb Copyright (c) 2011-12 Alex Chaffee
158
+
159
+ Permission is hereby granted, free of charge, to any person obtaining a copy
160
+ of this software and associated documentation files (the "Software"), to deal
161
+ in the Software without restriction, including without limitation the rights
162
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
163
+ copies of the Software, and to permit persons to whom the Software is
164
+ furnished to do so, subject to the following conditions:
165
+
166
+ The above copyright notice and this permission notice shall be included in
167
+ all copies or substantial portions of the Software.
168
+
169
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
170
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
171
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
172
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
173
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
174
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
175
+ THE SOFTWARE.
176
+
data/bin/deck CHANGED
@@ -12,15 +12,13 @@ require "deck/version"
12
12
  options = Trollop.options do
13
13
  version "deck v#{Deck::VERSION}"
14
14
  banner version
15
- banner "Usage: deck [options] run [slides]"
15
+ banner "Usage: deck [options] [slides]"
16
+ banner "(see http://github.com/alexch/deck.rb README for more help)"
16
17
  opt :port, "Specify alternate port", :default => 4333
18
+ opt :build, "Build an HTML file instead of launching a server (WARNING: not very useful yet)"
17
19
  end
18
20
 
19
- command = ARGV.shift
20
-
21
- case command
22
- when 'build'
23
-
21
+ if options[:build]
24
22
  slides = []
25
23
  output_path = nil
26
24
  output_dir = "." # for now, since deck.js is relative to the project root
@@ -29,7 +27,6 @@ when 'build'
29
27
  # output_dir ||= File.dirname(arg)
30
28
  basename ||= File.basename(arg, ".md")
31
29
  output_path ||= "#{output_dir}/#{basename}.html"
32
-
33
30
  slides += Slide.from_file arg
34
31
  end
35
32
 
@@ -39,24 +36,11 @@ when 'build'
39
36
  file.write deck.to_pretty
40
37
  end
41
38
 
42
- when 'run'
43
-
39
+ else
40
+
44
41
  # Fix Rack bug https://github.com/rack/rack/issues/301
45
42
  require 'deck/rack_static_patch'
46
-
47
43
  port = options[:port]
48
44
  slide_files = ARGV
49
45
  Rack::Handler.default.run Deck::RackApp.build(slide_files), :Port => port
50
-
51
- else
52
- puts "Unknown command '#{command}'"
53
- puts <<-USAGE
54
- Usage:
55
- deck run src.md...
56
- deck build src.md...
57
-
58
- see http://github.com/alexch/deck.rb README for more help.
59
-
60
- USAGE
61
- exit 1
62
46
  end
data/lib/deck/rack_app.rb CHANGED
@@ -12,8 +12,11 @@ module Deck
12
12
  app_root = File.expand_path "#{here}/../.."
13
13
  end
14
14
 
15
- def self.build slide_files
15
+ def self.public_file_server
16
+ Rack::File.new("#{app_root}/public")
17
+ end
16
18
 
19
+ def self.build slide_files
17
20
  if const_defined?(:Thin)
18
21
  if require "thin/logging"
19
22
  Thin::Logging.debug = true
@@ -34,7 +37,7 @@ module Deck
34
37
  def initialize slide_files
35
38
  @slide_files = [slide_files].flatten.map do |slide_file|
36
39
  case slide_file
37
- when /\/?showoff.json$/
40
+ when /\/?showoff(.*)\.json$/
38
41
  json_file_dir = File.expand_path(File.dirname(slide_file))
39
42
  json_file = slide_file
40
43
  config = JSON.parse(File.read(json_file))
@@ -52,7 +55,7 @@ module Deck
52
55
  end.flatten
53
56
 
54
57
  @file_servers =
55
- [Rack::File.new("#{::Deck::RackApp.app_root}/public")] +
58
+ [::Deck::RackApp.public_file_server] +
56
59
  @slide_files.map do |slide_file|
57
60
  File.expand_path File.dirname(slide_file.path) if slide_file.is_a? File
58
61
  end.compact.uniq.map do |slide_file_dir|
@@ -43,6 +43,10 @@ module Deck
43
43
  link({:rel => "stylesheet", :href => src}.merge(attributes))
44
44
  end
45
45
 
46
+ def public_asset path
47
+ "/#{path}"
48
+ end
49
+
46
50
  def head_content
47
51
  super
48
52
  meta 'charset' => 'utf-8'
@@ -51,30 +55,30 @@ module Deck
51
55
  meta :name => "description", :content=> @description if @description
52
56
  meta :name => "author", :content=> @author if @author
53
57
 
54
- stylesheet "coderay.css"
58
+ stylesheet public_asset("coderay.css")
55
59
 
56
60
  # <!-- Core and extension CSS files -->
57
- stylesheet "deck.js/core/deck.core.css"
61
+ stylesheet public_asset("deck.js/core/deck.core.css")
58
62
  extensions.each do |extension|
59
- stylesheet "deck.js/extensions/#{extension}/deck.#{extension}.css"
63
+ stylesheet public_asset("deck.js/extensions/#{extension}/deck.#{extension}.css")
60
64
  end
61
65
 
62
66
  # <!-- Theme CSS files (menu swaps these out) -->
63
- stylesheet "deck.js/themes/style/swiss.css", :id=>"style-theme-link"
67
+ stylesheet public_asset("deck.js/themes/style/swiss.css"), :id=>"style-theme-link"
64
68
  end
65
69
 
66
70
  def scripts
67
- script :src => "deck.js/modernizr.custom.js"
71
+ script :src => public_asset("deck.js/modernizr.custom.js")
68
72
 
69
73
  # comment 'Grab CDN jQuery, with a protocol relative URL; fall back to local if offline'
70
74
  # script :src => '//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js'
71
- script :src => 'deck.js/jquery-1.7.min.js'
75
+ script :src => public_asset('deck.js/jquery-1.7.min.js')
72
76
 
73
77
  comment 'Deck Core and extensions'
74
- script :type => "text/javascript", :src => 'deck.js/core/deck.core.js'
78
+ script :type => "text/javascript", :src => public_asset('deck.js/core/deck.core.js')
75
79
 
76
80
  extensions.each do |extension|
77
- script :type => "text/javascript", :src => "deck.js/extensions/#{extension}/deck.#{extension}.js"
81
+ script :type => "text/javascript", :src => public_asset("deck.js/extensions/#{extension}/deck.#{extension}.js")
78
82
  end
79
83
 
80
84
  # fire up deck.js
data/lib/deck/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Deck
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -73,7 +73,7 @@ module Deck
73
73
  get "/"
74
74
  assert_ok
75
75
  assert { last_response.body.include? "contents of foo.md" }
76
- assert { last_response.body.include? "<script src=\"deck.js/core/deck.core.js\"" }
76
+ assert { last_response.body.include? "<script src=\"/deck.js/core/deck.core.js\"" }
77
77
  end
78
78
 
79
79
  it "404s anything but the root path" do
@@ -187,6 +187,8 @@ module Deck
187
187
  assert { app.slides == Slide.from_file(slide_file) }
188
188
  end
189
189
 
190
+ # todo: unify these tests
191
+
190
192
  it "reads a showoff.json file" do
191
193
  foo_file = file "foo.md", "# hello"
192
194
  bar_file = file "bar.md", "# hello"
@@ -241,6 +243,25 @@ module Deck
241
243
  }
242
244
  end
243
245
 
246
+ it "reads a showoff-foo.json file" do
247
+ foo_file = file "foo.md", "# hello"
248
+ bar_file = file "bar.md", "# hello"
249
+ showoff_file = file "showoff-foo.json", <<-JSON
250
+ {
251
+ "name": "Ruby For Programmers",
252
+ "description": "an introduction to the Ruby programming language",
253
+ "sections": [
254
+ "foo.md",
255
+ "bar.md"
256
+ ]
257
+ }
258
+ JSON
259
+
260
+ app = RackApp.new [showoff_file]
261
+ assert { app.slides == Slide.from_file(foo_file) + Slide.from_file(bar_file) }
262
+ end
263
+
264
+
244
265
  it "if no slides are specified, it globs all markdown files under ."
245
266
 
246
267
  end
@@ -21,7 +21,7 @@ module Deck
21
21
 
22
22
  it "renders a basic deck.js HTML page" do
23
23
  assert { doc }
24
- assert { @html.include? '<link href="deck.js/core/deck.core.css" rel="stylesheet" />' }
24
+ assert { @html.include? '<link href="/deck.js/core/deck.core.css" rel="stylesheet" />' }
25
25
  end
26
26
 
27
27
  it "contains a single dummy slide" do
metadata CHANGED
@@ -1,147 +1,155 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: deckrb
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alex Chaffee
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-02-29 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-03-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: erector
16
+ requirement: !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3107287963
27
- segments:
28
- - 0
29
- - 9
30
- - 0
31
- - pre
32
- - 1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.9.0.pre1
34
- prerelease: false
35
- requirement: *id001
36
- name: erector
37
22
  type: :runtime
38
- - !ruby/object:Gem::Dependency
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 7
45
- segments:
46
- - 2
47
- version: "2"
48
23
  prerelease: false
49
- requirement: *id002
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0.pre1
30
+ - !ruby/object:Gem::Dependency
50
31
  name: redcarpet
51
- type: :runtime
52
- - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
54
33
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2'
38
+ type: :runtime
62
39
  prerelease: false
63
- requirement: *id003
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2'
46
+ - !ruby/object:Gem::Dependency
64
47
  name: rack
65
- type: :runtime
66
- - !ruby/object:Gem::Dependency
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
68
49
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
76
55
  prerelease: false
77
- requirement: *id004
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
78
63
  name: trollop
79
- type: :runtime
80
- - !ruby/object:Gem::Dependency
81
- version_requirements: &id005 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
82
65
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
90
71
  prerelease: false
91
- requirement: *id005
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
92
79
  name: nokogiri
93
- type: :runtime
94
- - !ruby/object:Gem::Dependency
95
- version_requirements: &id006 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
96
81
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
104
87
  prerelease: false
105
- requirement: *id006
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
106
95
  name: coderay
107
- type: :runtime
108
- - !ruby/object:Gem::Dependency
109
- version_requirements: &id007 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
110
97
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
118
103
  prerelease: false
119
- requirement: *id007
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
120
111
  name: json
121
- type: :runtime
122
- - !ruby/object:Gem::Dependency
123
- version_requirements: &id008 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
124
113
  none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- hash: 3
129
- segments:
130
- - 0
131
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
132
119
  prerelease: false
133
- requirement: *id008
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
134
127
  name: rack-codehighlighter
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
135
134
  type: :runtime
136
- description: deck.js (http://imakewebthings.github.com/deck.js) is a JavaScript library for building slide presentations using HTML 5. deck.rb (http://github.com/alexch/deck.rb) builds on top of deck.js, adding some features and letting you focus on your slides, not the HTML infrastructure.
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: deck.js (http://imakewebthings.github.com/deck.js) is a JavaScript library
143
+ for building slide presentations using HTML 5. deck.rb (http://github.com/alexch/deck.rb)
144
+ builds on top of deck.js, adding some features and letting you focus on your slides,
145
+ not the HTML infrastructure.
137
146
  email: alex@stinky.com
138
- executables:
147
+ executables:
139
148
  - deck
140
149
  extensions: []
141
-
142
- extra_rdoc_files:
150
+ extra_rdoc_files:
143
151
  - README.md
144
- files:
152
+ files:
145
153
  - lib/deck/noko.rb
146
154
  - lib/deck/rack_app.rb
147
155
  - lib/deck/rack_static_patch.rb
@@ -223,41 +231,39 @@ files:
223
231
  - spec/slide_deck_spec.rb
224
232
  - spec/slide_spec.rb
225
233
  - spec/spec_helper.rb
226
- - bin/deck
234
+ - !binary |-
235
+ YmluL2RlY2s=
227
236
  homepage: http://github.com/alexch/deck
228
237
  licenses: []
229
-
230
238
  post_install_message:
231
239
  rdoc_options: []
232
-
233
- require_paths:
240
+ require_paths:
234
241
  - lib
235
- required_ruby_version: !ruby/object:Gem::Requirement
242
+ required_ruby_version: !ruby/object:Gem::Requirement
236
243
  none: false
237
- requirements:
238
- - - ">="
239
- - !ruby/object:Gem::Version
240
- hash: 3
241
- segments:
244
+ requirements:
245
+ - - ! '>='
246
+ - !ruby/object:Gem::Version
247
+ version: '0'
248
+ segments:
242
249
  - 0
243
- version: "0"
244
- required_rubygems_version: !ruby/object:Gem::Requirement
250
+ hash: 1200341781470137723
251
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
252
  none: false
246
- requirements:
247
- - - ">="
248
- - !ruby/object:Gem::Version
249
- hash: 3
250
- segments:
253
+ requirements:
254
+ - - ! '>='
255
+ - !ruby/object:Gem::Version
256
+ version: '0'
257
+ segments:
251
258
  - 0
252
- version: "0"
259
+ hash: 1200341781470137723
253
260
  requirements: []
254
-
255
261
  rubyforge_project:
256
- rubygems_version: 1.8.15
262
+ rubygems_version: 1.8.21
257
263
  signing_key:
258
264
  specification_version: 3
259
265
  summary: Make HTML slide shows; wraps deck.js
260
- test_files:
266
+ test_files:
261
267
  - spec/javascripts/support/jasmine_config.rb
262
268
  - spec/javascripts/support/jasmine_runner.rb
263
269
  - spec/rack_app_spec.rb