slideshow 0.9.1 → 0.9.2
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 +9 -0
- data/Manifest.txt +11 -9
- data/config/slideshow.builtin.yml +11 -3
- data/config/slideshow.yml +6 -0
- data/lib/slideshow.rb +11 -3
- data/lib/slideshow/config.rb +19 -4
- data/lib/slideshow/filters/debug_filter.rb +44 -0
- data/lib/slideshow/filters/headers_filter.rb +4 -3
- data/lib/slideshow/filters/text_filter.rb +218 -43
- data/lib/slideshow/gen.rb +35 -25
- data/lib/slideshow/helpers/analytics_helper.rb +7 -4
- data/lib/slideshow/helpers/background_helper.rb +91 -0
- data/lib/slideshow/helpers/capture_helper.rb +4 -2
- data/lib/slideshow/helpers/directive_helper.rb +42 -0
- data/lib/slideshow/helpers/markdown_helper.rb +18 -0
- data/lib/slideshow/helpers/source_helper.rb +39 -0
- data/lib/slideshow/helpers/step_helper.rb +6 -4
- data/lib/slideshow/helpers/{coderay_helper.rb → syntax/coderay_helper.rb} +9 -3
- data/lib/slideshow/helpers/syntax/sh_helper.rb +48 -0
- data/lib/slideshow/helpers/{uv_helper.rb → syntax/uv_helper.rb} +9 -4
- data/lib/slideshow/helpers/table_helper.rb +8 -6
- data/lib/slideshow/helpers/text_helper.rb +7 -5
- data/lib/slideshow/markdown.rb +4 -2
- data/lib/slideshow/opts.rb +1 -1
- data/lib/slideshow/textile.rb +5 -4
- data/templates/s6.txt +15 -5
- data/templates/s6.txt.gen +6 -5
- data/templates/s6/slides.css +0 -3
- data/templates/{s6/header.html.erb → slides.html.erb} +33 -23
- data/templates/{s6/header.pdf.html.erb → slides.pdf.html.erb} +10 -1
- data/templates/style.css.erb +35 -0
- metadata +15 -13
- data/templates/gradient.svg.erb +0 -59
- data/templates/s6.txt.sample +0 -16
- data/templates/s6/footer.html.erb +0 -4
- data/templates/s6/footer.pdf.html.erb +0 -3
- data/templates/s6/style.css.erb +0 -33
data/lib/slideshow/gen.rb
CHANGED
@@ -60,11 +60,29 @@ class Gen
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def guard_text( text )
|
63
|
+
# todo/fix 2: note for Textile we need to differentiate between blocks and inline
|
64
|
+
# thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)
|
65
|
+
|
63
66
|
# todo/fix: remove wrap_markup; replace w/ guard_text
|
64
67
|
# why: text might be css, js, not just html
|
65
68
|
wrap_markup( text )
|
66
69
|
end
|
67
70
|
|
71
|
+
def guard_block( text )
|
72
|
+
if markup_type == :textile
|
73
|
+
# saveguard with notextile wrapper etc./no further processing needed
|
74
|
+
# note: add leading newlines to avoid block-runons
|
75
|
+
"\n\n<notextile>\n#{text}\n</notextile>\n"
|
76
|
+
else
|
77
|
+
text
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def guard_inline( text )
|
82
|
+
wrap_markup( text )
|
83
|
+
end
|
84
|
+
|
85
|
+
|
68
86
|
def wrap_markup( text )
|
69
87
|
if markup_type == :textile
|
70
88
|
# saveguard with notextile wrapper etc./no further processing needed
|
@@ -479,7 +497,10 @@ class Gen
|
|
479
497
|
|
480
498
|
# shared variables for templates (binding)
|
481
499
|
@content_for = {} # reset content_for hash
|
500
|
+
|
482
501
|
@name = basename
|
502
|
+
@extname = extname
|
503
|
+
|
483
504
|
@headers = @opts # deprecate/remove: use headers method in template
|
484
505
|
|
485
506
|
@session = {} # reset session hash for plugins/helpers
|
@@ -490,11 +511,6 @@ class Gen
|
|
490
511
|
|
491
512
|
content = File.read( inname )
|
492
513
|
|
493
|
-
# fix: add to comment text filter as first rule!!
|
494
|
-
# check for !SLIDE alias %slide (needs to get coverted to ! otherwise
|
495
|
-
# it gets removed as a comment)
|
496
|
-
content.gsub!(/^%slide/, '!SLIDE' )
|
497
|
-
|
498
514
|
# run text filters
|
499
515
|
|
500
516
|
config.text_filters.each do |filter|
|
@@ -502,20 +518,6 @@ class Gen
|
|
502
518
|
content = send( mn, content ) # call filter e.g. include_helper_hack( content )
|
503
519
|
end
|
504
520
|
|
505
|
-
# check for !SLIDE markers; change to HTML comments
|
506
|
-
|
507
|
-
# -- slide marker stats
|
508
|
-
slide_markers = 0
|
509
|
-
|
510
|
-
## todo: use html processing instruction <?s9 slide ?>
|
511
|
-
content.gsub!(/^!SLIDE(.*)/ ) do |match|
|
512
|
-
slide_markers += 1
|
513
|
-
"<!-- _S9SLIDE_ #{$1} -->"
|
514
|
-
end
|
515
|
-
|
516
|
-
puts " Processing directives (#{slide_markers} !SLIDE-directives)..."
|
517
|
-
|
518
|
-
|
519
521
|
# convert light-weight markup to hypertext
|
520
522
|
|
521
523
|
content = text_to_html( content )
|
@@ -545,16 +547,24 @@ class Gen
|
|
545
547
|
end
|
546
548
|
|
547
549
|
## split slide source into header (optional) and content/body
|
548
|
-
## plus check for classes
|
550
|
+
## plus check for (css style) classes
|
549
551
|
|
550
552
|
slides2 = []
|
551
553
|
slides.each do |slide_source|
|
552
554
|
slide = Slide.new
|
553
|
-
|
554
|
-
## check for css style
|
555
|
-
|
556
|
-
|
557
|
-
logger.debug " adding css classes: #{
|
555
|
+
|
556
|
+
## check for css style classes
|
557
|
+
from = 0
|
558
|
+
while (pos = slide_source.index( /<!-- _S9(SLIDE|STYLE)_(.*?)-->/m, from ))
|
559
|
+
logger.debug " adding css classes from pi #{$1.downcase}: #{$2.strip}"
|
560
|
+
|
561
|
+
if slide.classes.nil?
|
562
|
+
slide.classes = $2.strip
|
563
|
+
else
|
564
|
+
slide.classes << " #{$2.strip}"
|
565
|
+
end
|
566
|
+
|
567
|
+
from = Regexp.last_match.end(0)
|
558
568
|
end
|
559
569
|
|
560
570
|
if slide_source =~ /^\s*(<h1.*?>.*?<\/h\d>)\s*(.*)/m # try to cut off header using non-greedy .+? pattern; tip test regex online at rubular.com
|
@@ -1,4 +1,5 @@
|
|
1
|
-
module
|
1
|
+
module Slideshow
|
2
|
+
module AnalyticsHelper
|
2
3
|
|
3
4
|
|
4
5
|
def google_analytics( opts = {} )
|
@@ -27,13 +28,15 @@ def google_analytics( opts = {} )
|
|
27
28
|
<!-- end google-analytics -->
|
28
29
|
EOS
|
29
30
|
|
30
|
-
|
31
|
+
guard_block( text )
|
31
32
|
end
|
32
33
|
|
33
34
|
|
34
|
-
end #
|
35
|
+
end # module AnalyticsHelper
|
36
|
+
end # module Slideshow
|
37
|
+
|
35
38
|
|
36
39
|
class Slideshow::Gen
|
37
|
-
include AnalyticsHelper
|
40
|
+
include Slideshow::AnalyticsHelper
|
38
41
|
end
|
39
42
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Slideshow
|
2
|
+
module BackgroundHelper
|
3
|
+
|
4
|
+
|
5
|
+
def gradient( *args )
|
6
|
+
|
7
|
+
# check for optional hash for options
|
8
|
+
opts = args.last.kind_of?(Hash) ? args.pop : {}
|
9
|
+
|
10
|
+
colors = args
|
11
|
+
|
12
|
+
clazz = opts[:class] || ( 's9_gradient_linear_'+colors.join('_').gsub( /[(), ]/, '_' ).gsub( /_{2,}/, '_').gsub( /[^-\w]/, '' ) )
|
13
|
+
|
14
|
+
## generate code for webkit
|
15
|
+
|
16
|
+
webkit = ""
|
17
|
+
webkit << "-webkit-gradient(linear, 0% 0%, 0% 100%, "
|
18
|
+
webkit << "from(#{colors.first}), to(#{colors.last})"
|
19
|
+
|
20
|
+
# check for additional stop colors
|
21
|
+
more_colors = colors[ 1..-2 ]
|
22
|
+
more_colors.each_with_index do |color, i|
|
23
|
+
webkit << ", color-stop(#{(1.0/(more_colors.size+1))*(i+1)},#{color})"
|
24
|
+
end
|
25
|
+
webkit << ")"
|
26
|
+
|
27
|
+
## generate code for mozilla
|
28
|
+
|
29
|
+
mozilla = ""
|
30
|
+
mozilla << "-moz-linear-gradient(top, "
|
31
|
+
mozilla << "#{colors.first}, "
|
32
|
+
|
33
|
+
# check for additional stop colors
|
34
|
+
more_colors = colors[ 1..-2 ]
|
35
|
+
more_colors.each do |color|
|
36
|
+
mozilla << "#{color}, "
|
37
|
+
end
|
38
|
+
|
39
|
+
mozilla << "#{colors.last})"
|
40
|
+
|
41
|
+
|
42
|
+
puts " Adding CSS for background style rule..."
|
43
|
+
content_for( :css, <<-EOS )
|
44
|
+
.#{clazz} { background: #{webkit};
|
45
|
+
background: #{mozilla};
|
46
|
+
}
|
47
|
+
EOS
|
48
|
+
|
49
|
+
# add processing instruction to get style class added to slide
|
50
|
+
|
51
|
+
puts " Adding HTML PI for background style class '#{clazz}'..."
|
52
|
+
"<!-- _S9STYLE_ #{clazz} -->\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
def background( *args )
|
56
|
+
|
57
|
+
# make everyting optional; use it like:
|
58
|
+
# background( code, opts={} )
|
59
|
+
|
60
|
+
# check for optional hash for options
|
61
|
+
opts = args.last.kind_of?(Hash) ? args.pop : {}
|
62
|
+
|
63
|
+
# check for optional style rule code
|
64
|
+
code = args.last.kind_of?(String) ? args.pop : ''
|
65
|
+
|
66
|
+
clazz = opts[:class] || ( 's9'+code.strip.gsub( /[(), ]/, '_' ).gsub( /_{2,}/, '_').gsub( /[^-\w]/, '' ) )
|
67
|
+
|
68
|
+
# 1) add background rule to css
|
69
|
+
# e.g. .simple { background: -moz-linear-gradient(top, blue, white); }
|
70
|
+
|
71
|
+
unless code.empty?
|
72
|
+
puts " Adding CSS for background style rule..."
|
73
|
+
content_for( :css, <<-EOS )
|
74
|
+
.#{clazz} { background: #{code}; }
|
75
|
+
EOS
|
76
|
+
end
|
77
|
+
|
78
|
+
# 2) add processing instruction to get style class added to slide
|
79
|
+
|
80
|
+
puts " Adding HTML PI for background style class '#{clazz}'..."
|
81
|
+
"<!-- _S9STYLE_ #{clazz} -->\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
end # module BackgroundHelper
|
87
|
+
end # module Slideshow
|
88
|
+
|
89
|
+
class Slideshow::Gen
|
90
|
+
include Slideshow::BackgroundHelper
|
91
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# Originally based on code from Rails and Merb; adapted from Webby.
|
2
2
|
|
3
|
-
module
|
3
|
+
module Slideshow
|
4
|
+
module CaptureHelper
|
4
5
|
|
5
6
|
# Called in pages and partials to store up content for later use. Takes a
|
6
7
|
# string and/or a block. First, the string is evaluated, and then the
|
@@ -130,5 +131,6 @@ module CaptureHelper
|
|
130
131
|
end
|
131
132
|
|
132
133
|
end # module CaptureHelper
|
134
|
+
end # module Slideshow
|
133
135
|
|
134
|
-
Slideshow::Gen.__send__( :include, CaptureHelper )
|
136
|
+
Slideshow::Gen.__send__( :include, Slideshow::CaptureHelper )
|
@@ -0,0 +1,42 @@
|
|
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
|
+
"<!-- _S9SLIDE_ #{params ? params : ''} -->"
|
26
|
+
end
|
27
|
+
|
28
|
+
def style( params )
|
29
|
+
"<!-- _S9STYLE_ #{params ? params : ''} -->"
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
end # module DirectiveHelper
|
35
|
+
end # module Slideshow
|
36
|
+
|
37
|
+
class Slideshow::Gen
|
38
|
+
include Slideshow::DirectiveHelper
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,18 @@
|
|
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
|
@@ -0,0 +1,39 @@
|
|
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,4 +1,5 @@
|
|
1
|
-
module
|
1
|
+
module Slideshow
|
2
|
+
module StepHelper
|
2
3
|
|
3
4
|
|
4
5
|
def step( opts={}, &blk )
|
@@ -14,9 +15,9 @@ def step( opts={}, &blk )
|
|
14
15
|
after << "<!-- end step -->\n"
|
15
16
|
|
16
17
|
html = ""
|
17
|
-
html <<
|
18
|
+
html << guard_block( before )
|
18
19
|
html << text
|
19
|
-
html <<
|
20
|
+
html << guard_block( after )
|
20
21
|
|
21
22
|
concat_erb( html, blk.binding )
|
22
23
|
return
|
@@ -24,8 +25,9 @@ end
|
|
24
25
|
|
25
26
|
|
26
27
|
end # module StepHelper
|
28
|
+
end # module Slideshow
|
27
29
|
|
28
30
|
class Slideshow::Gen
|
29
|
-
include StepHelper
|
31
|
+
include Slideshow::StepHelper
|
30
32
|
end
|
31
33
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'coderay'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Slideshow
|
4
|
+
module Syntax
|
5
|
+
module CodeRayHelper
|
4
6
|
|
5
7
|
# coderay option defaults
|
6
8
|
CR_LANG = 'ruby'
|
@@ -73,6 +75,10 @@ def coderay( *args, &blk )
|
|
73
75
|
return
|
74
76
|
end
|
75
77
|
|
76
|
-
end # module
|
78
|
+
end # module CodeRayHelper
|
79
|
+
end # module Syntax
|
80
|
+
end # module Slideshow
|
77
81
|
|
78
|
-
Slideshow::Gen
|
82
|
+
class Slideshow::Gen
|
83
|
+
include Slideshow::Syntax::CodeRayHelper
|
84
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Slideshow
|
2
|
+
module Syntax
|
3
|
+
module ShHelper
|
4
|
+
|
5
|
+
# sh option defaults
|
6
|
+
SH_LANG = 'ruby'
|
7
|
+
SH_LINE_NUMBERS = 'true'
|
8
|
+
|
9
|
+
def sh_worker( code, opts )
|
10
|
+
|
11
|
+
lang = opts.fetch( :lang, SH_LANG )
|
12
|
+
line_numbers_value = opts.fetch( :line_numbers, headers.get( 'code-line-numbers', SH_LINE_NUMBERS ))
|
13
|
+
line_numbers = (line_numbers_value =~ /true|yes|on/i) ? true : false
|
14
|
+
|
15
|
+
# note: code gets highlighted at runtime in client (using JavaScript)
|
16
|
+
code_highlighted = CGI::escapeHTML( code )
|
17
|
+
|
18
|
+
css_class = 'code'
|
19
|
+
css_class_opt = opts.fetch( :class, nil ) # large, small, tiny, etc.
|
20
|
+
css_class << " #{css_class_opt}" if css_class_opt # e.g. use/allow multiple classes -> code small, code large, etc.
|
21
|
+
|
22
|
+
out = %{<pre class='#{css_class} brush: #{lang} gutter: #{line_numbers ? 'true' : 'false'}'>}
|
23
|
+
out << code_highlighted
|
24
|
+
out << %{</pre>\n}
|
25
|
+
|
26
|
+
return out
|
27
|
+
end
|
28
|
+
|
29
|
+
def sv( *args, &blk )
|
30
|
+
# check for optional hash for options
|
31
|
+
opts = args.last.kind_of?(Hash) ? args.pop : {}
|
32
|
+
|
33
|
+
code = capture_erb(&blk)
|
34
|
+
return if code.empty?
|
35
|
+
|
36
|
+
code_highlighted = sv_worker( code, opts )
|
37
|
+
|
38
|
+
concat_erb( guard_block( code_highlighted ), blk.binding )
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
end # module ShHelper
|
43
|
+
end # module Syntax
|
44
|
+
end # module Slideshow
|
45
|
+
|
46
|
+
class Slideshow::Gen
|
47
|
+
include Slideshow::Syntax::ShHelper
|
48
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'uv'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Slideshow
|
4
|
+
module Syntax
|
5
|
+
module UvHelper
|
4
6
|
|
5
7
|
# uv option defaults
|
6
8
|
UV_LANG = 'ruby'
|
@@ -79,7 +81,10 @@ def uv( *args, &blk )
|
|
79
81
|
return
|
80
82
|
end
|
81
83
|
|
82
|
-
end
|
83
|
-
|
84
|
-
|
84
|
+
end # module UvHelper
|
85
|
+
end # module Syntax
|
86
|
+
end # module Slideshow
|
85
87
|
|
88
|
+
class Slideshow::Gen
|
89
|
+
include Slideshow::Syntax::UvHelper
|
90
|
+
end
|