slideshow-models 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae6fbc86bac566ecfa4b2906afc0c11d243e061d
4
- data.tar.gz: eee81eb2a0456e3e284e0100007b06e1d25aef94
3
+ metadata.gz: 203fe3dd4ab5456281b10e0a77d275df5c0f093b
4
+ data.tar.gz: f4814e971e3d9a517600c5a2f5de17cf8bcf74f9
5
5
  SHA512:
6
- metadata.gz: ef4318d385ef0a99775c3e9194ab63a2ed0e5fd3752ded64407906d852bfdda5bc91e6464f3457e6086cdb397fe2e3c1dd2f404f000c381854ae7789c0953e1c
7
- data.tar.gz: 98d0cf267ff810f4b5922038e577db9d378ed5a46c0e086eb841af70cdd4bdeb1957b29191d1606b3c008ff4a10d7c9c3a370bba366ad9b45e08e7aa474eb90a
6
+ metadata.gz: 9e764b6fab1cc4240db3ac3f7459a2c0cf3ff77812e861710681671d7cfc4efeb0ce4ee2987416af79f3cf1cb014b6555ae23db4c82a6241b0468fcf4951c297
7
+ data.tar.gz: 49c0596b58f3414dfdaef751e133ade4fc806a8739c50d637675906d24ed9132527d291b21df5ec5ce84ae8d193c8dbedf6bad2248833ae1e1c3046c0f708ed0
data/Manifest.txt CHANGED
@@ -2,14 +2,17 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- config/slideshow.builtin.yml
6
5
  config/slideshow.index.yml
7
6
  config/slideshow.yml
7
+ lib/slideshow/commands/build.rb
8
8
  lib/slideshow/commands/fetch.rb
9
9
  lib/slideshow/commands/gen.rb
10
10
  lib/slideshow/commands/list.rb
11
+ lib/slideshow/commands/manifest_finder.rb
12
+ lib/slideshow/commands/merge.rb
11
13
  lib/slideshow/commands/plugins.rb
12
14
  lib/slideshow/commands/quick.rb
15
+ lib/slideshow/commands/update.rb
13
16
  lib/slideshow/config.rb
14
17
  lib/slideshow/drops.rb
15
18
  lib/slideshow/filters/debug_filter.rb
@@ -39,7 +42,7 @@ test/samples/test.md
39
42
  test/samples/test_content_for.md
40
43
  test/templates/test/test.html
41
44
  test/templates/test/test.txt
42
- test/test_gen.rb
45
+ test/test_build.rb
43
46
  test/test_kramdown.rb
44
47
  test/test_slide.rb
45
48
  test/test_version.rb
@@ -12,7 +12,7 @@
12
12
  # maps shortcut to URI
13
13
 
14
14
 
15
- s6blank: https://raw.github.com/slideshow-templates/slideshow-s6-blank/master/s6blank.txt
15
+ s6blank: https://raw.github.com/slideshow-templates/slideshow-s6-blank/gh-pages/s6blank.txt
16
16
 
17
17
  s6syntax: https://raw.github.com/slideshow-templates/slideshow-s6-syntax-highlighter/master/s6syntax.txt
18
18
 
@@ -31,12 +31,12 @@ csss:
31
31
  - https://raw.github.com/slideshow-templates/slideshow-csss/master/csss.txt.quick
32
32
 
33
33
  deck.js:
34
- - https://raw.github.com/slideshow-templates/slideshow-deck.js/master/deck.js.txt
35
- - https://raw.github.com/slideshow-templates/slideshow-deck.js/master/deck.js.txt.quick
34
+ - https://raw.github.com/slideshow-templates/slideshow-deck.js/gh-pages/deck.js.txt
35
+ - https://raw.github.com/slideshow-templates/slideshow-deck.js/gh-pages/deck.js.txt.quick
36
36
 
37
37
  impress.js:
38
- - https://raw.github.com/slideshow-templates/slideshow-impress.js/master/impress.js.txt
39
- - https://raw.github.com/slideshow-templates/slideshow-impress.js/master/impress.js.txt.quick
38
+ - https://raw.github.com/slideshow-templates/slideshow-impress.js/gh-pages/impress.js.txt
39
+ - https://raw.github.com/slideshow-templates/slideshow-impress.js/gh-pages/impress.js.txt.quick
40
40
 
41
41
  shower: https://raw.github.com/slideshow-templates/slideshow-shower/master/shower.txt
42
42
 
@@ -0,0 +1,210 @@
1
+ # encoding: utf-8
2
+
3
+ module Slideshow
4
+
5
+
6
+ class Build
7
+
8
+ include LogUtils::Logging
9
+
10
+
11
+ def initialize( config )
12
+ @config = config
13
+ @headers = Headers.new( config )
14
+
15
+ ## todo: check if we need to use expand_path - Dir.pwd always absolute (check ~/user etc.)
16
+ @usrdir = File.expand_path( Dir.pwd ) # save original (current) working directory
17
+ end
18
+
19
+ attr_reader :usrdir # original working dir (user called slideshow from)
20
+ attr_reader :config, :headers
21
+
22
+
23
+ def process_files( args )
24
+
25
+ ###
26
+ # returns a hash of merged buffers e.g.
27
+ # { text: '...',
28
+ # js: '...',
29
+ # css: '...',
30
+ # }
31
+ #
32
+
33
+ buffers = {}
34
+
35
+ args.each do |fn|
36
+
37
+ dirname = File.dirname( fn )
38
+ basename = File.basename( fn, '.*' )
39
+ extname = File.extname( fn )
40
+
41
+ logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
42
+
43
+ content = File.read_utf8( fn )
44
+
45
+ if extname.downcase == 'css'
46
+ key = :css # buffer key
47
+ elsif extname.downcase == 'js'
48
+ key = :js
49
+ else ## assume main text/content
50
+ ##
51
+ ## todo/check: process text files with gen(erator) one-by-one later? why? why not?
52
+ # for now process as one block all together (use sourcedir of first text file)
53
+ key = :text
54
+ end
55
+
56
+ if buffers[ key ].nil? ## first entry
57
+ h = { contents: [content],
58
+ files: [fn],
59
+ }
60
+ buffers[ key ] = h
61
+ else ## second, third, etc. entry
62
+ h = buffers[ key ]
63
+ h[:contents] << content
64
+ h[:files] << fn
65
+ end
66
+ end
67
+
68
+ buffers
69
+ end # process files
70
+
71
+
72
+ def create_slideshow( args )
73
+
74
+ ## first check if manifest exists / available / valid
75
+ manifestsrc = ManifestFinder.new( config ).find_manifestsrc( config.manifest )
76
+
77
+
78
+ # expand output path in current dir and make sure output path exists
79
+ outdir = File.expand_path( config.output_path, usrdir )
80
+ logger.debug "setting outdir to >#{outdir}<"
81
+
82
+ FileUtils.makedirs( outdir ) unless File.directory? outdir
83
+
84
+
85
+ if args.is_a? String
86
+ args = [args] ## for now for testing always assume array
87
+ end
88
+
89
+ buffers = process_files( args )
90
+
91
+ puts "buffers:"
92
+ pp buffers
93
+
94
+
95
+ ### todo/fix:
96
+ ## reset headers too - why? why not?
97
+
98
+ # shared variables for templates (binding)
99
+ content_for = {} # reset content_for hash
100
+ # give helpers/plugins a session-like hash
101
+ session = {} # reset session hash for plugins/helpers
102
+
103
+ name = 'untitled' ## default name (auto-detect from first file e.g. rest.txt => rest etc.)
104
+
105
+ content = ''
106
+
107
+ ## check for css and js buffers
108
+ ## todo/fix: check if content_for key is a symbol or just a string !!!!!!
109
+ if buffers[:css]
110
+ ## concat files (separate with newlines)
111
+ content_for[:css] = buffers[:css][:contents].join( "\n\n" )
112
+ end
113
+
114
+ if buffers[:js]
115
+ ## concat files (separate with newlines)
116
+ content_for[:js] = buffers[:js][:contents].join( "\n\n" )
117
+ end
118
+
119
+
120
+ gen = Gen.new( @config,
121
+ @headers,
122
+ session,
123
+ content_for )
124
+
125
+ chunk_size = buffers[:text] ? buffers[:text][:contents].size : 0
126
+
127
+ (0...chunk_size).each do |i|
128
+
129
+ chunk = buffers[:text][:contents][i]
130
+ fn = buffers[:text][:files][i]
131
+
132
+ dirname = File.dirname( fn )
133
+ basename = File.basename( fn, '.*' )
134
+ extname = File.extname( fn )
135
+ logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
136
+
137
+ ## for now use first text file for (auto-)caluclation name and source folder
138
+ if i==0
139
+ name = basename
140
+ puts "Preparing slideshow '#{basename}'..."
141
+ end
142
+
143
+ puts " [#{i+1}/#{chunk_size}] Generating '#{basename}' (#{dirname})..."
144
+
145
+
146
+ # change working dir to sourcefile dir
147
+ # todo: add a -c option to commandline? to let you set cwd?
148
+
149
+ srcdir = File.expand_path( dirname, usrdir )
150
+ logger.debug "setting srcdir to >#{srcdir}<"
151
+
152
+ logger.debug "changing cwd to src - new >#{srcdir}<, old >#{Dir.pwd}<"
153
+ Dir.chdir srcdir
154
+
155
+
156
+ ####################
157
+ ## todo/fix: move ctx to Gen.initialize - why? why not?
158
+ # move outdir, usrdir, name to Gen.initialize ??
159
+ # add basename, dirname ?
160
+ gen_ctx = {
161
+ name: name,
162
+ srcdir: srcdir,
163
+ outdir: outdir,
164
+ usrdir: usrdir,
165
+ }
166
+
167
+ chunk = gen.render( chunk, gen_ctx )
168
+
169
+ if i==0 ## first chunk
170
+ content << chunk
171
+ else ## follow-up chunk (start off with two newlines)
172
+ content << "\n\n"
173
+ content << chunk
174
+ end
175
+ end # each buffer.text.contents
176
+
177
+
178
+ logger.debug "restoring cwd to usr - new >#{usrdir}<, old >#{Dir.pwd}<"
179
+ Dir.chdir( usrdir )
180
+
181
+
182
+ # post-processing (all-in-one HTML with directive as HTML comments)
183
+ deck = Deck.new( content, header_level: config.header_level,
184
+ use_slide: config.slide? )
185
+
186
+
187
+ ## note: merge for now requires resetting to
188
+ ## original working dir (user called slideshow from)
189
+ merge = Merge.new( config )
190
+
191
+ merge_ctx = {
192
+ manifestsrc: manifestsrc,
193
+ outdir: outdir,
194
+ name: name,
195
+ }
196
+
197
+ merge.merge( deck,
198
+ merge_ctx,
199
+ headers,
200
+ content_for )
201
+
202
+
203
+ puts 'Done.'
204
+ end # method create_slideshow
205
+
206
+
207
+ end # class Build
208
+
209
+ end # class Slideshow
210
+
@@ -21,24 +21,6 @@ class Fetch
21
21
  end
22
22
 
23
23
 
24
- def update # update shortcut index
25
- dest = config.shortcut_index_file
26
-
27
- destfull = File.expand_path( dest )
28
- destpath = File.dirname( destfull )
29
- FileUtils.makedirs( destpath ) unless File.directory?( destpath )
30
-
31
- logger.debug "destfull=>#{destfull}<"
32
- logger.debug "destpath=>#{destpath}<"
33
-
34
- ## todo/fix: use a config setting for index url (do NOT hard core)
35
- src = 'https://raw.github.com/slideshow-s9/registry/master/slideshow.index.yml'
36
-
37
- puts "Updating shortcut index - downloading '#{src}'..."
38
- ::Fetcher::Worker.new.copy( src, destfull )
39
- end
40
-
41
-
42
24
  def fetch( shortcut_or_source )
43
25
 
44
26
  logger.debug "fetch >#{shortcut_or_source}<"
@@ -5,29 +5,61 @@ module Slideshow
5
5
  ## fix:/todo: move generation code out of command into its own class
6
6
  ## not residing/depending on cli
7
7
 
8
- class Gen ## todo: rename command to build
8
+ class Gen ## rename to GenCtx (Context) - why? why not?
9
9
 
10
10
  include LogUtils::Logging
11
11
 
12
- include ManifestHelper
13
12
 
14
-
15
- def initialize( config )
16
- @config = config
17
- @headers = Headers.new( config )
18
-
19
- ## todo: check if we need to use expand_path - Dir.pwd always absolute (check ~/user etc.)
20
- @usrdir = File.expand_path( Dir.pwd ) # save original (current) working directory
13
+ def initialize( config, headers, session={}, content_for={} )
14
+ @config = config
15
+ @headers = headers
16
+
17
+ @session = session
18
+ @content_for = content_for
21
19
  end
22
20
 
21
+ attr_reader :config, :headers
22
+ attr_reader :session # give helpers/plugins a session-like hash
23
+
24
+ ## todo/check: usrdir needed for something (e.g. why keep it?) - remove? why? why not??
23
25
  attr_reader :usrdir # original working dir (user called slideshow from)
24
- attr_reader :srcdir, :outdir, :pakdir # NB: "initalized" in create_slideshow
26
+ attr_reader :srcdir, :outdir # NB: "initalized" in create_slideshow
27
+
28
+
29
+ def render( content, ctx )
30
+
31
+ ####################
32
+ ## todo/fix: move ctx to Gen.initialize - why? why not?
33
+ @name = ctx[:name]
34
+
35
+ @outdir = ctx[:outdir]
36
+ @srcdir = ctx[:srcdir]
37
+ @usrdir = ctx[:usrdir]
38
+
39
+ # run text filters
40
+
41
+ config.text_filters.each do |filter|
42
+ mn = filter.tr( '-', '_' ).to_sym # construct method name (mn)
43
+ puts " run filter #{mn}..."
44
+ content = send( mn, content ) # call filter e.g. include_helper_hack( content )
45
+ end
46
+
47
+ if config.takahashi?
48
+ content = takahashi_slide_breaks( content )
49
+ end
50
+
51
+ # convert light-weight markup to hypertext
52
+
53
+ content = markdown_to_html( content )
54
+ content
55
+ end # method render
25
56
 
26
57
 
27
- attr_reader :config, :headers
28
- attr_reader :session # give helpers/plugins a session-like hash
29
58
 
30
-
59
+ ###
60
+ # some markdown guard helpers
61
+ # (e.g. guard text/mark text for do NOT convert)
62
+
31
63
  def guard_text( text )
32
64
  # todo/fix 2: note we need to differentiate between blocks and inline
33
65
  # thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)
@@ -56,171 +88,7 @@ class Gen ## todo: rename command to build
56
88
  end
57
89
 
58
90
 
59
- def create_slideshow( fn )
60
-
61
- manifest_path_or_name = config.manifest
62
-
63
- # add .txt file extension if missing (for convenience)
64
- if manifest_path_or_name.downcase.ends_with?( '.txt' ) == false
65
- manifest_path_or_name << '.txt'
66
- end
67
-
68
- logger.debug "manifest=#{manifest_path_or_name}"
69
-
70
- # check if file exists (if yes use custom template package!) - allows you to override builtin package with same name
71
- if File.exists?( manifest_path_or_name )
72
- manifestsrc = manifest_path_or_name
73
- else
74
- # check for builtin manifests
75
- manifests = installed_template_manifests
76
- matches = manifests.select { |m| m[0] == manifest_path_or_name }
77
-
78
- if matches.empty?
79
- puts "*** error: unknown template manifest '#{manifest_path_or_name}'"
80
- # todo: list installed manifests
81
- exit 2
82
- end
83
-
84
- manifestsrc = matches[0][1]
85
- end
86
-
87
- ### todo: use File.expand_path( xx, relative_to ) always with second arg
88
- ## do NOT default to cwd (because cwd will change!)
89
-
90
- # Reference src with absolute path, because this can be used with different pwd
91
- manifestsrc = File.expand_path( manifestsrc, usrdir )
92
-
93
- # expand output path in current dir and make sure output path exists
94
- @outdir = File.expand_path( config.output_path, usrdir )
95
- logger.debug "setting outdir to >#{outdir}<"
96
- FileUtils.makedirs( outdir ) unless File.directory? outdir
97
-
98
- dirname = File.dirname( fn )
99
- basename = File.basename( fn, '.*' )
100
- extname = File.extname( fn )
101
- logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
102
-
103
- # change working dir to sourcefile dir
104
- # todo: add a -c option to commandline? to let you set cwd?
105
-
106
- @srcdir = File.expand_path( dirname, usrdir )
107
- logger.debug "setting srcdir to >#{srcdir}<"
108
-
109
- unless usrdir == srcdir
110
- logger.debug "changing cwd to src - new >#{srcdir}<, old >#{Dir.pwd}<"
111
- Dir.chdir srcdir
112
- end
113
-
114
- puts "Preparing slideshow '#{basename}'..."
115
-
116
- ### todo/fix:
117
- ## reset headers too - why? why not?
118
-
119
- # shared variables for templates (binding)
120
- @content_for = {} # reset content_for hash
121
-
122
- @name = basename
123
- @extname = extname
124
-
125
- @session = {} # reset session hash for plugins/helpers
126
-
127
- inname = "#{basename}#{extname}"
128
-
129
- logger.debug "inname=#{inname}"
130
-
131
- content = File.read_utf8( inname )
132
-
133
- # run text filters
134
-
135
- config.text_filters.each do |filter|
136
- mn = filter.tr( '-', '_' ).to_sym # construct method name (mn)
137
- puts " run filter #{mn}..."
138
- content = send( mn, content ) # call filter e.g. include_helper_hack( content )
139
- end
140
-
141
-
142
- if config.takahashi?
143
- content = takahashi_slide_breaks( content )
144
- end
145
-
146
-
147
- # convert light-weight markup to hypertext
148
-
149
- content = markdown_to_html( content )
150
-
151
-
152
- # post-processing
153
- deck = Deck.new( content, header_level: config.header_level,
154
- use_slide: config.slide? )
155
-
156
-
157
- ### todo/fix: move merge to its own
158
- ## class e.g. commands/merge.rb or something
159
- ## or use Merger - why? why not?
160
-
161
-
162
- #### pak merge
163
- # nb: change cwd to template pak root
164
-
165
- @pakdir = File.dirname( manifestsrc ) # template pak root - make availabe too in erb via binding
166
- logger.debug " setting pakdir to >#{pakdir}<"
167
-
168
- # todo/fix: change current work dir (cwd) in pakman gem itself
169
- # for now lets do it here
170
-
171
- logger.debug "changing cwd to pak - new >#{pakdir}<, old >#{Dir.pwd}<"
172
- Dir.chdir( pakdir )
173
-
174
-
175
- pakpath = outdir
176
-
177
- logger.debug( "manifestsrc >#{manifestsrc}<, pakpath >#{pakpath}<" )
178
-
179
- ###########################################
180
- ## fix: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
181
- ## todo: setup hash for binding
182
- ctx = { 'name' => @name,
183
- 'headers' => HeadersDrop.new( @headers ),
184
- 'content' => deck.content,
185
- 'slides' => deck.slides.map { |slide| SlideDrop.new(slide) }, # strutured content - use LiquidDrop - why? why not?
186
- ## todo/fix: add content_for hash
187
- ## and some more -- ??
188
- }
189
-
190
- ## add content_for entries e.g.
191
- ## content_for :js => more_content_for_js or content_for_js or extra_js etc.
192
- ## for now allow all three aliases
193
-
194
- puts "content_for:"
195
- pp @content_for
196
-
197
- @content_for.each do |k,v|
198
- puts " (auto-)add content_for >#{k.to_s}< to ctx:"
199
- puts v
200
- ctx[ "more_content_for_#{k}"] = v
201
- ctx[ "content_for_#{k}" ] = v
202
- ctx[ "extra_#{k}" ] = v
203
- end
204
-
205
- puts "ctx:"
206
- pp ctx
207
-
208
-
209
- Pakman::LiquidTemplater.new.merge_pak( manifestsrc, pakpath, ctx, basename )
210
-
211
- logger.debug "restoring cwd to src - new >#{srcdir}<, old >#{Dir.pwd}<"
212
- Dir.chdir( srcdir )
213
-
214
- ## pop/restore org (original) working folder/dir
215
- unless usrdir == srcdir
216
- logger.debug "restoring cwd to usr - new >#{usrdir}<, old >#{Dir.pwd}<"
217
- Dir.chdir( usrdir )
218
- end
219
-
220
- puts "Done."
221
- end # method create_slideshow
222
-
223
-
224
91
  end # class Gen
225
92
 
226
- end # class Slideshow
93
+ end # class Slideshow
94
+
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ module Slideshow
4
+
5
+ class ManifestFinder
6
+
7
+ include LogUtils::Logging
8
+
9
+ include ManifestHelper
10
+
11
+
12
+ def initialize( config )
13
+ @config = config
14
+ @usrdir = File.expand_path( Dir.pwd ) # save original (current) working directory
15
+ end
16
+
17
+ attr_reader :config
18
+ attr_reader :usrdir # original working dir (user called slideshow from)
19
+
20
+
21
+ def find_manifestsrc( manifest_arg ) ## rename - just use find_manifest ??
22
+
23
+ manifest_path_or_name = manifest_arg.dup ## make a copy
24
+
25
+ # add .txt file extension if missing (for convenience)
26
+ if manifest_path_or_name.downcase.ends_with?( '.txt' ) == false
27
+ manifest_path_or_name << '.txt'
28
+ end
29
+
30
+ logger.debug "manifest=#{manifest_path_or_name}"
31
+
32
+ # check if file exists (if yes use custom template package!) - allows you to override builtin package with same name
33
+ if File.exists?( manifest_path_or_name )
34
+ manifestsrc = manifest_path_or_name
35
+ else
36
+ # check for builtin manifests
37
+ manifests = installed_template_manifests
38
+ matches = manifests.select { |m| m[0] == manifest_path_or_name }
39
+
40
+ if matches.empty?
41
+ puts "*** error: unknown template manifest '#{manifest_path_or_name}'"
42
+ # todo: list installed manifests
43
+ exit 2
44
+ end
45
+
46
+ manifestsrc = matches[0][1]
47
+ end
48
+
49
+ ### todo: use File.expand_path( xx, relative_to ) always with second arg
50
+ ## do NOT default to cwd (because cwd will change!)
51
+
52
+ # Reference src with absolute path, because this can be used with different pwd
53
+ manifestsrc = File.expand_path( manifestsrc, usrdir )
54
+ manifestsrc
55
+ end
56
+
57
+
58
+ end # class ManifestFinder
59
+
60
+ end # class Slideshow
@@ -0,0 +1,96 @@
1
+ # encoding: utf-8
2
+
3
+ module Slideshow
4
+
5
+
6
+ class Merge
7
+
8
+ include LogUtils::Logging
9
+
10
+
11
+ def initialize( config )
12
+ @config = config
13
+
14
+ ## todo: check if we need to use expand_path - Dir.pwd always absolute (check ~/user etc.)
15
+ @usrdir = File.expand_path( Dir.pwd ) # save original (current) working directory
16
+ end
17
+
18
+ attr_reader :config
19
+ attr_reader :usrdir # original working dir (user called slideshow from)
20
+
21
+
22
+ def merge( deck, ctx, headers, content_for )
23
+
24
+ manifestsrc = ctx[:manifestsrc]
25
+ name = ctx[:name]
26
+ outdir = ctx[:outdir]
27
+
28
+ ## note:
29
+ ## assumes name == basename (e.g. name without extension and directory)
30
+ ## rename name to basename - why? why not??
31
+
32
+ ## note: assumes working directory is (default) work directory
33
+ ## e.g. original working dir (user called slideshow from)
34
+
35
+
36
+ puts "Merging slideshow '#{name}'..."
37
+
38
+
39
+ #### pak merge
40
+ # nb: change cwd to template pak root
41
+
42
+ @pakdir = File.dirname( manifestsrc ) # template pak root - make availabe too in erb via binding
43
+ logger.debug " setting pakdir to >#{@pakdir}<"
44
+
45
+ # todo/fix: change current work dir (cwd) in pakman gem itself
46
+ # for now lets do it here
47
+
48
+ logger.debug "changing cwd to pak - new >#{@pakdir}<, old >#{Dir.pwd}<"
49
+ Dir.chdir( @pakdir )
50
+
51
+
52
+ logger.debug( "manifestsrc >#{manifestsrc}<, outdir >#{outdir}<" )
53
+
54
+
55
+ ###########################################
56
+ ## setup hash for binding
57
+ assigns = { 'name' => name,
58
+ 'headers' => HeadersDrop.new( headers ),
59
+ 'content' => deck.content,
60
+ 'slides' => deck.slides.map { |slide| SlideDrop.new(slide) }, # strutured content - use LiquidDrop - why? why not?
61
+ }
62
+
63
+ ## add content_for entries e.g.
64
+ ## content_for :js => more_content_for_js or content_for_js or extra_js etc.
65
+ ## for now allow all three aliases
66
+
67
+ puts "content_for:"
68
+ pp content_for
69
+
70
+ content_for.each do |k,v|
71
+ puts " (auto-)add content_for >#{k.to_s}< to ctx:"
72
+ puts v
73
+ assigns[ "more_content_for_#{k}"] = v
74
+ assigns[ "content_for_#{k}" ] = v
75
+ assigns[ "extra_#{k}" ] = v
76
+ end
77
+
78
+ puts "assigns:"
79
+ pp assigns
80
+
81
+
82
+ Pakman::LiquidTemplater.new.merge_pak( manifestsrc, outdir, assigns, name )
83
+
84
+
85
+ ## pop/restore org (original) working folder/dir
86
+ unless usrdir == @pakdir
87
+ logger.debug "restoring cwd to usr - new >#{usrdir}<, old >#{Dir.pwd}<"
88
+ Dir.chdir( usrdir )
89
+ end
90
+ end # method merge
91
+
92
+
93
+
94
+ end # class Merge
95
+
96
+ end # class Slideshow
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ module Slideshow
4
+
5
+
6
+ ###
7
+ # update/fetch shortcut/registry slideshow.index.yml
8
+ #
9
+
10
+ # todo/why/why not??
11
+ # - *ALWAYS* fetch index before an "online" fetch operation?
12
+ # why cache or use built-in version?
13
+ # use cached/built-in version only as fallback?
14
+
15
+
16
+
17
+ class Update
18
+
19
+
20
+ include LogUtils::Logging
21
+
22
+ def initialize( config )
23
+ @config = config
24
+ end
25
+
26
+ attr_reader :config
27
+
28
+
29
+ def update # update shortcut index
30
+ dest = config.shortcut_index_file
31
+
32
+ destfull = File.expand_path( dest )
33
+ destpath = File.dirname( destfull )
34
+ FileUtils.makedirs( destpath ) unless File.directory?( destpath )
35
+
36
+ logger.debug "destfull=>#{destfull}<"
37
+ logger.debug "destpath=>#{destpath}<"
38
+
39
+ ## todo/fix: use a config setting for index url (do NOT hard core)
40
+ src = 'https://raw.github.com/slideshow-s9/registry/master/slideshow.index.yml'
41
+
42
+ puts "Updating shortcut index - downloading '#{src}'..."
43
+ ::Fetcher::Worker.new.copy( src, destfull )
44
+ end
45
+
46
+ end # class Update
47
+
48
+ end # module Slideshow
49
+
@@ -111,12 +111,6 @@ class Config
111
111
  def load
112
112
 
113
113
  # load builtin config file @ <gem>/config/slideshow.yml
114
- #
115
- # NB: builtin use a different hierachy (not linked to default/home/user/cli props)
116
- # for now builtin has no erb processing
117
- # user cannot override builtin settings (only defaults see below)
118
- props_builtin_file = File.join( Slideshow.root, 'config', 'slideshow.builtin.yml' )
119
- @props_builtin = Props.load_file( props_builtin_file )
120
114
 
121
115
  props_default_file = File.join( Slideshow.root, 'config', 'slideshow.yml' )
122
116
  @props = @props_default = Props.load_file_with_erb( props_default_file, binding() )
@@ -141,9 +135,9 @@ class Config
141
135
  load_shortcuts
142
136
  end
143
137
 
138
+
144
139
  def dump # dump settings for debugging
145
140
  puts "Slideshow settings:"
146
- @props_builtin.dump if @props_builtin
147
141
  @props_default.dump if @props_default
148
142
  @props_home.dump if @props_home
149
143
  @props_work.dump if @props_work
@@ -170,23 +164,6 @@ class Config
170
164
  @props.fetch_from_section( 'analytics', 'google', nil )
171
165
  end
172
166
 
173
- def helper_renames
174
- ## NB: for now user cannot override/extent renames
175
- @props_builtin['helper']['renames']
176
- end
177
-
178
- def helper_unparsed
179
- ## NB: for now user cannot override/extent unparsed helpers
180
- # use unparsed params (passed along a single string)
181
- @props_builtin['helper']['unparsed']
182
- end
183
-
184
- def helper_exprs
185
- ## NB: for now user cannot override/extent helper exprs
186
- # allow expression as directives (no need for %end block)
187
- # by default directives are assumed statements (e.g. %mydir %end)
188
- @props_builtin['helper']['exprs']
189
- end
190
167
 
191
168
  private
192
169
 
@@ -11,6 +11,11 @@ module Slideshow
11
11
  include TextUtils::Filter # include comments_percent_style, skip_end_directive, etc. filters
12
12
 
13
13
 
14
+ DIRECTIVES_UNPARSED = [ 'slide', 'style' ]
15
+ DIRECTIVES_RENAMES = [ 'include', 'class' ]
16
+ DIRECTIVES_EXPRS = [ 'class', 'clear' ]
17
+
18
+
14
19
  def directives_bang_style_to_percent_style( content )
15
20
 
16
21
  # for compatibility allow !SLIDE/!STYLE as an alternative to %slide/%style-directive
@@ -18,18 +23,19 @@ def directives_bang_style_to_percent_style( content )
18
23
  bang_count = 0
19
24
 
20
25
  # get unparsed helpers e.g. SLIDE|STYLE
21
- unparsed = config.helper_unparsed.map { |item| item.upcase }.join( '|' )
26
+ unparsed = DIRECTIVES_UNPARSED.map { |item| item.upcase }.join( '|' )
22
27
 
23
28
  content.gsub!(/^!(#{unparsed})(.*)$/) do |match|
24
29
  bang_count += 1
25
30
  "<%= #{$1.downcase} '#{$2 ? $2 : ''}' %>"
26
31
  end
27
32
 
28
- puts " Patching !-directives (#{bang_count} #{config.helper_unparsed.join('/')}-directives)..."
33
+ puts " Patching !-directives (#{bang_count} #{DIRECTIVES_UNPARSED.join('/')}-directives)..."
29
34
 
30
35
  content
31
36
  end
32
37
 
38
+
33
39
  def directives_percent_style( content )
34
40
 
35
41
  directive_unparsed = 0
@@ -51,11 +57,10 @@ def directives_percent_style( content )
51
57
 
52
58
  logger.debug "processing %-directive: #{directive}"
53
59
 
54
- # slide, style
55
- if config.helper_unparsed.include?( directive )
60
+ if DIRECTIVES_UNPARSED.include?( directive ) # e.g. slide, style, etc.
56
61
  directive_unparsed += 1
57
62
  content2 << "<%= #{directive} '#{params ? params : ''}' %>"
58
- elsif config.helper_exprs.include?( directive )
63
+ elsif DIRECTIVES_EXPRS.include?( directive ) # e.g. class, clear, etc.
59
64
  directive_expr += 1
60
65
  content2 << "<%= #{directive} #{params ? erb_simple_params(directive,params) : ''} %>"
61
66
  elsif inside_helper && directive == 'end'
@@ -83,15 +88,15 @@ def directives_percent_style( content )
83
88
  end
84
89
 
85
90
  puts " Preparing %-directives (" +
86
- "#{directive_unparsed} #{config.helper_unparsed.join('/')} directives, " +
87
- "#{directive_expr} #{config.helper_exprs.join('/')} expr-directives, " +
91
+ "#{directive_unparsed} #{DIRECTIVES_UNPARSED.join('/')} directives, " +
92
+ "#{directive_expr} #{DIRECTIVES_EXPRS.join('/')} expr-directives, " +
88
93
  "#{directive_block_beg}/#{directive_block_end} block-directives)..."
89
94
 
90
95
  content2
91
96
  end
92
97
 
93
98
  ######################
94
- # todo: fix move to textutils gem (including helpers and config)
99
+ # todo: fix move to textutils gem (including helpers and config) - why? why not??
95
100
  #
96
101
 
97
102
 
@@ -102,14 +107,14 @@ end
102
107
 
103
108
  # turn renames into something like:
104
109
  # include|class etc.
105
- renames = config.helper_renames.join( '|' )
110
+ renames = DIRECTIVES_RENAMES.join( '|' )
106
111
 
107
112
  content.gsub!( /<%=[ \t]*(#{renames})/ ) do |match|
108
113
  rename_counter += 1
109
114
  "<%= s9_#{$1}"
110
115
  end
111
116
 
112
- puts " Patching embedded Ruby (erb) code for aliases (#{rename_counter} #{config.helper_renames.join('/')}-aliases)..."
117
+ puts " Patching embedded Ruby (erb) code for aliases (#{rename_counter} #{DIRECTIVES_RENAMES.join('/')}-aliases)..."
113
118
 
114
119
  content
115
120
  end
@@ -46,8 +46,12 @@ require 'slideshow/models/deck'
46
46
  require 'slideshow/markdown'
47
47
  require 'slideshow/drops'
48
48
 
49
+ require 'slideshow/commands/manifest_finder'
49
50
  require 'slideshow/commands/fetch'
51
+ require 'slideshow/commands/update'
50
52
  require 'slideshow/commands/gen'
53
+ require 'slideshow/commands/merge'
54
+ require 'slideshow/commands/build'
51
55
  require 'slideshow/commands/list'
52
56
  require 'slideshow/commands/plugins'
53
57
  require 'slideshow/commands/quick'
@@ -4,7 +4,7 @@ module Slideshow
4
4
 
5
5
  MAJOR = 3
6
6
  MINOR = 0
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -2,15 +2,15 @@
2
2
 
3
3
  ###
4
4
  # to run use
5
- # ruby -I ./lib -I ./test test/test_gen.rb
5
+ # ruby -I ./lib -I ./test test/test_build.rb
6
6
 
7
7
 
8
8
  require 'helper'
9
9
 
10
10
 
11
- class TestGen < MiniTest::Test
11
+ class TestBuild < MiniTest::Test
12
12
 
13
- def test_gen_test
13
+ def test_build_test
14
14
 
15
15
  opts = Slideshow::Opts.new
16
16
 
@@ -23,14 +23,14 @@ def test_gen_test
23
23
  config.load
24
24
  config.dump
25
25
 
26
- g = Slideshow::Gen.new( config )
26
+ g = Slideshow::Build.new( config )
27
27
  g.create_slideshow( "#{Slideshow.root}/test/samples/test.md" )
28
28
 
29
29
  assert true
30
- end # method test_gen
30
+ end # method test_build
31
31
 
32
32
 
33
- def test_gen_test_content_for
33
+ def test_build_test_content_for
34
34
 
35
35
  opts = Slideshow::Opts.new
36
36
 
@@ -43,12 +43,12 @@ def test_gen_test_content_for
43
43
  config.load
44
44
  config.dump
45
45
 
46
- g = Slideshow::Gen.new( config )
46
+ g = Slideshow::Build.new( config )
47
47
  g.create_slideshow( "#{Slideshow.root}/test/samples/test_content_for.md" )
48
48
 
49
49
  assert true
50
- end # method test_gen
50
+ end # method test_build
51
51
 
52
52
 
53
- end # class TestGen
53
+ end # class TestBuild
54
54
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -135,14 +135,17 @@ files:
135
135
  - Manifest.txt
136
136
  - README.md
137
137
  - Rakefile
138
- - config/slideshow.builtin.yml
139
138
  - config/slideshow.index.yml
140
139
  - config/slideshow.yml
140
+ - lib/slideshow/commands/build.rb
141
141
  - lib/slideshow/commands/fetch.rb
142
142
  - lib/slideshow/commands/gen.rb
143
143
  - lib/slideshow/commands/list.rb
144
+ - lib/slideshow/commands/manifest_finder.rb
145
+ - lib/slideshow/commands/merge.rb
144
146
  - lib/slideshow/commands/plugins.rb
145
147
  - lib/slideshow/commands/quick.rb
148
+ - lib/slideshow/commands/update.rb
146
149
  - lib/slideshow/config.rb
147
150
  - lib/slideshow/drops.rb
148
151
  - lib/slideshow/filters/debug_filter.rb
@@ -172,7 +175,7 @@ files:
172
175
  - test/samples/test_content_for.md
173
176
  - test/templates/test/test.html
174
177
  - test/templates/test/test.txt
175
- - test/test_gen.rb
178
+ - test/test_build.rb
176
179
  - test/test_kramdown.rb
177
180
  - test/test_slide.rb
178
181
  - test/test_version.rb
@@ -1,8 +0,0 @@
1
- ####################
2
- ### builtin configuration (not configurable by user now)
3
-
4
-
5
- helper:
6
- unparsed: [ slide, style ]
7
- renames: [ include, class ]
8
- exprs: [ class, clear ]