slideshow 0.9.6 → 0.9.7

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/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.9.7 / 2010-07-22
2
+
3
+ * Added support for reStructedText (using pandoc-ruby gem)
4
+ * Update builtin S6 blank templates (toggle slide counter, debug, etc.)
5
+ * Update SyntaxHighlighter helper
6
+
1
7
  === 0.9.6 / 2010-07-18
2
8
 
3
9
  * Update builtin S6 blank templates (adding autoplay, custom transitions, custom title selector, and more)
data/Manifest.txt CHANGED
@@ -7,6 +7,7 @@ config/slideshow.builtin.yml
7
7
  config/slideshow.yml
8
8
  lib/slideshow.rb
9
9
  lib/slideshow/config.rb
10
+ lib/slideshow/fetch.rb
10
11
  lib/slideshow/filters/debug_filter.rb
11
12
  lib/slideshow/filters/headers_filter.rb
12
13
  lib/slideshow/filters/slide_filter.rb
@@ -24,10 +25,12 @@ lib/slideshow/helpers/syntax/sh_helper.rb
24
25
  lib/slideshow/helpers/syntax/uv_helper.rb
25
26
  lib/slideshow/helpers/table_helper.rb
26
27
  lib/slideshow/helpers/text_helper.rb
27
- lib/slideshow/markdown.rb
28
+ lib/slideshow/manifest.rb
29
+ lib/slideshow/markup/markdown.rb
30
+ lib/slideshow/markup/rest.rb
31
+ lib/slideshow/markup/textile.rb
28
32
  lib/slideshow/opts.rb
29
33
  lib/slideshow/slide.rb
30
- lib/slideshow/textile.rb
31
34
  templates/s6.txt
32
35
  templates/s6.txt.gen
33
36
  templates/s6/jquery.js
data/README.rdoc CHANGED
@@ -26,6 +26,7 @@ Examples:
26
26
  slideshow microformats
27
27
  slideshow microformats.textile # Process slides using Textile
28
28
  slideshow microformats.text # Process slides using Markdown
29
+ slideshow microformats.rst # Process slides using reStructuredText (*see Requirements)
29
30
 
30
31
  slideshow -o slides microformats # Output slideshow to slides folder
31
32
 
@@ -45,9 +46,12 @@ More examles:
45
46
 
46
47
  * BlueCloth (Markdown Markup) [Optional]
47
48
  * RDiscount (Markdown Markup) [Optional]
49
+ * pandoc-ruby (Markdown/reStructuredText Markup) [Optional]
50
+
48
51
  * Coderay (Syntax Highlighting) [Optional]
49
52
  * Ultraviolet (Syntax Highlighting) [Optional]
50
53
 
54
+
51
55
  == INSTALL:
52
56
 
53
57
  Just install the gem:
@@ -26,11 +26,14 @@ filters:
26
26
  - dump_content_to_file_debug_text
27
27
 
28
28
 
29
- # markup (textile, markdown) config
29
+ # markup (textile, markdown, rest) config
30
30
 
31
31
  textile:
32
32
  extnames: [ .textile, .t ]
33
33
 
34
+ rest:
35
+ extnames: [ .rst, .rest ]
36
+
34
37
  markdown:
35
38
  extnames: [ .markdown, .m, .mark, .mkdn, .md, .txt, .text ]
36
39
 
@@ -57,6 +57,10 @@ class Config
57
57
  @hash.fetch( 'user', {} ).fetch( lib, {} ).fetch( 'post-processing', true )
58
58
  end
59
59
 
60
+ def known_rest_extnames
61
+ @hash[ 'builtin' ][ 'rest' ][ 'extnames' ]
62
+ end
63
+
60
64
  def known_textile_extnames
61
65
  # returns an array of known file extensions e.g.
62
66
  # [ '.textile', '.t' ]
@@ -86,7 +90,7 @@ class Config
86
90
  # ruby check: is it better self. ?? or more confusing
87
91
  # possible conflict only with write access (e.g. prop=)
88
92
 
89
- known_textile_extnames + known_markdown_extnames
93
+ known_textile_extnames + known_markdown_extnames + known_rest_extnames
90
94
  end
91
95
 
92
96
  def text_filters
@@ -0,0 +1,132 @@
1
+ module Slideshow
2
+ module Fetch
3
+
4
+ def fetch_file( dest, src )
5
+ logger.debug "fetch( dest: #{dest}, src: #{src})"
6
+
7
+ uri = URI.parse( src )
8
+
9
+ # new code: honor proxy env variable HTTP_PROXY
10
+ proxy = ENV['HTTP_PROXY']
11
+ proxy = ENV['http_proxy'] if proxy.nil? # try possible lower/case env variable (for *nix systems) is this necessary??
12
+
13
+ if proxy
14
+ proxy = URI.parse( proxy )
15
+ logger.debug "using net http proxy: proxy.host=#{proxy.host}, proxy.port=#{proxy.port}"
16
+ if proxy.user && proxy.password
17
+ logger.debug " using credentials: proxy.user=#{proxy.user}, proxy.password=****"
18
+ else
19
+ logger.debug " using no credentials"
20
+ end
21
+ else
22
+ logger.debug "using direct net http access; no proxy configured"
23
+ proxy = OpenStruct.new # all fields return nil (e.g. proxy.host, etc.)
24
+ end
25
+
26
+ # same as short-cut: http_proxy.get_respone( uri )
27
+ # use full code for easier changes
28
+
29
+ http_proxy = Net::HTTP::Proxy( proxy.host, proxy.port, proxy.user, proxy.password )
30
+ http = http_proxy.new( uri.host, uri.port )
31
+ request = Net::HTTP::Get.new( uri.request_uri )
32
+ response = http.request( request )
33
+
34
+ unless response.code == '200' # note: responsoe.code is a string
35
+ msg = "#{response.code} #{response.message}"
36
+ puts "*** error: #{msg}"
37
+ return # todo: throw StandardException?
38
+ end
39
+
40
+ logger.debug " content_type: #{response.content_type}, content_length: #{response.content_length}"
41
+
42
+ # check for content type; use 'wb' for images
43
+ if response.content_type =~ /image/
44
+ logger.debug ' switching to binary'
45
+ flags = 'wb'
46
+ else
47
+ flags = 'w'
48
+ end
49
+
50
+ File.open( dest, flags ) do |f|
51
+ f.write( response.body )
52
+ end
53
+ end
54
+
55
+
56
+ def fetch_slideshow_templates
57
+ logger.debug "fetch_uri=#{opts.fetch_uri}"
58
+
59
+ src = opts.fetch_uri
60
+
61
+ ## check for builtin shortcut (assume no / or \)
62
+ if src.index( '/' ).nil? && src.index( '\\' ).nil?
63
+ shortcut = src.clone
64
+ src = config.map_fetch_shortcut( src )
65
+
66
+ if src.nil?
67
+ puts "** Error: No mapping found for fetch shortcut '#{shortcut}'."
68
+ return
69
+ end
70
+ puts " Mapping fetch shortcut '#{shortcut}' to: #{src}"
71
+ end
72
+
73
+
74
+ # src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
75
+ # src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
76
+ uri = URI.parse( src )
77
+
78
+ logger.debug "host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
79
+
80
+ dirname = File.dirname( uri.path )
81
+ basename = File.basename( uri.path, '.*' ) # e.g. fullerscreen (without extension)
82
+ filename = File.basename( uri.path ) # e.g. fullerscreen.txt (with extension)
83
+
84
+ logger.debug "dirname: #{dirname}"
85
+ logger.debug "basename: #{basename}, filename: #{filename}"
86
+
87
+ dlbase = "http://#{uri.host}:#{uri.port}#{dirname}"
88
+ pkgpath = File.expand_path( "#{config_dir}/templates/#{basename}" )
89
+
90
+ logger.debug "dlpath: #{dlbase}"
91
+ logger.debug "pkgpath: #{pkgpath}"
92
+
93
+ FileUtils.makedirs( pkgpath ) unless File.directory? pkgpath
94
+
95
+ puts "Fetching template package '#{basename}'"
96
+ puts " : from '#{dlbase}'"
97
+ puts " : saving to '#{pkgpath}'"
98
+
99
+ # download manifest
100
+ dest = "#{pkgpath}/#{filename}"
101
+
102
+ puts " Downloading manifest '#{filename}'..."
103
+
104
+ fetch_file( dest, src )
105
+
106
+ manifest = load_manifest_core( dest )
107
+
108
+ # download templates listed in manifest
109
+ manifest.each do |values|
110
+ values[1..-1].each do |file|
111
+
112
+ dest = "#{pkgpath}/#{file}"
113
+
114
+ # make sure path exists
115
+ destpath = File.dirname( dest )
116
+ FileUtils.makedirs( destpath ) unless File.directory? destpath
117
+
118
+ src = "#{dlbase}/#{file}"
119
+
120
+ puts " Downloading template '#{file}'..."
121
+ fetch_file( dest, src )
122
+ end
123
+ end
124
+ puts "Done."
125
+ end
126
+
127
+ end # module Fetch
128
+ end # module Slideshow
129
+
130
+ class Slideshow::Gen
131
+ include Slideshow::Fetch
132
+ end
@@ -7,7 +7,7 @@ module Slideshow
7
7
  # e.g. changes:
8
8
  # <h1 id='optional' class='optional'>
9
9
  # to
10
- # <!-- _S9SLIDE_ -->
10
+ # html comment -> _S9SLIDE_ (note: rdoc can't handle html comments?)
11
11
  # <h1 id='optional' class='optional'>
12
12
 
13
13
  def add_slide_directive_before_h1( content )
@@ -33,7 +33,7 @@ end
33
33
  # <div id='header'>
34
34
  # <h1 id='optional' class='optional'>
35
35
  # to
36
- # <!-- _S9SLIDE_ -->
36
+ # html comment -> _S9SLIDE_
37
37
  # <div id='header'>
38
38
  # <h1 id='optional' class='optional'>
39
39
 
data/lib/slideshow/gen.rb CHANGED
@@ -17,45 +17,17 @@ class Gen
17
17
  @opts
18
18
  end
19
19
 
20
- attr_reader :markup_type # :textile, :markdown
20
+ attr_reader :markup_type # :textile, :markdown, :rest
21
21
 
22
- def load_markdown_libs
23
- # check for available markdown libs/gems
24
- # try to require each lib and remove any not installed
25
- @markdown_libs = []
26
-
27
- config.known_markdown_libs.each do |lib|
28
- begin
29
- require lib
30
- @markdown_libs << lib
31
- rescue LoadError => ex
32
- logger.debug "Markdown library #{lib} not found. Use gem install #{lib} to install."
33
- end
34
- end
35
-
36
- puts " Found #{@markdown_libs.length} Markdown libraries: #{@markdown_libs.join(', ')}"
37
- end
38
-
39
-
40
- def markdown_to_html( content )
41
- # call markdown filter; turn markdown lib name into method_name (mn)
42
- # eg. rpeg-markdown => rpeg_markdown_to_html
43
-
44
- # lets you use differnt options/converters for a single markdown lib
45
- mn = config.markdown_to_html_method( @markdown_libs.first )
46
-
47
- puts " Converting Markdown-text (#{content.length} bytes) to HTML using library '#{@markdown_libs.first}' calling '#{mn}'..."
48
-
49
- send mn, content # call 1st configured markdown engine e.g. kramdown_to_html( content )
50
- end
51
-
52
- # uses configured markup processor (textile,markdown) to generate html
22
+ # uses configured markup processor (textile,markdown,rest) to generate html
53
23
  def text_to_html( content )
54
24
  content = case @markup_type
55
25
  when :markdown
56
26
  markdown_to_html( content )
57
27
  when :textile
58
28
  textile_to_html( content )
29
+ when :rest
30
+ rest_to_html( content )
59
31
  end
60
32
  content
61
33
  end
@@ -93,10 +65,12 @@ class Gen
93
65
  end
94
66
  end
95
67
 
68
+ # todo/fix: move to Config class
96
69
  def cache_dir
97
70
  RUBY_PLATFORM =~ /win32/ ? win32_cache_dir : File.join(File.expand_path("~"), ".slideshow")
98
71
  end
99
72
 
73
+ # todo/fix: move to Config class
100
74
  def win32_cache_dir
101
75
  unless ENV['HOMEDRIVE'] && ENV['HOMEPATH'] && File.exists?(home = ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
102
76
  puts "No HOMEDRIVE or HOMEPATH environment variable. Set one to save a" +
@@ -107,6 +81,7 @@ class Gen
107
81
  end
108
82
  end
109
83
 
84
+ # todo/fix: move to Config class
110
85
  def config_dir
111
86
  unless @config_dir # first time? calculate config_dir value to "cache"
112
87
 
@@ -123,101 +98,6 @@ class Gen
123
98
  @config_dir
124
99
  end
125
100
 
126
- def load_manifest_core( path )
127
- manifest = []
128
-
129
- File.open( path ).readlines.each_with_index do |line,i|
130
- case line
131
- when /^\s*$/
132
- # skip empty lines
133
- when /^\s*#.*$/
134
- # skip comment lines
135
- else
136
- logger.debug "line #{i+1}: #{line.strip}"
137
- values = line.strip.split( /[ <,+]+/ )
138
-
139
- # add source for shortcuts (assumes relative path; if not issue warning/error)
140
- values << values[0] if values.size == 1
141
-
142
- manifest << values
143
- end
144
- end
145
-
146
- manifest
147
- end
148
-
149
- def load_manifest( path )
150
-
151
- filename = path
152
-
153
- puts " Loading template manifest #{filename}..."
154
- manifest = load_manifest_core( filename )
155
-
156
- # post-processing
157
- # normalize all source paths (1..-1) /make full path/add template dir
158
-
159
- templatesdir = File.dirname( path )
160
- logger.debug "templatesdir=#{templatesdir}"
161
-
162
- manifest.each do |values|
163
- (1..values.size-1).each do |i|
164
- values[i] = "#{templatesdir}/#{values[i]}"
165
- logger.debug " path[#{i}]=>#{values[i]}<"
166
- end
167
- end
168
-
169
- manifest
170
- end
171
-
172
- def find_manifests( patterns )
173
- manifests = []
174
-
175
- patterns.each do |pattern|
176
- pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
177
- logger.debug "Checking #{pattern}"
178
- Dir.glob( pattern ) do |file|
179
- logger.debug " Found manifest: #{file}"
180
- manifests << [ File.basename( file ), file ]
181
- end
182
- end
183
-
184
- manifests
185
- end
186
-
187
- def installed_generator_manifests
188
- # 1) search gem/templates
189
-
190
- builtin_patterns = [
191
- "#{File.dirname( LIB_PATH )}/templates/*.txt.gen"
192
- ]
193
-
194
- find_manifests( builtin_patterns )
195
- end
196
-
197
- def installed_template_manifests
198
- # 1) search ./templates
199
- # 2) search config_dir/templates
200
- # 3) search gem/templates
201
-
202
- builtin_patterns = [
203
- "#{File.dirname( LIB_PATH )}/templates/*.txt"
204
- ]
205
- config_patterns = [
206
- "#{config_dir}/templates/*.txt",
207
- "#{config_dir}/templates/*/*.txt"
208
- ]
209
- current_patterns = [
210
- "templates/*.txt",
211
- "templates/*/*.txt"
212
- ]
213
-
214
- patterns = []
215
- patterns += current_patterns unless LIB_PATH == File.expand_path( 'lib' ) # don't include working dir if we test code from repo (don't include slideshow/templates)
216
- patterns += config_patterns
217
- patterns += builtin_patterns
218
-
219
- find_manifests( patterns )
220
- end
221
101
 
222
102
  def load_template( path )
223
103
  puts " Loading template #{path}..."
@@ -228,22 +108,6 @@ class Gen
228
108
  ERB.new( content ).result( the_binding )
229
109
  end
230
110
 
231
- def load_template_old_delete( name, builtin )
232
-
233
- if opts.has_includes?
234
- opts.includes.each do |path|
235
- logger.debug "File.exists? #{path}/#{name}"
236
-
237
- if File.exists?( "#{path}/#{name}" ) then
238
- puts "Loading custom template #{path}/#{name}..."
239
- return File.read( "#{path}/#{name}" )
240
- end
241
- end
242
- end
243
-
244
- # fallback load builtin template packaged with gem
245
- load_builtin_template( builtin )
246
- end
247
111
 
248
112
  def with_output_path( dest, output_path )
249
113
  dest_full = File.expand_path( dest, output_path )
@@ -256,130 +120,7 @@ class Gen
256
120
  dest_full
257
121
  end
258
122
 
259
-
260
- def fetch_file( dest, src )
261
- logger.debug "fetch( dest: #{dest}, src: #{src})"
262
-
263
- uri = URI.parse( src )
264
-
265
- # new code: honor proxy env variable HTTP_PROXY
266
- proxy = ENV['HTTP_PROXY']
267
- proxy = ENV['http_proxy'] if proxy.nil? # try possible lower/case env variable (for *nix systems) is this necessary??
268
-
269
- if proxy
270
- proxy = URI.parse( proxy )
271
- logger.debug "using net http proxy: proxy.host=#{proxy.host}, proxy.port=#{proxy.port}"
272
- if proxy.user && proxy.password
273
- logger.debug " using credentials: proxy.user=#{proxy.user}, proxy.password=****"
274
- else
275
- logger.debug " using no credentials"
276
- end
277
- else
278
- logger.debug "using direct net http access; no proxy configured"
279
- proxy = OpenStruct.new # all fields return nil (e.g. proxy.host, etc.)
280
- end
281
-
282
- # same as short-cut: http_proxy.get_respone( uri )
283
- # use full code for easier changes
284
-
285
- http_proxy = Net::HTTP::Proxy( proxy.host, proxy.port, proxy.user, proxy.password )
286
- http = http_proxy.new( uri.host, uri.port )
287
- request = Net::HTTP::Get.new( uri.request_uri )
288
- response = http.request( request )
289
-
290
- unless response.code == '200' # note: responsoe.code is a string
291
- msg = "#{response.code} #{response.message}"
292
- puts "*** error: #{msg}"
293
- return # todo: throw StandardException?
294
- end
295
-
296
- logger.debug " content_type: #{response.content_type}, content_length: #{response.content_length}"
297
-
298
- # check for content type; use 'wb' for images
299
- if response.content_type =~ /image/
300
- logger.debug ' switching to binary'
301
- flags = 'wb'
302
- else
303
- flags = 'w'
304
- end
305
-
306
- File.open( dest, flags ) do |f|
307
- f.write( response.body )
308
- end
309
- end
310
-
311
123
 
312
- def fetch_slideshow_templates
313
- logger.debug "fetch_uri=#{opts.fetch_uri}"
314
-
315
- src = opts.fetch_uri
316
-
317
- ## check for builtin shortcut (assume no / or \)
318
- if src.index( '/' ).nil? && src.index( '\\' ).nil?
319
- shortcut = src.clone
320
- src = config.map_fetch_shortcut( src )
321
-
322
- if src.nil?
323
- puts "** Error: No mapping found for fetch shortcut '#{shortcut}'."
324
- return
325
- end
326
- puts " Mapping fetch shortcut '#{shortcut}' to: #{src}"
327
- end
328
-
329
-
330
- # src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
331
- # src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
332
- uri = URI.parse( src )
333
-
334
- logger.debug "host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
335
-
336
- dirname = File.dirname( uri.path )
337
- basename = File.basename( uri.path, '.*' ) # e.g. fullerscreen (without extension)
338
- filename = File.basename( uri.path ) # e.g. fullerscreen.txt (with extension)
339
-
340
- logger.debug "dirname: #{dirname}"
341
- logger.debug "basename: #{basename}, filename: #{filename}"
342
-
343
- dlbase = "http://#{uri.host}:#{uri.port}#{dirname}"
344
- pkgpath = File.expand_path( "#{config_dir}/templates/#{basename}" )
345
-
346
- logger.debug "dlpath: #{dlbase}"
347
- logger.debug "pkgpath: #{pkgpath}"
348
-
349
- FileUtils.makedirs( pkgpath ) unless File.directory? pkgpath
350
-
351
- puts "Fetching template package '#{basename}'"
352
- puts " : from '#{dlbase}'"
353
- puts " : saving to '#{pkgpath}'"
354
-
355
- # download manifest
356
- dest = "#{pkgpath}/#{filename}"
357
-
358
- puts " Downloading manifest '#{filename}'..."
359
-
360
- fetch_file( dest, src )
361
-
362
- manifest = load_manifest_core( dest )
363
-
364
- # download templates listed in manifest
365
- manifest.each do |values|
366
- values[1..-1].each do |file|
367
-
368
- dest = "#{pkgpath}/#{file}"
369
-
370
- # make sure path exists
371
- destpath = File.dirname( dest )
372
- FileUtils.makedirs( destpath ) unless File.directory? destpath
373
-
374
- src = "#{dlbase}/#{file}"
375
-
376
- puts " Downloading template '#{file}'..."
377
- fetch_file( dest, src )
378
- end
379
- end
380
- puts "Done."
381
- end
382
-
383
124
  def create_slideshow_templates
384
125
 
385
126
  manifest_name = opts.manifest
@@ -430,7 +171,7 @@ class Gen
430
171
 
431
172
  # 1) add slide break
432
173
 
433
- if @markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby'
174
+ if (@markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby') || @markup_type == :rest
434
175
  content = add_slide_directive_before_div_h1( content )
435
176
  else
436
177
  content = add_slide_directive_before_h1( content )
@@ -579,6 +320,8 @@ class Gen
579
320
 
580
321
  if config.known_markdown_extnames.include?( extname )
581
322
  @markup_type = :markdown
323
+ elsif config.known_rest_extnames.include?( extname )
324
+ @markup_type = :rest
582
325
  else
583
326
  @markup_type = :textile
584
327
  end
@@ -719,6 +462,7 @@ def run( args )
719
462
  puts " slideshow microformats"
720
463
  puts " slideshow microformats.textile # Process slides using Textile"
721
464
  puts " slideshow microformats.text # Process slides using Markdown"
465
+ puts " slideshow microformats.rst # Process slides using reStructuredText"
722
466
  puts " slideshow -o slides microformats # Output slideshow to slides folder"
723
467
  puts
724
468
  puts "More examles:"
@@ -19,10 +19,23 @@ def sh_worker( code, opts )
19
19
  css_class_opt = opts.fetch( :class, nil ) # large, small, tiny, etc.
20
20
  css_class << " #{css_class_opt}" if css_class_opt # e.g. use/allow multiple classes -> code small, code large, etc.
21
21
 
22
- out = %{<pre class='#{css_class} brush: #{lang} gutter: #{line_numbers ? 'true' : 'false'}'>}
22
+ out = %{<div class='#{css_class}'><pre class='brush: #{lang} toolbar: false gutter: #{line_numbers ? 'true' : 'false'}'>}
23
23
  out << code_highlighted
24
- out << %{</pre>\n}
24
+ out << %{</pre></div>\n}
25
25
 
26
+ name = opts.fetch( :name, nil )
27
+ txmt_value = opts.fetch( :txmt, headers.code_txmt )
28
+ txmt = (txmt_value =~ /true|yes|on/i) ? true : false
29
+
30
+ # add optional href link for textmate
31
+ if name
32
+ out << %{<div class="codeurl">}
33
+ out << %{<a href="txmt://open?url=file://#{File.expand_path(name)}">} if txmt
34
+ out << name
35
+ out << %{</a>} if txmt
36
+ out << %{</div>\n}
37
+ end
38
+
26
39
  return out
27
40
  end
28
41
 
@@ -13,15 +13,18 @@ def help()
13
13
  *Slide Show Keyboard Controls (Help)*
14
14
 
15
15
  | Action | Key |
16
- | Go to next slide | Space Bar, Right Arrow, Down Arrow, Page Down |
16
+ | Go to next slide | Space Bar, Right Arrow, Down Arrow, Page Down, Click Heading |
17
17
  | Go to previous slide | Left Arrow, Up Arrow, Page Up |
18
18
  | Toggle between slideshow and outline view (&#216;) | T |
19
19
  | Show/hide slide controls (&#216; &laquo; &raquo;) | C, Move mouse to bottom right corner |
20
+ | Zoom in, zoom out, zoom reset (100%) | Control[@+@]Plus, Control[@+@]Minus, Control[@+@]@0@ |
20
21
  EOS
21
22
 
22
23
  html = <<EOS
23
24
  <!-- begin help -->
25
+ <div class='help projection'>
24
26
  #{textile_to_html( text )}
27
+ </div>
25
28
  <!-- end help -->
26
29
  EOS
27
30
 
@@ -0,0 +1,105 @@
1
+ module Slideshow
2
+ module Manifest
3
+
4
+ def load_manifest_core( path )
5
+ manifest = []
6
+
7
+ File.open( path ).readlines.each_with_index do |line,i|
8
+ case line
9
+ when /^\s*$/
10
+ # skip empty lines
11
+ when /^\s*#.*$/
12
+ # skip comment lines
13
+ else
14
+ logger.debug "line #{i+1}: #{line.strip}"
15
+ values = line.strip.split( /[ <,+]+/ )
16
+
17
+ # add source for shortcuts (assumes relative path; if not issue warning/error)
18
+ values << values[0] if values.size == 1
19
+
20
+ manifest << values
21
+ end
22
+ end
23
+
24
+ manifest
25
+ end
26
+
27
+ def load_manifest( path )
28
+
29
+ filename = path
30
+
31
+ puts " Loading template manifest #{filename}..."
32
+ manifest = load_manifest_core( filename )
33
+
34
+ # post-processing
35
+ # normalize all source paths (1..-1) /make full path/add template dir
36
+
37
+ templatesdir = File.dirname( path )
38
+ logger.debug "templatesdir=#{templatesdir}"
39
+
40
+ manifest.each do |values|
41
+ (1..values.size-1).each do |i|
42
+ values[i] = "#{templatesdir}/#{values[i]}"
43
+ logger.debug " path[#{i}]=>#{values[i]}<"
44
+ end
45
+ end
46
+
47
+ manifest
48
+ end
49
+
50
+ def find_manifests( patterns )
51
+ manifests = []
52
+
53
+ patterns.each do |pattern|
54
+ pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
55
+ logger.debug "Checking #{pattern}"
56
+ Dir.glob( pattern ) do |file|
57
+ logger.debug " Found manifest: #{file}"
58
+ manifests << [ File.basename( file ), file ]
59
+ end
60
+ end
61
+
62
+ manifests
63
+ end
64
+
65
+ def installed_generator_manifests
66
+ # 1) search gem/templates
67
+
68
+ builtin_patterns = [
69
+ "#{File.dirname( LIB_PATH )}/templates/*.txt.gen"
70
+ ]
71
+
72
+ find_manifests( builtin_patterns )
73
+ end
74
+
75
+ def installed_template_manifests
76
+ # 1) search ./templates
77
+ # 2) search config_dir/templates
78
+ # 3) search gem/templates
79
+
80
+ builtin_patterns = [
81
+ "#{File.dirname( LIB_PATH )}/templates/*.txt"
82
+ ]
83
+ config_patterns = [
84
+ "#{config_dir}/templates/*.txt",
85
+ "#{config_dir}/templates/*/*.txt"
86
+ ]
87
+ current_patterns = [
88
+ "templates/*.txt",
89
+ "templates/*/*.txt"
90
+ ]
91
+
92
+ patterns = []
93
+ patterns += current_patterns unless LIB_PATH == File.expand_path( 'lib' ) # don't include working dir if we test code from repo (don't include slideshow/templates)
94
+ patterns += config_patterns
95
+ patterns += builtin_patterns
96
+
97
+ find_manifests( patterns )
98
+ end
99
+
100
+ end # module Manifest
101
+ end # module Slideshow
102
+
103
+ class Slideshow::Gen
104
+ include Slideshow::Manifest
105
+ end
@@ -49,6 +49,42 @@ module Slideshow
49
49
  def kramdown_to_html( content )
50
50
  Kramdown::Document.new( content ).to_html
51
51
  end
52
+
53
+
54
+ ### code for managing multiple markdown libs
55
+
56
+ def load_markdown_libs
57
+ # check for available markdown libs/gems
58
+ # try to require each lib and remove any not installed
59
+ @markdown_libs = []
60
+
61
+ config.known_markdown_libs.each do |lib|
62
+ begin
63
+ require lib
64
+ @markdown_libs << lib
65
+ rescue LoadError => ex
66
+ logger.debug "Markdown library #{lib} not found. Use gem install #{lib} to install."
67
+ end
68
+ end
69
+
70
+ puts " Found #{@markdown_libs.length} Markdown libraries: #{@markdown_libs.join(', ')}"
71
+ end
72
+
73
+
74
+ def markdown_to_html( content )
75
+ # call markdown filter; turn markdown lib name into method_name (mn)
76
+ # eg. rpeg-markdown => rpeg_markdown_to_html
77
+
78
+ # lets you use differnt options/converters for a single markdown lib
79
+ mn = config.markdown_to_html_method( @markdown_libs.first )
80
+
81
+ puts " Converting Markdown-text (#{content.length} bytes) to HTML using library '#{@markdown_libs.first}' calling '#{mn}'..."
82
+
83
+ send mn, content # call 1st configured markdown engine e.g. kramdown_to_html( content )
84
+ end
85
+
86
+
87
+
52
88
 
53
89
  end # module MarkdownEngines
54
90
  end # module Slideshow
@@ -0,0 +1,17 @@
1
+ require 'pandoc-ruby'
2
+
3
+ module Slideshow
4
+ module RestEngines # reStructuredText
5
+
6
+ def rest_to_html( content )
7
+ puts " Converting reStructuredText (#{content.length} bytes) to HTML..."
8
+
9
+ content = PandocRuby.new( content, :from => :rst, :to => :html ).convert
10
+ end
11
+
12
+ end # module RestEngines
13
+ end # module Slideshow
14
+
15
+ class Slideshow::Gen
16
+ include Slideshow::RestEngines
17
+ end
File without changes
data/lib/slideshow.rb CHANGED
@@ -25,9 +25,12 @@ require 'kramdown' # default markdown library
25
25
  require 'slideshow/opts'
26
26
  require 'slideshow/config'
27
27
  require 'slideshow/gen'
28
+ require 'slideshow/manifest'
29
+ require 'slideshow/fetch'
28
30
  require 'slideshow/slide'
29
- require 'slideshow/textile'
30
- require 'slideshow/markdown'
31
+
32
+ require 'slideshow/markup/textile'
33
+ require 'slideshow/markup/markdown'
31
34
 
32
35
  # load built-in (required) helpers/plugins
33
36
  require 'slideshow/helpers/text_helper'
@@ -51,7 +54,7 @@ require 'slideshow/filters/slide_filter'
51
54
 
52
55
  module Slideshow
53
56
 
54
- VERSION = '0.9.6'
57
+ VERSION = '0.9.7'
55
58
 
56
59
  # version string for generator meta tag (includes ruby version)
57
60
  def Slideshow.generator
@@ -73,7 +76,7 @@ module Slideshow
73
76
 
74
77
  end # module Slideshow
75
78
 
76
- # load built-in (optional) helpers/plugins
79
+ # load built-in (optional) helpers/plugins/engines
77
80
  # If a helper fails to load, simply ingnore it
78
81
  # If you want to use it install missing required gems e.g.:
79
82
  # gem install coderay
@@ -81,6 +84,7 @@ end # module Slideshow
81
84
  BUILTIN_OPT_HELPERS = [
82
85
  'slideshow/helpers/syntax/uv_helper.rb',
83
86
  'slideshow/helpers/syntax/coderay_helper.rb',
87
+ 'slideshow/markup/rest.rb',
84
88
  ]
85
89
 
86
90
  BUILTIN_OPT_HELPERS.each do |helper|
@@ -17,6 +17,16 @@ Slideshow.transition = function( $from, $to ) {
17
17
  * inspired by Karl Swedberg's Scroll Up Headline Reader jQuery Tutorial[1]
18
18
  * [1] http://docs.jquery.com/Tutorials:Scroll_Up_Headline_Reader
19
19
  */
20
+
21
+ function transitionSlideUpSlideDown( $from, $to ) {
22
+ $from.slideUp( 500, function() { $to.slideDown( 1000 ); } );
23
+ }
24
+
25
+ function transitionFadeOutFadeIn( $from, $to ) {
26
+ $from.fadeOut( 500 );
27
+ $to.fadeIn( 500 );
28
+ }
29
+
20
30
  function transitionScrollUp( $from, $to ) {
21
31
  var cheight = $from.outerHeight();
22
32
 
@@ -78,11 +88,7 @@ Slideshow.init = function( options ) {
78
88
 
79
89
  function updateCurrentSlideCounter()
80
90
  {
81
- $( '#currentSlide' ).html( '<a id="plink" href="">'
82
- + '<span id="csHere">' + settings.snum + '<\/span> '
83
- + '<span id="csSep">\/<\/span> '
84
- + '<span id="csTotal">' + settings.smax + '<\/span>'
85
- + '<\/a>' );
91
+ $( '#currentSlide' ).html( settings.snum + '/' + settings.smax );
86
92
  }
87
93
 
88
94
  function updateJumpList()
@@ -92,8 +98,6 @@ Slideshow.init = function( options ) {
92
98
 
93
99
  function updatePermaLink()
94
100
  {
95
- $('#plink').get(0).href = window.location.pathname + '#slide' + settings.snum;
96
-
97
101
  // todo: unify hash marks??; use #1 for div ids instead of #slide1?
98
102
  window.location.hash = '#'+settings.snum;
99
103
  }
@@ -229,6 +233,13 @@ function toggle()
229
233
 
230
234
  function createControls()
231
235
  {
236
+ // todo: make layout into an id (not class?)
237
+ // do we need or allow more than one element?
238
+
239
+
240
+ // if no div.layout exists, create one
241
+ if( $( '.layout' ).length == 0 )
242
+ $( "<div class='layout'></div>").appendTo( 'body' );
232
243
 
233
244
  $( '.layout' )
234
245
  .append( "<div id='controls'>" )
@@ -254,7 +265,13 @@ function toggle()
254
265
  updateCurrentSlideCounter();
255
266
  updatePermaLink();
256
267
  }
257
-
268
+
269
+ function toggleSlideNumber()
270
+ {
271
+ // toggle slide number/counter
272
+ $( '#currentSlide' ).toggle();
273
+ }
274
+
258
275
  function toggleFooter()
259
276
  {
260
277
  $( '#footer').toggle();
@@ -268,7 +285,7 @@ function toggle()
268
285
  key.which = key.keyCode;
269
286
  }
270
287
  if (key.which == 84) {
271
- toggle();
288
+ toggle(); // toggle between project and screen css media mode
272
289
  return;
273
290
  }
274
291
  if( settings.isProjection ) {
@@ -303,7 +320,7 @@ function toggle()
303
320
  goTo(settings.smax);
304
321
  break;
305
322
  case 67: // c
306
- showHide('c');
323
+ showHide('c'); // toggle controls (navlinks,navlist)
307
324
  break;
308
325
  case 65: //a
309
326
  case 80: //p
@@ -312,6 +329,12 @@ function toggle()
312
329
  break;
313
330
  case 70: //f
314
331
  toggleFooter();
332
+ break;
333
+ case 78: // n
334
+ toggleSlideNumber();
335
+ break;
336
+ case 68: // d
337
+ toggleDebug();
315
338
  break;
316
339
  }
317
340
  }
@@ -336,6 +359,33 @@ function autoplay()
336
359
  }
337
360
  }
338
361
 
362
+ function toggleDebug()
363
+ {
364
+ settings.debug = !settings.debug;
365
+ doDebug();
366
+ }
367
+
368
+ function doDebug()
369
+ {
370
+ // fix/todo: save background into oldbackground
371
+ // so we can restore later
372
+
373
+ if( settings.debug == true )
374
+ {
375
+ $( '#header' ).css( 'background', '#FCC' );
376
+ $( '#footer' ).css( 'background', '#CCF' );
377
+ $( '#controls' ).css( 'background', '#BBD' );
378
+ $( '#currentSlide' ).css( 'background', '#FFC' );
379
+ }
380
+ else
381
+ {
382
+ $( '#header' ).css( 'background', 'transparent' );
383
+ $( '#footer' ).css( 'background', 'transparent' );
384
+ $( '#controls' ).css( 'background', 'transparent' );
385
+ $( '#currentSlide' ).css( 'background', 'transparent' );
386
+ }
387
+ }
388
+
339
389
 
340
390
  function toggleAutoplay()
341
391
  {
@@ -452,14 +502,10 @@ function addSlideIds() {
452
502
  toggle();
453
503
  else if( settings.mode == 'autoplay' )
454
504
  toggleAutoplay();
455
-
505
+
506
+
456
507
  if( settings.debug == true )
457
- {
458
- $( '#header' ).css( 'background', '#FCC' );
459
- $( '#footer' ).css( 'background', '#CCF' );
460
- $( '#controls' ).css( 'background', '#BBD' );
461
- $( '#currentSlide' ).css( 'background', '#FFC' );
462
- }
508
+ doDebug();
463
509
 
464
510
  document.onkeyup = keys;
465
511
 
@@ -1 +1 @@
1
- /*********************************
2
1
  * CSS @media print rules (not projection or screen)
3
2
  */
4
3
  * Make sure all slides are visible (to make them all appear in prin)
5
4
  */
6
5
  display: block !important;
7
6
  }
8
7
  * Extra styling for first slide (title slide)
9
8
  */
10
9
  border-bottom: 1px dotted silver;
11
10
  }
12
11
  * Turn on print-specific stuff/classes
13
12
  */
14
13
  * Turn off online (screen/projection)-specific stuff/classes
15
14
  */
16
15
  * The following rule keeps the layout stuff out of print.
17
16
  * Remove at your own risk!
18
17
  */
18
+ /*********************************
19
19
  * CSS @media print rules (not projection or screen)
20
20
  */
21
21
  * Make sure all slides are visible (to make them all appear in prin)
22
22
  */
23
23
  display: block !important;
24
24
  }
25
25
  * Extra styling for first slide (title slide)
26
26
  */
27
27
  border-bottom: 1px dotted silver;
28
28
  }
29
29
  * Turn on print-specific stuff/classes
30
30
  */
31
31
  * Turn off online (screen/projection)-specific stuff/classes
32
32
  */
33
33
  * The following rule keeps the layout stuff out of print.
34
34
  * Remove at your own risk!
35
35
  */
@@ -15,6 +15,8 @@
15
15
 
16
16
  .layout * { display: none; }
17
17
 
18
+ .projection { display: none; }
19
+
18
20
  /*************
19
21
  * make toggle button visible and reposition to upper right corner *
20
22
  * note: toogle button is nested inside #controls > #navLinks > #toogle
@@ -8,9 +8,9 @@
8
8
  <meta name="author" content="<%= @headers['author']%>" >
9
9
 
10
10
  <!-- S6 style sheet links -->
11
- <link rel="stylesheet" href="<%= "#{@name}.css" %>" type="text/css" media="projection" id="styleProjection">
12
- <link rel="stylesheet" href="s6/screen.css" type="text/css" media="screen" id="styleScreen">
13
- <link rel="stylesheet" href="s6/print.css" type="text/css" media="print">
11
+ <link rel="stylesheet" href="<%= "#{@name}.css" %>" media="projection" id="styleProjection">
12
+ <link rel="stylesheet" href="s6/screen.css" media="screen" id="styleScreen">
13
+ <link rel="stylesheet" href="s6/print.css" media="print">
14
14
 
15
15
  <!-- S6 JS -->
16
16
  <script src="s6/jquery.js"></script>
@@ -47,6 +47,4 @@
47
47
 
48
48
  </div><!-- presentation -->
49
49
  </body>
50
- </html>
51
-
52
-
50
+ </html>
@@ -1,35 +1,91 @@
1
1
  @import url(s6/projection.css); /* required to make the slide show run at all */
2
2
 
3
- html, body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; }
3
+ body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; }
4
4
 
5
5
  a:link, a:visited { color: black; }
6
6
 
7
- h1 { font-size: 30pt; }
8
- h2 { font-size: 28pt; }
7
+ .slide h1 { font-size: 30pt; }
8
+
9
+ .slide h1 { text-align: center; }
10
+
11
+ .slide h1.fullscreen { position: absolute;
12
+ top: 40%;
13
+ width: 100%; }
14
+
15
+ /* lets you create slides with no heading (because heading is hidden but gets included in toc) */
16
+ .slide h1.hidden { display: none; }
17
+
18
+
19
+ .slide h2 { font-size: 28pt; }
20
+
9
21
  h3 { font-size: 25pt; }
22
+
23
+ /* todo: add special formating for .cover slide
24
+ lets you use h1(cover). for title/cover slide (a la S5 slide0) but more generic (not bound to 1st slide)
25
+ */
26
+
27
+ .cover h1 { /* tbd */ }
28
+ .cover h2 { /* tbd */ }
29
+
30
+ /* todo: add special formating for h1, h2 in footer */
31
+
32
+ #footer h1 { /* tbd */ }
33
+ #footer h2 { /* tbd */ }
34
+
35
+
10
36
  p, li, dt, dd, td, th { font-size: 18pt; }
11
37
 
38
+ ul { list-style-type: square; }
39
+
40
+ /**********************************/
41
+ /* general text-alignment classes */
42
+
43
+ .left { text-align: left; }
44
+ .center { text-align: center; }
45
+ .right { text-align: right; }
46
+
47
+ /**********************************/
48
+ /* general font-size classes */
49
+
50
+ .small { font-size: 97%; }
51
+
52
+ .x-small,
53
+ .smaller { font-size: 88%; }
54
+
55
+ .xx-small,
56
+ .smallest,
57
+ .tiny { font-size: 82%; }
58
+
59
+
60
+
12
61
  pre { font-size: 16pt; }
13
- pre.small { font-size: 12pt; }
14
62
 
15
- pre.code {
63
+ .code {
16
64
  background-color: azure;
17
65
  padding: 5px;
18
66
  }
67
+
68
+ .footnote a:first-of-type { text-decoration: none; }
19
69
 
20
- div.code {
21
- background-color: azure;
22
- padding: 5px;
23
- }
24
70
 
25
- ul { list-style-type: square; }
71
+ p.small { font-size: 97%; }
26
72
 
27
- .center { text-align: center; }
73
+ p.x-small,
74
+ p.smaller,
75
+ p.footnote { font-size: 88%; }
28
76
 
29
- /*** style rules for steps ****/
77
+ p.xx-small,
78
+ p.smallest,
79
+ p.tiny { font-size: 82%; }
30
80
 
31
- .stepcurrent { color: black; }
81
+
82
+ .help p,
83
+ .help td { font-size: 88%; }
84
+
85
+
32
86
  .step { color: silver; }
33
87
  /* or hide next steps e.g. .step { visibility: hidden; } */
88
+ .stepcurrent { color: black; }
89
+
34
90
 
35
91
  <%= content_for :css %>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 6
10
- version: 0.9.6
9
+ - 7
10
+ version: 0.9.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-18 00:00:00 +02:00
18
+ date: 2010-07-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,7 @@ files:
105
105
  - config/slideshow.yml
106
106
  - lib/slideshow.rb
107
107
  - lib/slideshow/config.rb
108
+ - lib/slideshow/fetch.rb
108
109
  - lib/slideshow/filters/debug_filter.rb
109
110
  - lib/slideshow/filters/headers_filter.rb
110
111
  - lib/slideshow/filters/slide_filter.rb
@@ -122,10 +123,12 @@ files:
122
123
  - lib/slideshow/helpers/syntax/uv_helper.rb
123
124
  - lib/slideshow/helpers/table_helper.rb
124
125
  - lib/slideshow/helpers/text_helper.rb
125
- - lib/slideshow/markdown.rb
126
+ - lib/slideshow/manifest.rb
127
+ - lib/slideshow/markup/markdown.rb
128
+ - lib/slideshow/markup/rest.rb
129
+ - lib/slideshow/markup/textile.rb
126
130
  - lib/slideshow/opts.rb
127
131
  - lib/slideshow/slide.rb
128
- - lib/slideshow/textile.rb
129
132
  - templates/s6.txt
130
133
  - templates/s6.txt.gen
131
134
  - templates/s6/jquery.js