slideshow 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY.md +4 -0
  3. data/Manifest.txt +3 -48
  4. data/{README.markdown → README.md} +134 -132
  5. data/Rakefile +26 -17
  6. data/lib/slideshow.rb +19 -97
  7. data/lib/slideshow/cli/main.rb +38 -20
  8. data/lib/slideshow/cli/main_utils.rb +10 -4
  9. data/lib/slideshow/cli/opts.rb +3 -1
  10. data/lib/slideshow/cli/version.rb +26 -0
  11. metadata +63 -147
  12. data/History.markdown +0 -171
  13. data/config/slideshow.builtin.yml +0 -8
  14. data/config/slideshow.index.yml +0 -61
  15. data/config/slideshow.yml +0 -76
  16. data/lib/slideshow/cli/commands/fetch.rb +0 -121
  17. data/lib/slideshow/cli/commands/gen.rb +0 -330
  18. data/lib/slideshow/cli/commands/gen_templates.rb +0 -52
  19. data/lib/slideshow/cli/commands/list.rb +0 -70
  20. data/lib/slideshow/cli/commands/plugins.rb +0 -44
  21. data/lib/slideshow/cli/commands/quick.rb +0 -86
  22. data/lib/slideshow/config.rb +0 -241
  23. data/lib/slideshow/filters/debug_filter.rb +0 -74
  24. data/lib/slideshow/filters/headers_filter.rb +0 -45
  25. data/lib/slideshow/filters/slide_filter.rb +0 -113
  26. data/lib/slideshow/filters/text_filter.rb +0 -140
  27. data/lib/slideshow/headers.rb +0 -87
  28. data/lib/slideshow/helpers/background_helper.rb +0 -121
  29. data/lib/slideshow/helpers/capture_helper.rb +0 -136
  30. data/lib/slideshow/helpers/directive_helper.rb +0 -43
  31. data/lib/slideshow/helpers/markdown_helper.rb +0 -18
  32. data/lib/slideshow/helpers/source_helper.rb +0 -39
  33. data/lib/slideshow/helpers/step_helper.rb +0 -33
  34. data/lib/slideshow/helpers/syntax/coderay_helper.rb +0 -84
  35. data/lib/slideshow/helpers/syntax/sh_helper.rb +0 -61
  36. data/lib/slideshow/helpers/syntax/uv_helper.rb +0 -90
  37. data/lib/slideshow/helpers/text_helper.rb +0 -130
  38. data/lib/slideshow/manifest_helpers.rb +0 -94
  39. data/lib/slideshow/markup/markdown.rb +0 -18
  40. data/lib/slideshow/markup/mediawiki.rb +0 -38
  41. data/lib/slideshow/markup/rest.rb +0 -17
  42. data/lib/slideshow/markup/textile.rb +0 -68
  43. data/lib/slideshow/plugin_helpers.rb +0 -62
  44. data/lib/slideshow/slide.rb +0 -118
  45. data/lib/slideshow/version.rb +0 -3
  46. data/templates/s6.txt +0 -27
  47. data/templates/s6.txt.gen +0 -19
  48. data/templates/s6/jquery.js +0 -8176
  49. data/templates/s6/jquery.microsoft.js +0 -31
  50. data/templates/s6/jquery.slideshow.js +0 -534
  51. data/templates/s6/print.css +0 -1
  52. data/templates/s6/projection.css +0 -109
  53. data/templates/s6/screen.css +0 -50
  54. data/templates/slides.html.erb +0 -55
  55. data/templates/slides.pdf.html.erb +0 -62
  56. data/templates/style.css.erb +0 -91
  57. data/templates/welcome.text +0 -167
  58. data/templates/welcome.txt.quick +0 -6
@@ -1,121 +0,0 @@
1
- module Slideshow
2
- module BackgroundHelper
3
-
4
- def gradient_from_headers( *args )
5
-
6
- return "" unless headers.has_gradient? # do nothing if use hasn't set gradient headers (ignore defaults)
7
-
8
- # lets you use headers (gradient, gradient-theme, gradient-colors)
9
- # to define gradient (see http://slideshow.rubyforge.org/themes.html for predefined themes)
10
-
11
- theme = headers[ :gradient_theme ]
12
- colors = headers[ :gradient_colors ].split(' ') # colors as space separated all-in-one string
13
-
14
- buf = ""
15
-
16
- if theme == 'diagonal'
17
- buf << "linear-gradient( top left, #{colors.join(', ')} )"
18
- elsif theme == 'top-bottom'
19
- buf << "linear-gradient( top, #{colors.join(', ')} )"
20
- elsif theme == 'left-right'
21
- buf << "linear-gradient( left, #{colors.join(', ')} )"
22
- elsif theme == 'repeat'
23
- buf << "repeating-linear-gradient( -60deg, #{colors.join(', ')} 10% )"
24
- elsif theme == 'radial'
25
- buf << "radial-gradient( #{colors.join(', ')} )"
26
- elsif theme == 'radial-off-center'
27
- buf << "radial-gradient( 70% 70%, ellipse, #{colors.join(', ')} )"
28
- elsif theme == 'radial-repeat'
29
- buf << "repeating-radial-gradient( 60% 60%, ellipse, #{colors.join(', ')} 10% )"
30
- else
31
- buf << "linear-gradient( #{colors.join(', ')} )"
32
- puts "warning: unknown gradient themes #{theme} - falling back to default"
33
- end
34
-
35
- puts " Adding CSS for gradient background style rule using headers..."
36
- puts " gradient-theme: #{theme}"
37
- puts " gradient-colors: #{colors.join(' ')}"
38
-
39
- content_for( :css, <<-EOS )
40
- /****
41
- * generated by gradient_from_headers helper; using headers:
42
- * gradient-theme: #{theme}
43
- * gradient-colors: #{colors.join(' ')}
44
- */
45
- .slide { background-image: -webkit-#{buf};
46
- background-image: -moz-#{buf};
47
- background-image: -ms-#{buf};
48
- background-image: -o-#{buf};
49
- background-image: #{buf};
50
- }
51
- EOS
52
- end
53
-
54
- def gradient( *args )
55
-
56
- # check for optional hash for options
57
- opts = args.last.kind_of?(Hash) ? args.pop : {}
58
-
59
- colors = args
60
-
61
- clazz = opts[:class] || ( 's9_gradient_linear_'+colors.join('_').gsub( /[(), ]/, '_' ).gsub( /_{2,}/, '_').gsub( /[^-\w]/, '' ) )
62
-
63
-
64
- ## generate code
65
-
66
- buf = "linear-gradient(top, #{colors.join(', ')} )"
67
-
68
-
69
- puts " Adding CSS for background style rule..."
70
- content_for( :css, <<-EOS )
71
- .#{clazz} { background-image: -webkit-#{buf};
72
- background-image: -moz-#{buf};
73
- background-image: -ms-#{buf};
74
- background-image: -o-#{buf};
75
- background-image: #{buf};
76
- }
77
- EOS
78
-
79
- # add processing instruction to get style class added to slide
80
-
81
- puts " Adding HTML PI for background style class '#{clazz}'..."
82
- "<!-- _S9STYLE_ #{clazz} -->\n"
83
- end
84
-
85
- def background( *args )
86
-
87
- # make everyting optional; use it like:
88
- # background( code, opts={} )
89
-
90
- # check for optional hash for options
91
- opts = args.last.kind_of?(Hash) ? args.pop : {}
92
-
93
- # check for optional style rule code
94
- code = args.last.kind_of?(String) ? args.pop : ''
95
-
96
- clazz = opts[:class] || ( 's9'+code.strip.gsub( /[(), ]/, '_' ).gsub( /_{2,}/, '_').gsub( /[^-\w]/, '' ) )
97
-
98
- # 1) add background rule to css
99
- # e.g. .simple { background: -moz-linear-gradient(top, blue, white); }
100
-
101
- unless code.empty?
102
- puts " Adding CSS for background style rule..."
103
- content_for( :css, <<-EOS )
104
- .#{clazz} { background: #{code}; }
105
- EOS
106
- end
107
-
108
- # 2) add processing instruction to get style class added to slide
109
-
110
- puts " Adding HTML PI for background style class '#{clazz}'..."
111
- "<!-- _S9STYLE_ #{clazz} -->\n"
112
- end
113
-
114
-
115
-
116
- end # module BackgroundHelper
117
- end # module Slideshow
118
-
119
- class Slideshow::Gen
120
- include Slideshow::BackgroundHelper
121
- end
@@ -1,136 +0,0 @@
1
- # Originally based on code from Rails and Merb; adapted from Webby.
2
-
3
- module Slideshow
4
- module CaptureHelper
5
-
6
- # Called in pages and partials to store up content for later use. Takes a
7
- # string and/or a block. First, the string is evaluated, and then the
8
- # block is captured using the capture() helper provided by the template
9
- # languages. The two are concatenated together.
10
- #
11
- # Content is retrieved by calling the method without a string or a block.
12
- #
13
- # ==== Parameters
14
- # obj<Object>:: The key in the content_for hash.
15
- # string<String>:: Textual content. Defaults to nil.
16
- # &block:: A block to be evaluated and concatenated to string.
17
- #
18
- # ==== Returns
19
- # Any content associated with the key (or nil).
20
- #
21
- # ==== Example
22
- # content_for(:foo, "Foo")
23
- # content_for(:foo) #=> "Foo"
24
- # content_for(:foo, "Bar")
25
- # content_for(:foo) #=> "FooBar"
26
- #
27
- def content_for( obj, string = nil, &block )
28
- return @content_for[obj] unless string || block_given?
29
-
30
- cur = @content_for[obj].to_s
31
- new = string.to_s + (block_given? ? capture_erb(&block) : "")
32
- @content_for[obj] = cur + new
33
- end
34
-
35
- # Returns true if there is content for the given key. Otherwise returns
36
- # false.
37
- #
38
- # ==== Parameters
39
- # obj<Object>:: The key in the conetnt_for hash.
40
- #
41
- # ==== Example
42
- # content_for(:foo, "Foo")
43
- # content_for?(:foo) #=> true
44
- # content_for?(:bar) #=> false
45
- #
46
- def content_for?( obj )
47
- @content_for.key?(obj)
48
- end
49
-
50
- # Deletes any content associated with the given object in the content_for
51
- # hash.
52
- #
53
- # ==== Parameters
54
- # obj<Object>:: The key in the conetnt_for hash.
55
- #
56
- # ==== Returns
57
- # Any content associated with the key (or nil).
58
- #
59
- # ==== Example
60
- # content_for(:foo, "Foo")
61
- # content_for?(:foo) #=> true
62
- # delete_content_for(:foo)
63
- # content_for?(:foo) #=> false
64
- #
65
- def delete_content_for( obj )
66
- @content_for.delete(obj)
67
- end
68
-
69
- # This method is used to capture content from an ERB filter evaluation. It
70
- # is useful to helpers that need to process chunks of data during ERB filter
71
- # processing.
72
- #
73
- # ==== Parameters
74
- # *args:: Arguments to pass to the block.
75
- # &block:: The ERB block to call.
76
- #
77
- # ==== Returns
78
- # String:: The output of the block.
79
- #
80
- # ==== Examples
81
- # Capture being used in an ERB page:
82
- #
83
- # <% @foo = capture_erb do %>
84
- # <p>Some Foo content!</p>
85
- # <% end %>
86
- #
87
- def capture_erb( *args, &block )
88
- # get the buffer from the block's binding
89
- buffer = _erb_buffer(block.binding) rescue nil
90
-
91
- # If there is no buffer, just call the block and get the contents
92
- if buffer.nil?
93
- block.call(*args)
94
- # If there is a buffer, execute the block, then extract its contents
95
- else
96
- pos = buffer.length
97
- block.call(*args)
98
-
99
- # extract the block
100
- data = buffer[pos..-1]
101
-
102
- # replace it in the original with empty string
103
- buffer[pos..-1] = ""
104
-
105
- data
106
- end
107
- end
108
-
109
- # This method is used to concatenate content into the ERB output buffer.
110
- # It is usefule to helpers that need to insert transformed text back into
111
- # the ERB output buffer.
112
- #
113
- # ==== Parameters
114
- # string<String>:: The string to insert into the ERB output.
115
- # the_binding<Binding>:: The binding to pass to the buffer.
116
- #
117
- def concat_erb( string, the_binding )
118
- _erb_buffer(the_binding) << string
119
- end
120
-
121
- # Provides direct acccess to the ERB buffer in the conext of the binding.
122
- #
123
- # ==== Parameters
124
- # the_binding<Binding>:: The binding to pass to the buffer.
125
- #
126
- # ==== Returns
127
- # The current ERB output buffer.
128
- #
129
- def _erb_buffer( the_binding )
130
- eval('_erbout', the_binding, __FILE__, __LINE__)
131
- end
132
-
133
- end # module CaptureHelper
134
- end # module Slideshow
135
-
136
- Slideshow::Gen.__send__( :include, Slideshow::CaptureHelper )
@@ -1,43 +0,0 @@
1
- module Slideshow
2
- module DirectiveHelper
3
-
4
- # css directive:
5
- #
6
- # lets you use:
7
- # %css
8
- # -- inline css code here
9
- # %end
10
- #
11
- # shortcut for:
12
- # %content_for :css
13
- # -- inline css code here
14
- # %end
15
- # or
16
- # <% content_for :css do %>
17
- # -- inline css code here
18
- # <% end %>
19
-
20
- def css( &block )
21
- content_for( :css, nil, &block )
22
- end
23
-
24
- def slide( params )
25
- # note: to avoid runons with blocks (wrap in double newlines)
26
-
27
- "\n\n<!-- _S9SLIDE_ #{params ? params : ''} -->\n\n"
28
- end
29
-
30
- def style( params )
31
- # note: to avoid runons with blocks (wrap in double newlines)
32
-
33
- "\n\n<!-- _S9STYLE_ #{params ? params : ''} -->\n\n"
34
- end
35
-
36
-
37
- end # module DirectiveHelper
38
- end # module Slideshow
39
-
40
- class Slideshow::Gen
41
- include Slideshow::DirectiveHelper
42
- end
43
-
@@ -1,18 +0,0 @@
1
- module Slideshow
2
- module MarkdownHelper
3
-
4
- def s9_class( clazz )
5
- "{: .#{clazz.strip}}"
6
- end
7
-
8
- def clear
9
- "{: .clear}"
10
- end
11
-
12
-
13
- end # module MarkdownHelper
14
- end # module Slideshow
15
-
16
- class Slideshow::Gen
17
- include Slideshow::MarkdownHelper
18
- end
@@ -1,39 +0,0 @@
1
- module Slideshow
2
- module SourceHelper
3
-
4
-
5
- def source( *args )
6
-
7
- # make everyting optional; use it like:
8
- # source( name_or_path, opts={} )
9
-
10
- # check for optional hash for options
11
- opts = args.last.kind_of?(Hash) ? args.pop : {}
12
-
13
- # check for optional name or path
14
- name_or_path = args.last.kind_of?(String) ? args.pop : "#{@name}#{@extname}"
15
-
16
- link_text = opts[:text] || '(Source)'
17
-
18
- # add extra path (e.g. 3rd) if present
19
- name_or_path = "#{opts[:path]}/#{name_or_path}" if opts[:path]
20
-
21
- # add file extension if missing (for convenience)
22
- name_or_path << @extname if File.extname( name_or_path ).empty?
23
-
24
- base = 'http://github.com/geraldb/slideshow/raw/master/samples'
25
-
26
- buf = "<a href='#{base}/#{name_or_path}'>#{link_text}</a>"
27
-
28
- puts " Adding HTML for source link to '#{name_or_path}'..."
29
-
30
- guard_inline( buf )
31
- end
32
-
33
-
34
- end # module SourceHelper
35
- end # module Slideshow
36
-
37
- class Slideshow::Gen
38
- include Slideshow::SourceHelper
39
- end
@@ -1,33 +0,0 @@
1
- module Slideshow
2
- module StepHelper
3
-
4
-
5
- def step( opts={}, &blk )
6
-
7
- puts " Adding HTML div block for step (incremental display)..."
8
-
9
- text = capture_erb(&blk)
10
-
11
- before = "<!-- begin step #{opts.inspect} -->\n"
12
- before << "<div class='step' markdown='block'>\n"
13
-
14
- after = "</div>\n"
15
- after << "<!-- end step -->\n"
16
-
17
- html = ""
18
- html << guard_block( before )
19
- html << text
20
- html << guard_block( after )
21
-
22
- concat_erb( html, blk.binding )
23
- return
24
- end
25
-
26
-
27
- end # module StepHelper
28
- end # module Slideshow
29
-
30
- class Slideshow::Gen
31
- include Slideshow::StepHelper
32
- end
33
-
@@ -1,84 +0,0 @@
1
- require 'coderay'
2
-
3
- module Slideshow
4
- module Syntax
5
- module CodeRayHelper
6
-
7
- # coderay option defaults
8
- CR_LANG = 'ruby'
9
- CR_LINE_NUMBERS = 'table' # table | list | inline
10
-
11
- def coderay_worker( code, opts )
12
-
13
- lang = opts.fetch( :lang, CR_LANG )
14
- line_numbers = opts.fetch( :line_numbers, headers.get('code-line-numbers', CR_LINE_NUMBERS ) )
15
- line_number_start = opts.fetch( :start, nil )
16
-
17
- cr_opts = {}
18
- cr_opts[ :line_numbers ] = line_numbers.to_sym
19
- cr_opts[ :line_number_start ] = line_number_start.to_i if line_number_start
20
-
21
- # todo: add options for bold_every, tab_width (any others?)
22
-
23
- code_highlighted = CodeRay.scan( code, lang.to_sym ).html(cr_opts)
24
-
25
- # first time? get built-in coderay stylesheet
26
- cr_first_time = session.fetch( :cr_first_time, true )
27
- if cr_first_time
28
- session[ :cr_first_time ] = false
29
-
30
- theme_content = CodeRay::Encoders[:html]::CSS.new.stylesheet
31
-
32
- theme_out = %{/* styles for built-in coderay syntax highlighting theme */\n\n}
33
- theme_out << theme_content
34
- theme_out << %{\n\n}
35
-
36
- content_for( :css, theme_out )
37
- end
38
-
39
- css_class = 'code'
40
- css_class_opt = opts.fetch( :class, nil ) # large, small, tiny, etc.
41
- css_class << " #{css_class_opt}" if css_class_opt # e.g. use/allow multiple classes -> code small, code large, etc.
42
-
43
- name = opts.fetch( :name, nil )
44
- txmt_value = opts.fetch( :txmt, headers.code_txmt )
45
- txmt = (txmt_value =~ /true|yes|on/i) ? true : false
46
-
47
- out = %{<div class='CodeRay'>}
48
- out << %{<pre '#{css_class}'>\n}
49
- out << code_highlighted
50
- out << %{</pre>}
51
- out << %{</div>}
52
-
53
- # add optional href link for textmate
54
- if name
55
- out << %{<div class="codeurl">}
56
- out << %{<a href="txmt://open?url=file://#{File.expand_path(name)}">} if txmt
57
- out << name
58
- out << %{</a>} if txmt
59
- out << %{</div>\n}
60
- end
61
-
62
- return out
63
- end
64
-
65
- def coderay( *args, &blk )
66
- # check for optional hash for options
67
- opts = args.last.kind_of?(Hash) ? args.pop : {}
68
-
69
- code = capture_erb(&blk)
70
- return if code.empty?
71
-
72
- code_highlighted = coderay_worker( code, opts )
73
-
74
- concat_erb( wrap_markup( code_highlighted ), blk.binding )
75
- return
76
- end
77
-
78
- end # module CodeRayHelper
79
- end # module Syntax
80
- end # module Slideshow
81
-
82
- class Slideshow::Gen
83
- include Slideshow::Syntax::CodeRayHelper
84
- end