slideshow 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slideshow/cli/commands/fetch.rb +12 -2
- data/lib/slideshow/cli/commands/gen.rb +64 -28
- data/lib/slideshow/cli/opts.rb +27 -0
- data/lib/slideshow/cli/runner.rb +13 -1
- data/lib/slideshow/config.rb +23 -1
- data/lib/slideshow/filters/slide_filter.rb +33 -0
- data/lib/slideshow/filters/text_filter.rb +0 -3
- data/lib/slideshow/version.rb +1 -1
- metadata +4 -4
@@ -14,9 +14,19 @@ class Fetch
|
|
14
14
|
|
15
15
|
|
16
16
|
def run
|
17
|
-
|
17
|
+
if opts.fetch_all?
|
18
|
+
config.default_fetch_shortcuts.keys.each do |shortcut|
|
19
|
+
fetch_pak( shortcut )
|
20
|
+
end
|
21
|
+
else
|
22
|
+
fetch_pak( opts.fetch_uri )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def fetch_pak( src )
|
18
28
|
|
19
|
-
src
|
29
|
+
logger.debug "src=>#{src}<"
|
20
30
|
|
21
31
|
## check for builtin shortcut (assume no / or \)
|
22
32
|
if src.index( '/' ).nil? && src.index( '\\' ).nil?
|
@@ -50,7 +50,7 @@ class Gen
|
|
50
50
|
"\n\n<notextile>\n#{text}\n</notextile>\n"
|
51
51
|
else
|
52
52
|
text
|
53
|
-
end
|
53
|
+
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def guard_inline( text )
|
@@ -81,23 +81,28 @@ class Gen
|
|
81
81
|
ERB.new( content ).result( the_binding )
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
|
85
85
|
|
86
86
|
# move into a filter??
|
87
87
|
def post_processing_slides( content )
|
88
88
|
|
89
|
-
# 1) add slide
|
89
|
+
# 1) add slide breaks
|
90
90
|
|
91
|
-
if
|
92
|
-
|
93
|
-
else
|
94
|
-
if
|
95
|
-
content =
|
96
|
-
else
|
97
|
-
|
91
|
+
if config.slide? # only allow !SLIDE directives fo slide breaks?
|
92
|
+
# do nothing (no extra automagic slide breaks wanted)
|
93
|
+
else
|
94
|
+
if (@markup_type == :markdown && Markdown.lib == 'pandoc-ruby') || @markup_type == :rest
|
95
|
+
content = add_slide_directive_before_div_h1( content )
|
96
|
+
else
|
97
|
+
if config.header_level == 2
|
98
|
+
content = add_slide_directive_before_h2( content )
|
99
|
+
else # assume level 1
|
100
|
+
content = add_slide_directive_before_h1( content )
|
101
|
+
end
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
105
|
+
|
101
106
|
dump_content_to_file_debug_html( content )
|
102
107
|
|
103
108
|
# 2) use generic slide break processing instruction to
|
@@ -106,43 +111,68 @@ class Gen
|
|
106
111
|
slide_counter = 0
|
107
112
|
|
108
113
|
slides = []
|
109
|
-
|
114
|
+
slide_buf = ""
|
110
115
|
|
111
116
|
content.each_line do |line|
|
112
|
-
if line.include?( '<!-- _S9SLIDE_' )
|
113
|
-
if slide_counter > 0
|
114
|
-
slides <<
|
115
|
-
|
117
|
+
if line.include?( '<!-- _S9SLIDE_' )
|
118
|
+
if slide_counter > 0 # found start of new slide (and, thus, end of last slide)
|
119
|
+
slides << slide_buf # add slide to slide stack
|
120
|
+
slide_buf = "" # reset slide source buffer
|
121
|
+
else # slide_counter == 0
|
122
|
+
# check for first slide with missing leading SLIDE directive (possible/allowed in takahashi, for example)
|
123
|
+
## remove html comments and whitspaces (still any content?)
|
124
|
+
### more than just whitespace? assume its a slide
|
125
|
+
if slide_buf.gsub(/<!--.*?-->/m, '').gsub( /[\n\r\t ]/, '').length > 0
|
126
|
+
logger.debug "add slide with missing leading slide directive >#{slide_buf}< with slide_counter == 0"
|
127
|
+
slides << slide_buf
|
128
|
+
slide_buf = ""
|
129
|
+
else
|
130
|
+
logger.debug "skipping slide_buf >#{slide_buf}< with slide_counter == 0"
|
131
|
+
end
|
116
132
|
end
|
117
133
|
slide_counter += 1
|
118
134
|
end
|
119
|
-
|
135
|
+
slide_buf << line
|
120
136
|
end
|
121
137
|
|
122
|
-
if slide_counter > 0
|
123
|
-
slides <<
|
124
|
-
|
138
|
+
if slide_counter > 0
|
139
|
+
slides << slide_buf # add slide to slide stack
|
140
|
+
slide_buf = "" # reset slide source buffer
|
125
141
|
end
|
126
142
|
|
127
143
|
|
128
144
|
slides2 = []
|
129
|
-
slides.each do |
|
130
|
-
slides2 << Slide.new(
|
145
|
+
slides.each do |source|
|
146
|
+
slides2 << Slide.new( source, config )
|
131
147
|
end
|
132
148
|
|
133
|
-
|
134
|
-
|
149
|
+
|
150
|
+
puts "#{slides2.size} slides found:"
|
151
|
+
|
152
|
+
slides2.each_with_index do |slide,i|
|
153
|
+
print " [#{i+1}] "
|
154
|
+
if slide.header.present?
|
155
|
+
print slide.header
|
156
|
+
else
|
157
|
+
# remove html comments
|
158
|
+
print "-- no header -- | #{slide.content.gsub(/<!--.*?-->/m, '').gsub(/\n/,'$')[0..40]}"
|
159
|
+
end
|
160
|
+
puts
|
161
|
+
end
|
135
162
|
|
136
|
-
content2 = ""
|
137
|
-
slides2.each do |slide|
|
138
|
-
content2 << slide.to_classic_html
|
139
|
-
end
|
140
163
|
|
141
164
|
# make content2 and slide2 available to erb template
|
142
165
|
# -- todo: cleanup variable names and use attr_readers for content and slide
|
166
|
+
|
167
|
+
### fix: use class SlideDeck or Deck?? for slides array?
|
168
|
+
|
169
|
+
content2 = ""
|
170
|
+
slides2.each do |slide|
|
171
|
+
content2 << slide.to_classic_html
|
172
|
+
end
|
143
173
|
|
174
|
+
@content = content2
|
144
175
|
@slides = slides2 # strutured content
|
145
|
-
@content = content2 # content all-in-one
|
146
176
|
end
|
147
177
|
|
148
178
|
|
@@ -228,6 +258,12 @@ class Gen
|
|
228
258
|
content = send( mn, content ) # call filter e.g. include_helper_hack( content )
|
229
259
|
end
|
230
260
|
|
261
|
+
|
262
|
+
if config.takahashi?
|
263
|
+
content = takahashi_slide_breaks( content )
|
264
|
+
end
|
265
|
+
|
266
|
+
|
231
267
|
# convert light-weight markup to hypertext
|
232
268
|
|
233
269
|
content = text_to_html( content )
|
data/lib/slideshow/cli/opts.rb
CHANGED
@@ -12,6 +12,25 @@ class Opts
|
|
12
12
|
@header_level || 1
|
13
13
|
end
|
14
14
|
|
15
|
+
def slide=(boolean)
|
16
|
+
@slide = boolean
|
17
|
+
end
|
18
|
+
|
19
|
+
def slide?
|
20
|
+
return false if @slide.nil? # default slide flag is false
|
21
|
+
@slide == true
|
22
|
+
end
|
23
|
+
|
24
|
+
def takahashi=(boolean)
|
25
|
+
@takahashi = boolean
|
26
|
+
end
|
27
|
+
|
28
|
+
def takahashi?
|
29
|
+
return false if @takahashi.nil? # default takahashi flag is false
|
30
|
+
@takahashi == true
|
31
|
+
end
|
32
|
+
|
33
|
+
|
15
34
|
def quick=(boolean)
|
16
35
|
@quick = boolean
|
17
36
|
end
|
@@ -58,6 +77,14 @@ class Opts
|
|
58
77
|
@list == true
|
59
78
|
end
|
60
79
|
|
80
|
+
def fetch_all=(boolean)
|
81
|
+
@fetch_all = boolean
|
82
|
+
end
|
83
|
+
|
84
|
+
def fetch_all?
|
85
|
+
return false if @fetch_all.nil? # default fetch all flag is false
|
86
|
+
@fetch_all == true
|
87
|
+
end
|
61
88
|
|
62
89
|
def fetch_uri=(value)
|
63
90
|
@fetch_uri = value
|
data/lib/slideshow/cli/runner.rb
CHANGED
@@ -80,6 +80,14 @@ def run( args )
|
|
80
80
|
cmd.on( '--h1', 'Set Header Level to 1 (default)' ) { opts.header_level = 1 }
|
81
81
|
cmd.on( '--h2', 'Set Header Level to 2' ) { opts.header_level = 2 }
|
82
82
|
|
83
|
+
cmd.on( '--slide', 'Use only !SLIDE for slide breaks (Showoff Compatible)' ) do
|
84
|
+
opts.slide = true
|
85
|
+
end
|
86
|
+
|
87
|
+
cmd.on( '--takahashi', 'Allow // for slide breaks' ) do
|
88
|
+
opts.takahashi = true
|
89
|
+
end
|
90
|
+
|
83
91
|
|
84
92
|
# ?? opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s }
|
85
93
|
|
@@ -89,6 +97,10 @@ def run( args )
|
|
89
97
|
opts.fetch_uri = uri
|
90
98
|
end
|
91
99
|
|
100
|
+
cmd.on( '--all', "Fetch Template Packs (#{config.default_fetch_shortcuts.keys.join(', ')})" ) do
|
101
|
+
opts.fetch_all = true
|
102
|
+
end
|
103
|
+
|
92
104
|
cmd.on( '-l', '--list', 'List Installed Templates' ) { opts.list = true }
|
93
105
|
|
94
106
|
cmd.on( '-c', '--config PATH', "Configuration Path (default is #{opts.config_path})" ) do |path|
|
@@ -207,7 +219,7 @@ EOS
|
|
207
219
|
GenTemplates.new( logger, opts, config ).run ### todo: remove opts
|
208
220
|
elsif opts.quick?
|
209
221
|
Quick.new( logger, opts, config ).run ### todo: remove opts
|
210
|
-
elsif opts.fetch?
|
222
|
+
elsif opts.fetch? || opts.fetch_all?
|
211
223
|
Fetch.new( logger, opts, config ).run ### todo: remove opts
|
212
224
|
else
|
213
225
|
load_plugins # check for optional plugins/extension in ./lib folder
|
data/lib/slideshow/config.rb
CHANGED
@@ -12,6 +12,14 @@ class Config
|
|
12
12
|
def header_level
|
13
13
|
@opts.header_level
|
14
14
|
end
|
15
|
+
|
16
|
+
def slide?
|
17
|
+
@opts.slide?
|
18
|
+
end
|
19
|
+
|
20
|
+
def takahashi?
|
21
|
+
@opts.takahashi?
|
22
|
+
end
|
15
23
|
|
16
24
|
# todo/fix: fix references after this move to here, that is, Config class
|
17
25
|
# - used in syntax/uv_helper (use config.cache_dir to access?)
|
@@ -73,11 +81,25 @@ class Config
|
|
73
81
|
## todo: add more config settings?
|
74
82
|
end
|
75
83
|
|
76
|
-
|
84
|
+
|
77
85
|
def header( key )
|
78
86
|
@props.fetch_from_section( 'headers', normalize_key( key ), nil )
|
79
87
|
end
|
80
88
|
|
89
|
+
def default_fetch_shortcuts
|
90
|
+
fetch_shortcuts = @props_default.fetch( 'fetch', {} )
|
91
|
+
|
92
|
+
fetch_shortcuts = fetch_shortcuts.clone
|
93
|
+
fetch_shortcuts.delete( 'fullerscreen' ) # obsolete (do not promote any longer)
|
94
|
+
fetch_shortcuts.delete( 'slippy' ) # needs update/maintainer anyone?
|
95
|
+
fetch_shortcuts.delete( 'shower' ) # needs update/maintainer anyone?
|
96
|
+
|
97
|
+
fetch_shortcuts.delete( 's6syntax' ) # better wait for next update
|
98
|
+
fetch_shortcuts.delete( 's6blank' ) # better wait for next update
|
99
|
+
|
100
|
+
fetch_shortcuts
|
101
|
+
end
|
102
|
+
|
81
103
|
def markdown_post_processing?( lib )
|
82
104
|
## todo: normalize key/lib???
|
83
105
|
@props.fetch_from_section( lib, 'post-processing', true )
|
@@ -3,6 +3,39 @@ module Slideshow
|
|
3
3
|
module SlideFilter
|
4
4
|
|
5
5
|
|
6
|
+
def takahashi_slide_breaks( content )
|
7
|
+
|
8
|
+
inline_count = 0
|
9
|
+
line_count = 0
|
10
|
+
|
11
|
+
###########################
|
12
|
+
## allows one // two // three
|
13
|
+
|
14
|
+
content.gsub!( /\b[ ]+\/{2}[ ]+\b/) do |match|
|
15
|
+
inline_count += 1
|
16
|
+
"\n\n<!-- _S9SLIDE_ -->\n\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
############################
|
20
|
+
## allows
|
21
|
+
##
|
22
|
+
## one
|
23
|
+
## //
|
24
|
+
## two
|
25
|
+
## //
|
26
|
+
## three
|
27
|
+
|
28
|
+
content.gsub!( /^[ ]*\/{2}[ ]*$/ ) do |match|
|
29
|
+
line_count += 1
|
30
|
+
"\n\n<!-- _S9SLIDE_ -->\n\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
puts " Adding #{inline_count+line_count} takahashi slide breaks (#{inline_count} //-inline, #{line_count} //-line)..."
|
34
|
+
|
35
|
+
content
|
36
|
+
end
|
37
|
+
|
38
|
+
|
6
39
|
# add slide directive before h1 (tells slideshow gem where to break slides)
|
7
40
|
#
|
8
41
|
# e.g. changes:
|
data/lib/slideshow/version.rb
CHANGED
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
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: 2012-06-
|
18
|
+
date: 2012-06-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: props
|