slideshow-models 2.5.0 → 3.0.0
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.
- 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
@@ -8,14 +8,12 @@ class List
|
|
8
8
|
|
9
9
|
include ManifestHelper
|
10
10
|
|
11
|
-
### fix: remove opts, use config (wrapped!!)
|
12
11
|
|
13
|
-
def initialize(
|
14
|
-
@opts = opts
|
12
|
+
def initialize( config )
|
15
13
|
@config = config
|
16
14
|
end
|
17
15
|
|
18
|
-
attr_reader :
|
16
|
+
attr_reader :config
|
19
17
|
|
20
18
|
def run
|
21
19
|
home = Env.home
|
@@ -8,14 +8,12 @@ class Plugins
|
|
8
8
|
|
9
9
|
include PluginHelper
|
10
10
|
|
11
|
-
### fix: remove opts, use config (wrapped!!)
|
12
11
|
|
13
|
-
def initialize(
|
14
|
-
@opts = opts
|
12
|
+
def initialize( config )
|
15
13
|
@config = config
|
16
14
|
end
|
17
15
|
|
18
|
-
attr_reader :
|
16
|
+
attr_reader :config
|
19
17
|
|
20
18
|
def run
|
21
19
|
home = Env.home
|
@@ -8,17 +8,14 @@ class Quick
|
|
8
8
|
|
9
9
|
include ManifestHelper
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def initialize( opts, config )
|
14
|
-
@opts = opts
|
11
|
+
def initialize( config )
|
15
12
|
@config = config
|
16
13
|
end
|
17
14
|
|
18
|
-
attr_reader :
|
15
|
+
attr_reader :config
|
19
16
|
|
20
17
|
def run
|
21
|
-
manifest_name =
|
18
|
+
manifest_name = config.quick_manifest.gsub('.txt','').gsub('.quick','') # make sure we get name w/o .quick and .txt extension
|
22
19
|
|
23
20
|
### todo:fix: always download quickstart templates (except welcome?)
|
24
21
|
# how to make sure the won't go stale in the cache after the download?
|
@@ -39,7 +36,7 @@ class Quick
|
|
39
36
|
end
|
40
37
|
|
41
38
|
manifestsrc = matches[0][1]
|
42
|
-
pakpath =
|
39
|
+
pakpath = config.output_path
|
43
40
|
|
44
41
|
logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" )
|
45
42
|
|
@@ -85,4 +82,4 @@ class Quick
|
|
85
82
|
end # method fetch_pak
|
86
83
|
|
87
84
|
end # class GenTemplates
|
88
|
-
end # module Slideshow
|
85
|
+
end # module Slideshow
|
data/lib/slideshow/config.rb
CHANGED
@@ -10,19 +10,17 @@ class Config
|
|
10
10
|
@opts = opts
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
## -- todo: allow (direct) access to opts - why? why not?
|
14
|
+
## attr_reader :opts
|
14
15
|
|
15
|
-
def
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def takahashi?
|
24
|
-
@opts.takahashi?
|
25
|
-
end
|
16
|
+
def manifest() @opts.manifest; end
|
17
|
+
def quick_manifest() @opts.quick_manifest; end
|
18
|
+
def header_level() @opts.header_level; end
|
19
|
+
def slide?() @opts.slide?; end
|
20
|
+
def takahashi?() @opts.takahashi?; end
|
21
|
+
def test?() @opts.test?; end ## in test mode (yes/no) - will (auto-)include test templates
|
22
|
+
def verbose?() @opts.verbose?; end
|
23
|
+
def output_path() @opts.output_path; end
|
26
24
|
|
27
25
|
|
28
26
|
# todo/fix: fix references after this move to here, that is, Config class
|
@@ -34,7 +32,7 @@ class Config
|
|
34
32
|
|
35
33
|
def config_dir
|
36
34
|
unless @config_dir # first time? calculate config_dir value to "cache"
|
37
|
-
@config_dir = opts.config_path
|
35
|
+
@config_dir = @opts.config_path
|
38
36
|
|
39
37
|
# make sure path exists
|
40
38
|
FileUtils.makedirs( @config_dir ) unless File.directory? @config_dir
|
@@ -163,43 +161,6 @@ class Config
|
|
163
161
|
@props.fetch_from_section( 'headers', normalize_key( key ), nil )
|
164
162
|
end
|
165
163
|
|
166
|
-
|
167
|
-
def markdown_post_processing?( lib )
|
168
|
-
## todo: normalize key/lib???
|
169
|
-
@props.fetch_from_section( lib, 'post-processing', true )
|
170
|
-
end
|
171
|
-
|
172
|
-
def known_rest_extnames
|
173
|
-
@props.fetch_from_section( 'rest', 'extnames', [] )
|
174
|
-
end
|
175
|
-
|
176
|
-
def known_textile_extnames
|
177
|
-
@props.fetch_from_section( 'textile', 'extnames', [] )
|
178
|
-
end
|
179
|
-
|
180
|
-
def known_mediawiki_extnames
|
181
|
-
@props.fetch_from_section( 'mediawiki', 'extnames', [] )
|
182
|
-
end
|
183
|
-
|
184
|
-
def known_markdown_extnames
|
185
|
-
## delegate config to Markdown gem for now
|
186
|
-
## todo/fix: how to pass on setting to Markdown gem??
|
187
|
-
Markdown.extnames
|
188
|
-
end
|
189
|
-
|
190
|
-
def known_extnames
|
191
|
-
# returns an array of known file extensions e.g.
|
192
|
-
# [ '.textile', '.t' ]
|
193
|
-
#
|
194
|
-
# using nested key
|
195
|
-
# textile:
|
196
|
-
# extnames: [ .textile, .t ]
|
197
|
-
#
|
198
|
-
# ruby check: is it better self. ?? or more confusing
|
199
|
-
# possible conflict only with write access (e.g. prop=)
|
200
|
-
|
201
|
-
known_textile_extnames + known_markdown_extnames + known_mediawiki_extnames + known_rest_extnames
|
202
|
-
end
|
203
164
|
|
204
165
|
def text_filters
|
205
166
|
@props.fetch( 'filters', [] )
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
|
5
|
+
class HeadersDrop < Liquid::Drop
|
6
|
+
|
7
|
+
def initialize( headers )
|
8
|
+
@headers = headers
|
9
|
+
end
|
10
|
+
|
11
|
+
def before_method( method )
|
12
|
+
## note: assume returned value is always a string or nil (if key not found)
|
13
|
+
puts " call HeadersDrop#before_method >#{method}< : #{method.class}"
|
14
|
+
value = @headers[ method ]
|
15
|
+
value
|
16
|
+
end
|
17
|
+
|
18
|
+
end # class HeadersDrop
|
19
|
+
|
20
|
+
|
21
|
+
class SlideDrop < Liquid::Drop
|
22
|
+
|
23
|
+
def initialize( slide )
|
24
|
+
@slide = slide
|
25
|
+
end
|
26
|
+
|
27
|
+
def content() puts " call SlideDrop#content"; @slide.content; end
|
28
|
+
def content_without_header() puts " call SlideDrop#content_w/o_header"; @slide.content_without_header; end
|
29
|
+
def header() puts " call SlideDrop#header"; @slide.header; end
|
30
|
+
def classes() puts " call SlideDrop#classes"; @slide.classes; end
|
31
|
+
def data_attributes() puts " call SlideDrop#data_attributes"; @slide.data_attributes; end
|
32
|
+
end ## class SlideDrop
|
33
|
+
|
34
|
+
|
35
|
+
end # module Slideshow
|
@@ -11,7 +11,7 @@ def dump_content_to_file_debug_text_erb( content )
|
|
11
11
|
# - opts
|
12
12
|
# - outdir
|
13
13
|
|
14
|
-
return content unless
|
14
|
+
return content unless config.verbose?
|
15
15
|
|
16
16
|
outname = "#{outdir}/#{@name}.debug.text.erb"
|
17
17
|
|
@@ -32,7 +32,7 @@ def dump_content_to_file_debug_html( content )
|
|
32
32
|
# - opts
|
33
33
|
# - outdir
|
34
34
|
|
35
|
-
return content unless
|
35
|
+
return content unless config.verbose?
|
36
36
|
|
37
37
|
outname = "#{outdir}/#{@name}.debug.html"
|
38
38
|
|
@@ -53,7 +53,7 @@ def dump_content_to_file_debug_text( content )
|
|
53
53
|
# - opts
|
54
54
|
# - outdir
|
55
55
|
|
56
|
-
return content unless
|
56
|
+
return content unless config.verbose?
|
57
57
|
|
58
58
|
outname = "#{outdir}/#{@name}.debug.text"
|
59
59
|
|
@@ -38,73 +38,6 @@ module Slideshow
|
|
38
38
|
content
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
# add slide directive before h1 (tells slideshow gem where to break slides)
|
43
|
-
#
|
44
|
-
# e.g. changes:
|
45
|
-
# <h1 id='optional' class='optional'>
|
46
|
-
# to
|
47
|
-
# html comment -> _S9SLIDE_ (note: rdoc can't handle html comments?)
|
48
|
-
# <h1 id='optional' class='optional'>
|
49
|
-
|
50
|
-
def add_slide_directive_before_h1( content )
|
51
|
-
|
52
|
-
# mark h1 for getting wrapped into slide divs
|
53
|
-
# note: use just <h1 since some processors add ids e.g. <h1 id='x'>
|
54
|
-
|
55
|
-
slide_count = 0
|
56
|
-
|
57
|
-
content.gsub!( /<h1/ ) do |match|
|
58
|
-
slide_count += 1
|
59
|
-
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
60
|
-
end
|
61
|
-
|
62
|
-
puts " Adding #{slide_count} slide breaks (using h1 rule)..."
|
63
|
-
|
64
|
-
content
|
65
|
-
end
|
66
|
-
|
67
|
-
def add_slide_directive_before_h2( content )
|
68
|
-
|
69
|
-
slide_count = 0
|
70
|
-
|
71
|
-
content.gsub!( /<h2/ ) do |match|
|
72
|
-
slide_count += 1
|
73
|
-
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
74
|
-
end
|
75
|
-
|
76
|
-
puts " Adding #{slide_count} slide breaks (using h2 rule)..."
|
77
|
-
|
78
|
-
content
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# add slide directive before div h1 (for pandoc-generated html)
|
84
|
-
#
|
85
|
-
# e.g. changes:
|
86
|
-
# <div id='header'>
|
87
|
-
# <h1 id='optional' class='optional'>
|
88
|
-
# to
|
89
|
-
# html comment -> _S9SLIDE_
|
90
|
-
# <div id='header'>
|
91
|
-
# <h1 id='optional' class='optional'>
|
92
|
-
|
93
|
-
|
94
|
-
def add_slide_directive_before_div_h1( content )
|
95
|
-
|
96
|
-
slide_count = 0
|
97
|
-
|
98
|
-
content.gsub!( /<div[^>]*>\s*<h1/ ) do |match|
|
99
|
-
slide_count += 1
|
100
|
-
"\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
|
101
|
-
end
|
102
|
-
|
103
|
-
puts " Adding #{slide_count} slide breaks (using div_h1 rule)..."
|
104
|
-
|
105
|
-
content
|
106
|
-
end
|
107
|
-
|
108
41
|
|
109
42
|
end # module SlideFilter
|
110
43
|
end # module Slideshow
|
@@ -112,3 +45,4 @@ end # module Slideshow
|
|
112
45
|
class Slideshow::Gen
|
113
46
|
include Slideshow::SlideFilter
|
114
47
|
end
|
48
|
+
|
@@ -10,16 +10,6 @@ module Slideshow
|
|
10
10
|
|
11
11
|
include TextUtils::Filter # include comments_percent_style, skip_end_directive, etc. filters
|
12
12
|
|
13
|
-
alias_method :old_comments_percent_style, :comments_percent_style
|
14
|
-
|
15
|
-
def comments_percent_style( content )
|
16
|
-
|
17
|
-
# skip filter for pandoc
|
18
|
-
# - pandoc uses % for its own markdown extension
|
19
|
-
return content if @markup_type == :markdown && Markdown.lib == 'pandoc-ruby'
|
20
|
-
|
21
|
-
old_comments_percent_style( content )
|
22
|
-
end
|
23
13
|
|
24
14
|
def directives_bang_style_to_percent_style( content )
|
25
15
|
|
@@ -41,14 +31,7 @@ def directives_bang_style_to_percent_style( content )
|
|
41
31
|
end
|
42
32
|
|
43
33
|
def directives_percent_style( content )
|
44
|
-
|
45
|
-
# skip filter for pandoc
|
46
|
-
# - pandoc uses % for its own markdown extension
|
47
|
-
# - don't process % pass it along/through to pandoc
|
48
|
-
|
49
|
-
return content if @markup_type == :markdown && Markdown.lib == 'pandoc-ruby'
|
50
|
-
|
51
|
-
|
34
|
+
|
52
35
|
directive_unparsed = 0
|
53
36
|
directive_expr = 0
|
54
37
|
directive_block_beg = 0
|
@@ -11,7 +11,7 @@ def step( opts={}, &blk )
|
|
11
11
|
text = capture_erb(&blk)
|
12
12
|
|
13
13
|
before = "<!-- begin step #{opts.inspect} -->\n"
|
14
|
-
before << "<div class='step' markdown='
|
14
|
+
before << "<div class='step' markdown='1'>\n"
|
15
15
|
|
16
16
|
after = "</div>\n"
|
17
17
|
after << "<!-- end step -->\n"
|
@@ -39,6 +39,9 @@ module ManifestHelper
|
|
39
39
|
builtin_patterns = []
|
40
40
|
builtin_patterns << "#{SlideshowTemplates.root}/templates/*.txt" if defined?( SlideshowTemplates )
|
41
41
|
|
42
|
+
test_patterns = []
|
43
|
+
test_patterns << "#{Slideshow.root}/test/templates/*/*.txt"
|
44
|
+
|
42
45
|
config_patterns = [
|
43
46
|
"#{config.config_dir}/templates/*.txt",
|
44
47
|
"#{config.config_dir}/templates/*/*.txt"
|
@@ -51,6 +54,7 @@ module ManifestHelper
|
|
51
54
|
|
52
55
|
patterns = []
|
53
56
|
patterns += current_patterns
|
57
|
+
patterns += test_patterns if config.test? ## (auto-)add test templates in test mode
|
54
58
|
patterns += config_patterns
|
55
59
|
patterns += builtin_patterns
|
56
60
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
module MarkdownEngines
|
5
|
+
|
6
|
+
## note: for now keep it simple use just kramdown
|
7
|
+
|
8
|
+
def markdown_to_html( content )
|
9
|
+
## note: set to gfm (github-flavored markdown) by default
|
10
|
+
## see http://kramdown.gettalong.org/parser/gfm.html
|
11
|
+
kramdown_config = {
|
12
|
+
'input' => 'GFM',
|
13
|
+
'hard_wrap' => false
|
14
|
+
}
|
15
|
+
|
16
|
+
puts " Converting markdown-text (#{content.length} bytes) to HTML using kramdown library with #{kramdown_config.inspect}..."
|
17
|
+
|
18
|
+
Kramdown::Document.new( content, kramdown_config ).to_html
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module MarkdownEngines
|
22
|
+
end # module Slideshow
|
23
|
+
|
24
|
+
class Slideshow::Gen
|
25
|
+
include Slideshow::MarkdownEngines
|
26
|
+
end
|
27
|
+
|
data/lib/slideshow/models.rb
CHANGED
@@ -19,12 +19,9 @@ require 'fileutils'
|
|
19
19
|
require 'active_support/all'
|
20
20
|
|
21
21
|
require 'props' # manage settings/env
|
22
|
-
require 'logutils'
|
23
|
-
|
24
|
-
require 'markdown' # default markdown library
|
22
|
+
require 'logutils' # logger utils library
|
25
23
|
require 'fetcher' # fetch docs and blogs via http, https, etc.
|
26
24
|
|
27
|
-
|
28
25
|
class Env
|
29
26
|
def self.slideshowopt
|
30
27
|
ENV[ 'SLIDESHOWOPT' ]
|
@@ -34,14 +31,20 @@ end # class Env
|
|
34
31
|
require 'textutils' # text filters and helpers
|
35
32
|
require 'pakman' # template pack manager
|
36
33
|
|
34
|
+
require 'kramdown' # default markdown library
|
35
|
+
|
37
36
|
|
38
37
|
# our own code
|
39
38
|
require 'slideshow/version' # note: let version always go first
|
40
|
-
require 'slideshow/
|
39
|
+
require 'slideshow/opts'
|
41
40
|
require 'slideshow/config'
|
41
|
+
require 'slideshow/headers'
|
42
42
|
require 'slideshow/manifest_helpers'
|
43
43
|
require 'slideshow/plugin_helpers'
|
44
|
-
require 'slideshow/slide'
|
44
|
+
require 'slideshow/models/slide'
|
45
|
+
require 'slideshow/models/deck'
|
46
|
+
require 'slideshow/markdown'
|
47
|
+
require 'slideshow/drops'
|
45
48
|
|
46
49
|
require 'slideshow/commands/fetch'
|
47
50
|
require 'slideshow/commands/gen'
|
@@ -50,11 +53,6 @@ require 'slideshow/commands/plugins'
|
|
50
53
|
require 'slideshow/commands/quick'
|
51
54
|
|
52
55
|
|
53
|
-
require 'slideshow/markup/markdown'
|
54
|
-
require 'slideshow/markup/mediawiki'
|
55
|
-
require 'slideshow/markup/textile'
|
56
|
-
|
57
|
-
|
58
56
|
# load built-in (required) helpers/plugins
|
59
57
|
require 'slideshow/helpers/text_helper'
|
60
58
|
require 'slideshow/helpers/capture_helper'
|
@@ -62,7 +60,6 @@ require 'slideshow/helpers/step_helper'
|
|
62
60
|
require 'slideshow/helpers/background_helper'
|
63
61
|
require 'slideshow/helpers/source_helper'
|
64
62
|
require 'slideshow/helpers/directive_helper'
|
65
|
-
require 'slideshow/helpers/markdown_helper'
|
66
63
|
|
67
64
|
require 'slideshow/helpers/syntax/sh_helper'
|
68
65
|
|
@@ -82,7 +79,6 @@ require 'slideshow/filters/slide_filter'
|
|
82
79
|
BUILTIN_OPT_HELPERS = [
|
83
80
|
'slideshow/helpers/syntax/uv_helper.rb',
|
84
81
|
'slideshow/helpers/syntax/coderay_helper.rb',
|
85
|
-
'slideshow/markup/rest.rb',
|
86
82
|
]
|
87
83
|
|
88
84
|
BUILTIN_OPT_HELPERS.each do |helper|
|