slideshow 0.4 → 0.4.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/lib/slideshow.rb +55 -10
 - data/lib/templates/gradient.svg.erb +21 -21
 - data/lib/templates/header.html.erb +1 -1
 - metadata +2 -2
 
    
        data/lib/slideshow.rb
    CHANGED
    
    | 
         @@ -12,10 +12,10 @@ module Slideshow 
     | 
|
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            class Params
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              def initialize(  
     | 
| 
       16 
     | 
    
         
            -
                  @title   = title
         
     | 
| 
      
 15 
     | 
    
         
            +
              def initialize( name, headers )
         
     | 
| 
       17 
16 
     | 
    
         
             
                  @svgname =  "#{name}.svg"
         
     | 
| 
       18 
17 
     | 
    
         
             
                  @cssname =  "#{name}.css"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @headers =  headers
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              def params_binding
         
     | 
| 
         @@ -61,8 +61,6 @@ def Slideshow.create_slideshow( fn ) 
     | 
|
| 
       61 
61 
     | 
    
         
             
              basename = File.basename( fn, '.*' )
         
     | 
| 
       62 
62 
     | 
    
         
             
              extname  = File.extname( fn )
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
              params = Params.new( "Slideshow", basename )
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
64 
     | 
    
         
             
              known_textile_extnames = [ '.textile', '.t' ]
         
     | 
| 
       67 
65 
     | 
    
         
             
              known_markdown_extnames =  [ '.markdown', '.mark', '.m', '.txt', '.text' ]
         
     | 
| 
       68 
66 
     | 
    
         
             
              known_extnames = known_textile_extnames + known_markdown_extnames
         
     | 
| 
         @@ -110,6 +108,15 @@ def Slideshow.create_slideshow( fn ) 
     | 
|
| 
       110 
108 
     | 
    
         
             
                end
         
     | 
| 
       111 
109 
     | 
    
         
             
              end
         
     | 
| 
       112 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
              # run pre-filters (built-in macros)
         
     | 
| 
      
 112 
     | 
    
         
            +
              # o replace {{{  w/ <pre class='code'>
         
     | 
| 
      
 113 
     | 
    
         
            +
              # o replace }}}  w/ </pre>
         
     | 
| 
      
 114 
     | 
    
         
            +
              content.gsub!( "{{{", "<pre class='code'>" )
         
     | 
| 
      
 115 
     | 
    
         
            +
              content.gsub!( "}}}", "</pre>" )
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              set_default_options()
         
     | 
| 
      
 118 
     | 
    
         
            +
              params = Params.new( basename, $options )
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
       113 
120 
     | 
    
         
             
              puts "Preparing slideshow theme '#{svgname}'..."
         
     | 
| 
       114 
121 
     | 
    
         | 
| 
       115 
122 
     | 
    
         
             
              out = File.new( svgname, "w+" )
         
     | 
| 
         @@ -134,9 +141,9 @@ def Slideshow.create_slideshow( fn ) 
     | 
|
| 
       134 
141 
     | 
    
         
             
              slide_counter = 0
         
     | 
| 
       135 
142 
     | 
    
         
             
              content2 = ''
         
     | 
| 
       136 
143 
     | 
    
         | 
| 
       137 
     | 
    
         
            -
              # wrap h1's in slide divs
         
     | 
| 
      
 144 
     | 
    
         
            +
              # wrap h1's in slide divs; note use just <h1 since some processors add ids e.g. <h1 id='x'>
         
     | 
| 
       138 
145 
     | 
    
         
             
              content.each_line { |line|
         
     | 
| 
       139 
     | 
    
         
            -
                 if line.include?( '<h1 
     | 
| 
      
 146 
     | 
    
         
            +
                 if line.include?( '<h1' ) then
         
     | 
| 
       140 
147 
     | 
    
         
             
                    content2 << "\n\n</div>"  if slide_counter > 0
         
     | 
| 
       141 
148 
     | 
    
         
             
                    content2 << "<div class='slide'>\n\n"
         
     | 
| 
       142 
149 
     | 
    
         
             
                    slide_counter += 1
         
     | 
| 
         @@ -152,9 +159,12 @@ def Slideshow.create_slideshow( fn ) 
     | 
|
| 
       152 
159 
     | 
    
         
             
                doc.search("pre.code, pre > code").each do |e|
         
     | 
| 
       153 
160 
     | 
    
         
             
                  if e.inner_html =~ /^\s*#!(\w+)/
         
     | 
| 
       154 
161 
     | 
    
         
             
                    lang = $1.downcase
         
     | 
| 
       155 
     | 
    
         
            -
                    logger.debug "  lang=#{lang}"
         
     | 
| 
      
 162 
     | 
    
         
            +
                    logger.debug "  syntax highlighting using lang=#{lang}"
         
     | 
| 
       156 
163 
     | 
    
         
             
                    if Uv.syntaxes.include?(lang)
         
     | 
| 
       157 
     | 
    
         
            -
                      e.inner_html = Uv.parse( e.inner_html.sub(/^\s*#!\w+/, '').strip, "xhtml", lang, get_boolean_option( 'code-line-numbers', true ), get_option( 'code-theme', 'amy' ))
         
     | 
| 
      
 164 
     | 
    
         
            +
                      # e.inner_html = Uv.parse( e.inner_html.sub(/^\s*#!\w+/, '').strip, "xhtml", lang, get_boolean_option( 'code-line-numbers', true ), get_option( 'code-theme', 'amy' ))
         
     | 
| 
      
 165 
     | 
    
         
            +
                      # todo: is it ok to replace the pre.code enclosing element to avoid duplicates?
         
     | 
| 
      
 166 
     | 
    
         
            +
                      html = Uv.parse( e.inner_html.sub(/^\s*#!\w+/, '').strip, "xhtml", lang, get_boolean_option( 'code-line-numbers', true ), get_option( 'code-theme', 'amy' ))
         
     | 
| 
      
 167 
     | 
    
         
            +
                      e.swap( html )
         
     | 
| 
       158 
168 
     | 
    
         
             
                      include_code_stylesheet = true
         
     | 
| 
       159 
169 
     | 
    
         
             
                    end
         
     | 
| 
       160 
170 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -205,9 +215,44 @@ def Slideshow.logger 
     | 
|
| 
       205 
215 
     | 
    
         
             
            end
         
     | 
| 
       206 
216 
     | 
    
         | 
| 
       207 
217 
     | 
    
         | 
| 
      
 218 
     | 
    
         
            +
            def Slideshow.set_default_options()
         
     | 
| 
      
 219 
     | 
    
         
            +
              defaults =
         
     | 
| 
      
 220 
     | 
    
         
            +
              [
         
     | 
| 
      
 221 
     | 
    
         
            +
                [ 'title',             'Untitled Slide Show' ],
         
     | 
| 
      
 222 
     | 
    
         
            +
                [ 'gradient-theme',    'dark' ],
         
     | 
| 
      
 223 
     | 
    
         
            +
                [ 'gradient-color1',   'red' ],
         
     | 
| 
      
 224 
     | 
    
         
            +
                [ 'gradient-color2',   'black' ],
         
     | 
| 
      
 225 
     | 
    
         
            +
                [ 'code-theme',        'amy' ],
         
     | 
| 
      
 226 
     | 
    
         
            +
                [ 'code-line-numbers', 'true' ]
         
     | 
| 
      
 227 
     | 
    
         
            +
              ]
         
     | 
| 
      
 228 
     | 
    
         
            +
              
         
     | 
| 
      
 229 
     | 
    
         
            +
              defaults.each do | item |
         
     | 
| 
      
 230 
     | 
    
         
            +
                 key   = item[0]
         
     | 
| 
      
 231 
     | 
    
         
            +
                 value = item[1]
         
     | 
| 
      
 232 
     | 
    
         
            +
                 $options[ key ] = value if $options[ key ].nil?
         
     | 
| 
      
 233 
     | 
    
         
            +
              end
         
     | 
| 
      
 234 
     | 
    
         
            +
            end
         
     | 
| 
       208 
235 
     | 
    
         | 
| 
       209 
236 
     | 
    
         
             
            def Slideshow.store_option( key, value )
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
      
 237 
     | 
    
         
            +
              key = key.downcase
         
     | 
| 
      
 238 
     | 
    
         
            +
              if key.eql? 'code-theme' then
         
     | 
| 
      
 239 
     | 
    
         
            +
                $options[ 'code-theme' ] = value.tr( '-', '_' )
         
     | 
| 
      
 240 
     | 
    
         
            +
              elsif key.eql? 'gradient' then
         
     | 
| 
      
 241 
     | 
    
         
            +
                values = value.split( ' ' )
         
     | 
| 
      
 242 
     | 
    
         
            +
                $options[ 'gradient-theme'  ] = values[0].tr( '-', '_' )
         
     | 
| 
      
 243 
     | 
    
         
            +
                $options[ 'gradient-color1' ] = values[1] if values[1] 
         
     | 
| 
      
 244 
     | 
    
         
            +
                $options[ 'gradient-color2' ] = values[2] if values[2]
         
     | 
| 
      
 245 
     | 
    
         
            +
              elsif key.eql? 'gradient-colors' then
         
     | 
| 
      
 246 
     | 
    
         
            +
                values = value.split( ' ' )
         
     | 
| 
      
 247 
     | 
    
         
            +
                $options[ 'gradient-color1' ] = values[0] 
         
     | 
| 
      
 248 
     | 
    
         
            +
                $options[ 'gradient-color2' ] = values[1] if values[1]
         
     | 
| 
      
 249 
     | 
    
         
            +
              elsif key.eql? 'gradient-color' then
         
     | 
| 
      
 250 
     | 
    
         
            +
                $options[ 'gradient-color1' ] = value
         
     | 
| 
      
 251 
     | 
    
         
            +
              elsif key.eql? 'gradient-theme' then
         
     | 
| 
      
 252 
     | 
    
         
            +
                $options[ 'gradient-theme' ] = value.tr( '-', '_' )
         
     | 
| 
      
 253 
     | 
    
         
            +
              else
         
     | 
| 
      
 254 
     | 
    
         
            +
                $options[ key ] = value
         
     | 
| 
      
 255 
     | 
    
         
            +
              end
         
     | 
| 
       211 
256 
     | 
    
         
             
            end
         
     | 
| 
       212 
257 
     | 
    
         | 
| 
       213 
258 
     | 
    
         
             
            def Slideshow.get_option( key, default )
         
     | 
| 
         @@ -261,7 +306,7 @@ def Slideshow.main 
     | 
|
| 
       261 
306 
     | 
    
         | 
| 
       262 
307 
     | 
    
         
             
              opt.parse!
         
     | 
| 
       263 
308 
     | 
    
         | 
| 
       264 
     | 
    
         
            -
              puts "Slide Show (S9) Version: 0.4 on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
         
     | 
| 
      
 309 
     | 
    
         
            +
              puts "Slide Show (S9) Version: 0.4.1 on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
         
     | 
| 
       265 
310 
     | 
    
         | 
| 
       266 
311 
     | 
    
         
             
              ARGV.each { |fn| Slideshow.create_slideshow( fn ) }
         
     | 
| 
       267 
312 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,58 +2,58 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
              <defs>
         
     | 
| 
       4 
4 
     | 
    
         
             
                <linearGradient id="dark" x1="0" y1="0" x2="1" y2="1">
         
     | 
| 
       5 
     | 
    
         
            -
                  <stop offset="0" style="stop-color:  
     | 
| 
       6 
     | 
    
         
            -
                  <stop offset="1" style="stop-color:  
     | 
| 
      
 5 
     | 
    
         
            +
                  <stop offset="0" style="stop-color: <%= @headers['gradient-color1'] %>"/>
         
     | 
| 
      
 6 
     | 
    
         
            +
                  <stop offset="1" style="stop-color: <%= @headers['gradient-color2'] %>"/>
         
     | 
| 
       7 
7 
     | 
    
         
             
                </linearGradient>
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                <linearGradient id="dark_reverse" x1="0" y1="0" x2="1" y2="1">
         
     | 
| 
       10 
     | 
    
         
            -
                  <stop offset="0" style="stop-color:  
     | 
| 
       11 
     | 
    
         
            -
                  <stop offset="1" style="stop-color:  
     | 
| 
      
 10 
     | 
    
         
            +
                  <stop offset="0" style="stop-color: <%= @headers['gradient-color2'] %>"/>
         
     | 
| 
      
 11 
     | 
    
         
            +
                  <stop offset="1" style="stop-color: <%= @headers['gradient-color1'] %>"/>
         
     | 
| 
       12 
12 
     | 
    
         
             
                </linearGradient>
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                 <linearGradient id="light" x1="0" y1="0" x2="1" y2="1">
         
     | 
| 
       15 
     | 
    
         
            -
                  <stop offset="0" style="stop-color:  
     | 
| 
       16 
     | 
    
         
            -
                  <stop offset="1" style="stop-color:  
     | 
| 
      
 15 
     | 
    
         
            +
                  <stop offset="0" style="stop-color: <%= @headers['gradient-color1'] %>"/>
         
     | 
| 
      
 16 
     | 
    
         
            +
                  <stop offset="1" style="stop-color: <%= @headers['gradient-color2'] %>"/>
         
     | 
| 
       17 
17 
     | 
    
         
             
                </linearGradient>
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                <linearGradient id="top_bottom" x1="0" y1="0" x2="0" y2="1">
         
     | 
| 
       20 
     | 
    
         
            -
                   <stop offset="0%"   style="stop-color:  
     | 
| 
       21 
     | 
    
         
            -
                   <stop offset="100%" style="stop-color:  
     | 
| 
      
 20 
     | 
    
         
            +
                   <stop offset="0%"   style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
      
 21 
     | 
    
         
            +
                   <stop offset="100%" style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
       22 
22 
     | 
    
         
             
                </linearGradient>
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
               <linearGradient id="left_right" x1="0" y1="0" x2="1" y2="0">
         
     | 
| 
       25 
     | 
    
         
            -
                 <stop offset="0%"   style="stop-color:  
     | 
| 
       26 
     | 
    
         
            -
                 <stop offset="100%" style="stop-color:  
     | 
| 
      
 25 
     | 
    
         
            +
                 <stop offset="0%"   style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
      
 26 
     | 
    
         
            +
                 <stop offset="100%" style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
       27 
27 
     | 
    
         
             
               </linearGradient>
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                <linearGradient id="repeat" x1="0.4" y1="0.4" x2="0.5" y2="0.5"
         
     | 
| 
       30 
30 
     | 
    
         
             
                     spreadMethod="repeat">
         
     | 
| 
       31 
     | 
    
         
            -
                 <stop offset="0%"   style="stop-color:  
     | 
| 
       32 
     | 
    
         
            -
                 <stop offset="50%"  style="stop-color:  
     | 
| 
       33 
     | 
    
         
            -
                 <stop offset="100%" style="stop-color:  
     | 
| 
      
 31 
     | 
    
         
            +
                 <stop offset="0%"   style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
      
 32 
     | 
    
         
            +
                 <stop offset="50%"  style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
      
 33 
     | 
    
         
            +
                 <stop offset="100%" style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
       34 
34 
     | 
    
         
             
               </linearGradient>
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
               <radialGradient id="radial">
         
     | 
| 
       37 
     | 
    
         
            -
                <stop offset="0%"   style="stop-color:  
     | 
| 
       38 
     | 
    
         
            -
                <stop offset="100%" style="stop-color:  
     | 
| 
      
 37 
     | 
    
         
            +
                <stop offset="0%"   style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
      
 38 
     | 
    
         
            +
                <stop offset="100%" style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
       39 
39 
     | 
    
         
             
               </radialGradient>
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
               <radialGradient id="radial_off_center" fx="0.7" fy="0.7" cx="0.5" cy="0.5" r="0.4">
         
     | 
| 
       43 
     | 
    
         
            -
                 <stop offset="0%"   style="stop-color:  
     | 
| 
       44 
     | 
    
         
            -
                 <stop offset="100%" style="stop-color:  
     | 
| 
      
 43 
     | 
    
         
            +
                 <stop offset="0%"   style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
      
 44 
     | 
    
         
            +
                 <stop offset="100%" style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
       45 
45 
     | 
    
         
             
               </radialGradient>
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
              <radialGradient id="radial_repeat" fx="0.5" fy="0.5" cx="0.6" cy="0.6" r="0.2"
         
     | 
| 
       48 
48 
     | 
    
         
             
                      spreadMethod="repeat">
         
     | 
| 
       49 
     | 
    
         
            -
                 <stop offset="0%"   style="stop-color:  
     | 
| 
       50 
     | 
    
         
            -
                 <stop offset="50%"  style="stop-color:  
     | 
| 
       51 
     | 
    
         
            -
                 <stop offset="100%" style="stop-color:  
     | 
| 
      
 49 
     | 
    
         
            +
                 <stop offset="0%"   style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
      
 50 
     | 
    
         
            +
                 <stop offset="50%"  style="stop-color: <%= @headers['gradient-color2'] %>" />
         
     | 
| 
      
 51 
     | 
    
         
            +
                 <stop offset="100%" style="stop-color: <%= @headers['gradient-color1'] %>" />
         
     | 
| 
       52 
52 
     | 
    
         
             
              </radialGradient>
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
              </defs>
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
56 
     | 
    
         
             
              <rect width="100%" height="100%"
         
     | 
| 
       57 
     | 
    
         
            -
                        style="fill: url( 
     | 
| 
      
 57 
     | 
    
         
            +
                        style="fill: url(#<%= @headers['gradient-theme'] %>) "/>
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
59 
     | 
    
         
             
            </svg>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: slideshow
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Gerald Bauer
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2008-05- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-05-18 00:00:00 -07:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |