slideshow-models 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +45 -37
- data/README.md +3 -2
- data/Rakefile +3 -5
- data/config/slideshow.yml +7 -14
- data/lib/slideshow/commands/fetch.rb +2 -4
- data/lib/slideshow/commands/gen.rb +57 -161
- data/lib/slideshow/commands/list.rb +2 -4
- data/lib/slideshow/commands/plugins.rb +2 -4
- data/lib/slideshow/commands/quick.rb +5 -8
- data/lib/slideshow/config.rb +11 -50
- data/lib/slideshow/drops.rb +35 -0
- data/lib/slideshow/filters/debug_filter.rb +3 -3
- data/lib/slideshow/filters/slide_filter.rb +1 -67
- data/lib/slideshow/filters/text_filter.rb +1 -18
- data/lib/slideshow/helpers/background_helper.rb +1 -0
- data/lib/slideshow/helpers/step_helper.rb +1 -1
- data/lib/slideshow/manifest_helpers.rb +4 -0
- data/lib/slideshow/markdown.rb +27 -0
- data/lib/slideshow/models.rb +9 -13
- data/lib/slideshow/models/deck.rb +188 -0
- data/lib/slideshow/{slide.rb → models/slide.rb} +9 -4
- data/lib/slideshow/opts.rb +117 -0
- data/lib/slideshow/version.rb +2 -2
- data/test/helper.rb +9 -0
- data/test/samples/test.md +29 -0
- data/test/samples/test_content_for.md +25 -0
- data/test/templates/test/test.html +52 -0
- data/test/templates/test/test.txt +5 -0
- data/test/test_gen.rb +54 -0
- data/test/test_kramdown.rb +67 -0
- data/test/test_slide.rb +44 -0
- data/test/test_version.rb +29 -0
- metadata +25 -17
- data/lib/slideshow/helpers/markdown_helper.rb +0 -20
- data/lib/slideshow/markup/markdown.rb +0 -20
- data/lib/slideshow/markup/mediawiki.rb +0 -40
- data/lib/slideshow/markup/rest.rb +0 -19
- data/lib/slideshow/markup/textile.rb +0 -70
@@ -0,0 +1,188 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
|
5
|
+
|
6
|
+
module DeckFilter
|
7
|
+
|
8
|
+
# add slide directive before h1 (tells slideshow gem where to break slides)
|
9
|
+
#
|
10
|
+
# e.g. changes:
|
11
|
+
# <h1 id='optional' class='optional'>
|
12
|
+
# to
|
13
|
+
# html comment -> _S9SLIDE_ (note: rdoc can't handle html comments?)
|
14
|
+
# <h1 id='optional' class='optional'>
|
15
|
+
|
16
|
+
def add_slide_directive_before_h1( content )
|
17
|
+
|
18
|
+
# mark h1 for getting wrapped into slide divs
|
19
|
+
# note: use just <h1 since some processors add ids e.g. <h1 id='x'>
|
20
|
+
|
21
|
+
slide_count = 0
|
22
|
+
|
23
|
+
content = content.gsub( /<h1/ ) do |match|
|
24
|
+
slide_count += 1
|
25
|
+
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
26
|
+
end
|
27
|
+
|
28
|
+
puts " Adding #{slide_count} slide breaks (using h1 rule)..."
|
29
|
+
|
30
|
+
content
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_slide_directive_before_h2( content )
|
34
|
+
|
35
|
+
slide_count = 0
|
36
|
+
|
37
|
+
content = content.gsub( /<h2/ ) do |match|
|
38
|
+
slide_count += 1
|
39
|
+
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
40
|
+
end
|
41
|
+
|
42
|
+
puts " Adding #{slide_count} slide breaks (using h2 rule)..."
|
43
|
+
|
44
|
+
content
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
# add slide directive before div h1 (for pandoc-generated html)
|
50
|
+
#
|
51
|
+
# e.g. changes:
|
52
|
+
# <div id='header'>
|
53
|
+
# <h1 id='optional' class='optional'>
|
54
|
+
# to
|
55
|
+
# html comment -> _S9SLIDE_
|
56
|
+
# <div id='header'>
|
57
|
+
# <h1 id='optional' class='optional'>
|
58
|
+
|
59
|
+
|
60
|
+
def add_slide_directive_before_div_h1( content )
|
61
|
+
|
62
|
+
slide_count = 0
|
63
|
+
|
64
|
+
content = content.gsub( /<div[^>]*>\s*<h1/ ) do |match|
|
65
|
+
slide_count += 1
|
66
|
+
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
67
|
+
end
|
68
|
+
|
69
|
+
puts " Adding #{slide_count} slide breaks (using div_h1 rule)..."
|
70
|
+
|
71
|
+
content
|
72
|
+
end
|
73
|
+
|
74
|
+
end # module DeckFilter
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
class Deck
|
79
|
+
|
80
|
+
include LogUtils::Logging
|
81
|
+
include DeckFilter # e.g. add_slide_directive_before_h1
|
82
|
+
|
83
|
+
|
84
|
+
attr_accessor :content ## all-in-one content (that is, incl. all slides )
|
85
|
+
attr_accessor :slides
|
86
|
+
|
87
|
+
|
88
|
+
def initialize( source, header_level: 1, use_slide: false )
|
89
|
+
@source = source ## keep a copy of the original source (input)
|
90
|
+
|
91
|
+
@header_level = header_level # e.g. 1 or 2 -- todo/fix: allow more options e.g. 1..2 etc.
|
92
|
+
@use_slide = use_slide # e.g. opts.slide? -- only allow !SLIDE directives fo slide breaks?
|
93
|
+
|
94
|
+
@slides = []
|
95
|
+
@content = '' # note: gets (re)build from slides in parse
|
96
|
+
|
97
|
+
parse()
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
def parse
|
102
|
+
#############################
|
103
|
+
# step 1 - add slide breaks
|
104
|
+
|
105
|
+
@content = @source
|
106
|
+
|
107
|
+
if @use_slide # only allow !SLIDE directives fo slide breaks?
|
108
|
+
# do nothing (no extra automagic slide breaks wanted)
|
109
|
+
else
|
110
|
+
if @header_level == 2
|
111
|
+
@content = add_slide_directive_before_h2( @content )
|
112
|
+
else # assume level 1
|
113
|
+
@content = add_slide_directive_before_h1( @content )
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
### todo/fix: add back dump to file (requires @name and outpath !!!!)
|
119
|
+
### dump_content_to_file_debug_html( content )
|
120
|
+
|
121
|
+
|
122
|
+
#############################################################
|
123
|
+
# step 2 - use generic slide break processing instruction to
|
124
|
+
# split content into slides
|
125
|
+
|
126
|
+
counter = 0
|
127
|
+
chunks = []
|
128
|
+
buf = ""
|
129
|
+
|
130
|
+
|
131
|
+
@content.each_line do |line|
|
132
|
+
if line.include?( '<!-- _S9SLIDE_' ) || line.include?( '<!-- @SLIDE' ) ## add new format
|
133
|
+
if counter > 0 # found start of new slide (and, thus, end of last slide)
|
134
|
+
chunks << buf # add slide to slide stack
|
135
|
+
buf = "" # reset slide source buffer
|
136
|
+
else # counter == 0
|
137
|
+
# check for first slide with missing leading SLIDE directive (possible/allowed in takahashi, for example)
|
138
|
+
## remove html comments and whitspaces (still any content?)
|
139
|
+
### more than just whitespace? assume its a slide
|
140
|
+
if buf.gsub(/<!--.*?-->/m, '').gsub( /[\n\r\t ]/, '').length > 0
|
141
|
+
logger.debug "add slide with missing leading slide directive >#{buf}< with slide_counter == 0"
|
142
|
+
chunks << buf
|
143
|
+
buf = ""
|
144
|
+
else
|
145
|
+
logger.debug "** note: skipping slide >#{buf}< with counter == 0"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
counter += 1
|
149
|
+
end
|
150
|
+
buf << line
|
151
|
+
end
|
152
|
+
|
153
|
+
if counter > 0
|
154
|
+
chunks << buf # add slide to slide stack
|
155
|
+
buf = "" # reset slide source buffer
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
@slides = []
|
160
|
+
chunks.each do |chunk|
|
161
|
+
@slides << Slide.new( chunk, header_level: @header_level )
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
puts "#{@slides.size} slides found:"
|
166
|
+
|
167
|
+
@slides.each_with_index do |slide,i|
|
168
|
+
print " [#{i+1}] "
|
169
|
+
if slide.header.present?
|
170
|
+
print slide.header
|
171
|
+
else
|
172
|
+
# remove html comments
|
173
|
+
print "-- no header -- | #{slide.content.gsub(/<!--.*?-->/m, '').gsub(/\n/,'$')[0..40]}"
|
174
|
+
end
|
175
|
+
puts
|
176
|
+
end
|
177
|
+
|
178
|
+
## rebuild all-in-one content (incl. all slides)
|
179
|
+
@content = ""
|
180
|
+
@slides.each do |slide|
|
181
|
+
@content << slide.to_classic_html
|
182
|
+
end
|
183
|
+
end # method parse
|
184
|
+
|
185
|
+
|
186
|
+
end # class Deck
|
187
|
+
|
188
|
+
end # class Slideshow
|
@@ -4,7 +4,7 @@ module Slideshow
|
|
4
4
|
|
5
5
|
class Slide
|
6
6
|
|
7
|
-
|
7
|
+
include LogUtils::Logging
|
8
8
|
|
9
9
|
# NB: unparsed html source (use content_without_header
|
10
10
|
# for content without option header)
|
@@ -14,9 +14,12 @@ module Slideshow
|
|
14
14
|
attr_accessor :header
|
15
15
|
attr_accessor :classes
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
### def to_drop() SlideDrop.new( self ); end -- add - why? why not??
|
19
|
+
|
20
|
+
def initialize( content, header_level: 1 )
|
21
|
+
## options
|
22
|
+
@header_level = header_level
|
20
23
|
|
21
24
|
@content = content
|
22
25
|
|
@@ -82,6 +85,8 @@ module Slideshow
|
|
82
85
|
|
83
86
|
|
84
87
|
def data_attributes
|
88
|
+
return nil if @data.empty? ## note: return nil for empty hash
|
89
|
+
|
85
90
|
buf = ""
|
86
91
|
@data.each do | key,value |
|
87
92
|
buf << "data-#{key}='#{value}' "
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
|
5
|
+
|
6
|
+
class Opts
|
7
|
+
|
8
|
+
def header_level=(value)
|
9
|
+
@header_level = value.to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
def header_level
|
13
|
+
## todo: check 0 is not nil?
|
14
|
+
@header_level || 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def slide=(boolean)
|
18
|
+
@slide = boolean
|
19
|
+
end
|
20
|
+
|
21
|
+
def slide?
|
22
|
+
return false if @slide.nil? # default slide flag is false
|
23
|
+
@slide == true
|
24
|
+
end
|
25
|
+
|
26
|
+
def takahashi=(boolean)
|
27
|
+
@takahashi = boolean
|
28
|
+
end
|
29
|
+
|
30
|
+
def takahashi?
|
31
|
+
return false if @takahashi.nil? # default takahashi flag is false
|
32
|
+
@takahashi == true
|
33
|
+
end
|
34
|
+
|
35
|
+
def verbose=(boolean) # add: alias for debug ??
|
36
|
+
@verbose = boolean
|
37
|
+
end
|
38
|
+
|
39
|
+
def verbose?
|
40
|
+
return false if @verbose.nil? # default verbose/debug flag is false
|
41
|
+
@verbose == true
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def test=(boolean)
|
46
|
+
@test = boolean
|
47
|
+
end
|
48
|
+
|
49
|
+
def test?
|
50
|
+
return false if @test.nil? # default verbose/debug flag is false
|
51
|
+
@test == true
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def quick_manifest=(value)
|
56
|
+
@quick_manifest = value
|
57
|
+
end
|
58
|
+
|
59
|
+
def quick_manifest
|
60
|
+
@quick_manifest || 'welcome'
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
def fetch_all=(boolean)
|
66
|
+
@fetch_all = boolean
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch_all?
|
70
|
+
return false if @fetch_all.nil? # default fetch all flag is false
|
71
|
+
@fetch_all == true
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
def includes=(value)
|
77
|
+
@includes = value
|
78
|
+
end
|
79
|
+
|
80
|
+
def includes
|
81
|
+
# fix: use os-agnostic delimiter (use : for Mac/Unix?)
|
82
|
+
@includes.nil? ? [] : @includes.split( ';' )
|
83
|
+
end
|
84
|
+
|
85
|
+
def has_includes?
|
86
|
+
@includes.nil? ? false : true
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def manifest=(value)
|
91
|
+
@manifest = value
|
92
|
+
end
|
93
|
+
|
94
|
+
def manifest
|
95
|
+
@manifest || 's6'
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def config_path=(value)
|
100
|
+
@config_path = value
|
101
|
+
end
|
102
|
+
|
103
|
+
def config_path
|
104
|
+
@config_path || File.join( Env.home, '.slideshow' )
|
105
|
+
end
|
106
|
+
|
107
|
+
def output_path=(value)
|
108
|
+
@output_path = value
|
109
|
+
end
|
110
|
+
|
111
|
+
def output_path
|
112
|
+
@output_path || '.'
|
113
|
+
end
|
114
|
+
|
115
|
+
end # class Opts
|
116
|
+
|
117
|
+
end # module Slideshow
|
data/lib/slideshow/version.rb
CHANGED
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
title: test title
|
2
|
+
author: test author
|
3
|
+
|
4
|
+
|
5
|
+
# test header 1
|
6
|
+
|
7
|
+
test content 1
|
8
|
+
|
9
|
+
|
10
|
+
# test header 2
|
11
|
+
|
12
|
+
test content 2
|
13
|
+
|
14
|
+
|
15
|
+
# test header 3
|
16
|
+
|
17
|
+
test content 3 with some code
|
18
|
+
|
19
|
+
```
|
20
|
+
puts 'hello'
|
21
|
+
```
|
22
|
+
|
23
|
+
# test header 4
|
24
|
+
|
25
|
+
test content 4 with syntax highlighter
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
puts 'hello'
|
29
|
+
```
|
@@ -0,0 +1,25 @@
|
|
1
|
+
title: test title
|
2
|
+
author: test author
|
3
|
+
|
4
|
+
|
5
|
+
<% content_for :css do %>
|
6
|
+
body { color: red}
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_for :js do %>
|
10
|
+
console.log( "hello, js" )
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
|
14
|
+
# test header 1
|
15
|
+
|
16
|
+
test content 1
|
17
|
+
|
18
|
+
<% content_for :css do %>
|
19
|
+
.slide1 { color: green }
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
|
23
|
+
# test header 2
|
24
|
+
|
25
|
+
test content 2
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>pakman Test Template</title>
|
7
|
+
{{ more_content_for_head }}
|
8
|
+
|
9
|
+
<style>
|
10
|
+
{{ more_content_for_css }}
|
11
|
+
{{ content_for_css }}
|
12
|
+
{{ extra_css }}
|
13
|
+
</style>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<h1>Hello pakman</h1>
|
18
|
+
|
19
|
+
<h3>Headers</h3>
|
20
|
+
|
21
|
+
<ul>
|
22
|
+
<li>author: {{ headers.author }}</li>
|
23
|
+
<li>title: {{ headers.title }}</li>
|
24
|
+
<li>email: {{ headers.email }}</li>
|
25
|
+
<li>footer: {{ headers.footer }}</li>
|
26
|
+
<li>subfooter: {{ headers.subfooter }}</li>
|
27
|
+
<li>authorxxx: {{ headers.authorxxx }}</li> <!-- check missing keys too -->
|
28
|
+
</ul>
|
29
|
+
|
30
|
+
<ul>
|
31
|
+
<li>author: {{ headers['author'] }}</li>
|
32
|
+
<li>title: {{ headers['title'] }}</li>
|
33
|
+
<li>authorxxx: {{ headers['authorxxx'] }}</li> <!-- check missing keys too -->
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
<h3>Slides</h3>
|
37
|
+
|
38
|
+
{% for slide in slides %}
|
39
|
+
<div>{{ slide.header }}</div>
|
40
|
+
<div>{{ slide.content_without_header }}</div>
|
41
|
+
{% endfor %}
|
42
|
+
|
43
|
+
<!-- begin (all-in-one) content -->
|
44
|
+
{{ content }}
|
45
|
+
<!-- end (all-in-one) content -->
|
46
|
+
|
47
|
+
<script>
|
48
|
+
{{ more_content_for_js }}
|
49
|
+
</script>
|
50
|
+
|
51
|
+
</body>
|
52
|
+
</html>
|