slideshow-models 2.4.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 +7 -0
- data/HISTORY.md +171 -0
- data/Manifest.txt +37 -0
- data/README.md +23 -0
- data/Rakefile +37 -0
- data/config/slideshow.builtin.yml +8 -0
- data/config/slideshow.index.yml +69 -0
- data/config/slideshow.yml +76 -0
- data/lib/slideshow/commands/fetch.rb +123 -0
- data/lib/slideshow/commands/gen.rb +330 -0
- data/lib/slideshow/commands/list.rb +72 -0
- data/lib/slideshow/commands/plugins.rb +46 -0
- data/lib/slideshow/commands/quick.rb +88 -0
- data/lib/slideshow/config.rb +243 -0
- data/lib/slideshow/filters/debug_filter.rb +75 -0
- data/lib/slideshow/filters/headers_filter.rb +46 -0
- data/lib/slideshow/filters/slide_filter.rb +114 -0
- data/lib/slideshow/filters/text_filter.rb +140 -0
- data/lib/slideshow/headers.rb +89 -0
- data/lib/slideshow/helpers/background_helper.rb +151 -0
- data/lib/slideshow/helpers/capture_helper.rb +138 -0
- data/lib/slideshow/helpers/directive_helper.rb +45 -0
- data/lib/slideshow/helpers/markdown_helper.rb +20 -0
- data/lib/slideshow/helpers/source_helper.rb +41 -0
- data/lib/slideshow/helpers/step_helper.rb +35 -0
- data/lib/slideshow/helpers/syntax/coderay_helper.rb +86 -0
- data/lib/slideshow/helpers/syntax/sh_helper.rb +63 -0
- data/lib/slideshow/helpers/syntax/uv_helper.rb +92 -0
- data/lib/slideshow/helpers/text_helper.rb +132 -0
- data/lib/slideshow/manifest_helpers.rb +99 -0
- data/lib/slideshow/markup/markdown.rb +20 -0
- data/lib/slideshow/markup/mediawiki.rb +40 -0
- data/lib/slideshow/markup/rest.rb +19 -0
- data/lib/slideshow/markup/textile.rb +70 -0
- data/lib/slideshow/models.rb +98 -0
- data/lib/slideshow/plugin_helpers.rb +64 -0
- data/lib/slideshow/slide.rb +120 -0
- data/lib/slideshow/version.rb +28 -0
- metadata +197 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
|
5
|
+
class Quick
|
6
|
+
|
7
|
+
include LogUtils::Logging
|
8
|
+
|
9
|
+
include ManifestHelper
|
10
|
+
|
11
|
+
### fix: remove opts, use config (wrapped!!)
|
12
|
+
|
13
|
+
def initialize( opts, config )
|
14
|
+
@opts = opts
|
15
|
+
@config = config
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :opts, :config
|
19
|
+
|
20
|
+
def run
|
21
|
+
manifest_name = opts.quick_manifest.gsub('.txt','').gsub('.quick','') # make sure we get name w/o .quick and .txt extension
|
22
|
+
|
23
|
+
### todo:fix: always download quickstart templates (except welcome?)
|
24
|
+
# how to make sure the won't go stale in the cache after the download?
|
25
|
+
|
26
|
+
manifests = installed_quick_manifests
|
27
|
+
matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') }
|
28
|
+
|
29
|
+
if matches.empty?
|
30
|
+
fetch_pak( manifest_name )
|
31
|
+
|
32
|
+
# retry
|
33
|
+
manifests = installed_quick_manifests
|
34
|
+
matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') }
|
35
|
+
if matches.empty?
|
36
|
+
puts "*** error: quickstart template #{manifest_name} not found"
|
37
|
+
exit 2
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
manifestsrc = matches[0][1]
|
42
|
+
pakpath = opts.output_path
|
43
|
+
|
44
|
+
logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" )
|
45
|
+
|
46
|
+
Pakman::Copier.new.copy_pak( manifestsrc, pakpath )
|
47
|
+
end
|
48
|
+
|
49
|
+
## todo rename to fetch_quick_pak??
|
50
|
+
## share/use same code in fetch too??
|
51
|
+
|
52
|
+
def fetch_pak( shortcut )
|
53
|
+
|
54
|
+
sources = config.map_fetch_shortcut( shortcut )
|
55
|
+
|
56
|
+
if sources.empty?
|
57
|
+
puts "*** error: no mapping found for shortcut '#{shortcut}'."
|
58
|
+
exit 2
|
59
|
+
end
|
60
|
+
|
61
|
+
sources = sources.select { |s| s.include?('.txt.quick') || s.include?('.quick.txt') }
|
62
|
+
|
63
|
+
if sources.empty?
|
64
|
+
puts "*** error: no quick mapping found for shortcut '#{shortcut}'."
|
65
|
+
exit 2
|
66
|
+
end
|
67
|
+
|
68
|
+
src = sources[0]
|
69
|
+
|
70
|
+
puts " Mapping quick shortcut '#{shortcut}' to: #{src}"
|
71
|
+
|
72
|
+
|
73
|
+
# src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
|
74
|
+
# src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
|
75
|
+
uri = URI.parse( src )
|
76
|
+
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
|
77
|
+
|
78
|
+
pakname = File.basename( uri.path ).downcase.gsub('.txt','')
|
79
|
+
pakpath = File.expand_path( "#{config.config_dir}/templates/#{pakname}" )
|
80
|
+
|
81
|
+
logger.debug "pakname >#{pakname}<"
|
82
|
+
logger.debug "pakpath >#{pakpath}<"
|
83
|
+
|
84
|
+
Pakman::Fetcher.new.fetch_pak( src, pakpath )
|
85
|
+
end # method fetch_pak
|
86
|
+
|
87
|
+
end # class GenTemplates
|
88
|
+
end # module Slideshow
|
@@ -0,0 +1,243 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
|
5
|
+
class Config
|
6
|
+
|
7
|
+
include LogUtils::Logging
|
8
|
+
|
9
|
+
def initialize( opts )
|
10
|
+
@opts = opts
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :opts
|
14
|
+
|
15
|
+
def header_level
|
16
|
+
@opts.header_level
|
17
|
+
end
|
18
|
+
|
19
|
+
def slide?
|
20
|
+
@opts.slide?
|
21
|
+
end
|
22
|
+
|
23
|
+
def takahashi?
|
24
|
+
@opts.takahashi?
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# todo/fix: fix references after this move to here, that is, Config class
|
29
|
+
# - used in syntax/uv_helper (use config.cache_dir to access?)
|
30
|
+
|
31
|
+
def cache_dir
|
32
|
+
File.join( Env.home, '.slideshow' )
|
33
|
+
end
|
34
|
+
|
35
|
+
def config_dir
|
36
|
+
unless @config_dir # first time? calculate config_dir value to "cache"
|
37
|
+
@config_dir = opts.config_path
|
38
|
+
|
39
|
+
# make sure path exists
|
40
|
+
FileUtils.makedirs( @config_dir ) unless File.directory? @config_dir
|
41
|
+
end
|
42
|
+
|
43
|
+
@config_dir
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def shortcut_index_file
|
48
|
+
## e.g. ~/slideshow.index.yml
|
49
|
+
File.join( Env.home, 'slideshow.index.yml' )
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def load_shortcuts
|
54
|
+
# load default index/registry for shortcuts
|
55
|
+
props_shortcuts_default_file = File.join( Slideshow.root, 'config', 'slideshow.index.yml' )
|
56
|
+
@props_shortcuts = @props_shortcuts_default = Props.load_file( props_shortcuts_default_file )
|
57
|
+
|
58
|
+
# check for update (slideshow.index.yml) in home folder
|
59
|
+
|
60
|
+
props_shortcuts_home_file = File.join( Env.home, 'slideshow.index.yml' )
|
61
|
+
if File.exists?( props_shortcuts_home_file )
|
62
|
+
puts "Loading shortcut index from '#{props_shortcuts_home_file}'..."
|
63
|
+
@props_shortcuts = @props_shortcuts_home = Props.load_file( props_shortcuts_home_file, @props_shortcuts )
|
64
|
+
end
|
65
|
+
|
66
|
+
# todo: add props from (optional) fetch section from 'standard' props (e.g. props[:fetch])
|
67
|
+
# - allows user to add own shortcuts in slideshow.yml settings
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def map_fetch_shortcut( key )
|
72
|
+
# NB: always returns an array!!! 0,1 or more entries
|
73
|
+
# - no value - return empty ary
|
74
|
+
|
75
|
+
## todo: normalize key???
|
76
|
+
value = @props.fetch_from_section( 'fetch', key, @props_shortcuts.fetch( key, nil ))
|
77
|
+
|
78
|
+
if value.nil?
|
79
|
+
[]
|
80
|
+
elsif value.kind_of?( String )
|
81
|
+
[value]
|
82
|
+
else # assume it's an array already; ## todo: check if it's an array
|
83
|
+
value
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def default_fetch_shortcuts
|
89
|
+
## NB: used by install --all
|
90
|
+
|
91
|
+
['s6blank',
|
92
|
+
's6syntax',
|
93
|
+
's5blank',
|
94
|
+
's5themes',
|
95
|
+
'g5',
|
96
|
+
'slidy',
|
97
|
+
'deck.js',
|
98
|
+
'impress.js',
|
99
|
+
'analytics'
|
100
|
+
]
|
101
|
+
|
102
|
+
## todo: use @props_shortcuts keys
|
103
|
+
# and use
|
104
|
+
#
|
105
|
+
# fetch_shortcuts = fetch_shortcuts.clone
|
106
|
+
# fetch_shortcuts.delete( 'fullerscreen' ) # obsolete (do not promote any longer)
|
107
|
+
# fetch_shortcuts.delete( 'slippy' ) # needs update/maintainer anyone?
|
108
|
+
# fetch_shortcuts.delete( 'shower' ) # needs update/maintainer anyone?
|
109
|
+
# etc. to strip keys for all install
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def load
|
114
|
+
|
115
|
+
# load builtin config file @ <gem>/config/slideshow.yml
|
116
|
+
#
|
117
|
+
# NB: builtin use a different hierachy (not linked to default/home/user/cli props)
|
118
|
+
# for now builtin has no erb processing
|
119
|
+
# user cannot override builtin settings (only defaults see below)
|
120
|
+
props_builtin_file = File.join( Slideshow.root, 'config', 'slideshow.builtin.yml' )
|
121
|
+
@props_builtin = Props.load_file( props_builtin_file )
|
122
|
+
|
123
|
+
props_default_file = File.join( Slideshow.root, 'config', 'slideshow.yml' )
|
124
|
+
@props = @props_default = Props.load_file_with_erb( props_default_file, binding() )
|
125
|
+
|
126
|
+
# check for user settings (slideshow.yml) in home folder
|
127
|
+
|
128
|
+
props_home_file = File.join( Env.home, 'slideshow.yml' )
|
129
|
+
if File.exists?( props_home_file )
|
130
|
+
puts "Loading settings from '#{props_home_file}'..."
|
131
|
+
@props = @props_home = Props.load_file_with_erb( props_home_file, binding(), @props )
|
132
|
+
end
|
133
|
+
|
134
|
+
# check for user settings (slideshow.yml) in working folder
|
135
|
+
|
136
|
+
props_work_file = File.join( '.', 'slideshow.yml' )
|
137
|
+
if File.exists?( props_work_file )
|
138
|
+
puts "Loading settings from '#{props_work_file}'..."
|
139
|
+
@props = @props_work = Props.load_file_with_erb( props_work_file, binding(), @props )
|
140
|
+
end
|
141
|
+
|
142
|
+
# load shortcuts
|
143
|
+
load_shortcuts
|
144
|
+
end
|
145
|
+
|
146
|
+
def dump # dump settings for debugging
|
147
|
+
puts "Slideshow settings:"
|
148
|
+
@props_builtin.dump if @props_builtin
|
149
|
+
@props_default.dump if @props_default
|
150
|
+
@props_home.dump if @props_home
|
151
|
+
@props_work.dump if @props_work
|
152
|
+
|
153
|
+
puts "Slideshow shortcuts:"
|
154
|
+
@props_shortcuts_default.dump if @props_shortcuts_default
|
155
|
+
@props_shortcuts_home.dump if @props_shortcuts_home
|
156
|
+
## todo: add props from 'standard' props via fetch key
|
157
|
+
|
158
|
+
## todo: add more config settings?
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
def header( key )
|
163
|
+
@props.fetch_from_section( 'headers', normalize_key( key ), nil )
|
164
|
+
end
|
165
|
+
|
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
|
+
|
204
|
+
def text_filters
|
205
|
+
@props.fetch( 'filters', [] )
|
206
|
+
end
|
207
|
+
|
208
|
+
def google_analytics_code
|
209
|
+
@props.fetch_from_section( 'analytics', 'google', nil )
|
210
|
+
end
|
211
|
+
|
212
|
+
def helper_renames
|
213
|
+
## NB: for now user cannot override/extent renames
|
214
|
+
@props_builtin['helper']['renames']
|
215
|
+
end
|
216
|
+
|
217
|
+
def helper_unparsed
|
218
|
+
## NB: for now user cannot override/extent unparsed helpers
|
219
|
+
# use unparsed params (passed along a single string)
|
220
|
+
@props_builtin['helper']['unparsed']
|
221
|
+
end
|
222
|
+
|
223
|
+
def helper_exprs
|
224
|
+
## NB: for now user cannot override/extent helper exprs
|
225
|
+
# allow expression as directives (no need for %end block)
|
226
|
+
# by default directives are assumed statements (e.g. %mydir %end)
|
227
|
+
@props_builtin['helper']['exprs']
|
228
|
+
end
|
229
|
+
|
230
|
+
private
|
231
|
+
|
232
|
+
def normalize_key( key )
|
233
|
+
# make key all lower case/downcase (e.g. Content-Type => content-type)
|
234
|
+
# replace _ with - (e.g. gradient_color => gradient-color)
|
235
|
+
# todo: replace space(s) with - ??
|
236
|
+
# todo: strip leading and trailing spaces - possible use case ??
|
237
|
+
|
238
|
+
key.to_s.downcase.tr( '_', '-' )
|
239
|
+
end
|
240
|
+
|
241
|
+
end # class Config
|
242
|
+
|
243
|
+
end # module Slideshow
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
module DebugFilter
|
5
|
+
|
6
|
+
# use it to dump content before erb merge
|
7
|
+
|
8
|
+
def dump_content_to_file_debug_text_erb( content )
|
9
|
+
|
10
|
+
# NB: using attribs from mixed in class
|
11
|
+
# - opts
|
12
|
+
# - outdir
|
13
|
+
|
14
|
+
return content unless opts.verbose?
|
15
|
+
|
16
|
+
outname = "#{outdir}/#{@name}.debug.text.erb"
|
17
|
+
|
18
|
+
puts " Dumping content before erb merge to #{outname}..."
|
19
|
+
|
20
|
+
File.open( outname, 'w' ) do |f|
|
21
|
+
f.write( content )
|
22
|
+
end
|
23
|
+
|
24
|
+
content
|
25
|
+
end
|
26
|
+
|
27
|
+
# use it to dump content before html post processing
|
28
|
+
|
29
|
+
def dump_content_to_file_debug_html( content )
|
30
|
+
|
31
|
+
# NB: using attribs from mixed in class
|
32
|
+
# - opts
|
33
|
+
# - outdir
|
34
|
+
|
35
|
+
return content unless opts.verbose?
|
36
|
+
|
37
|
+
outname = "#{outdir}/#{@name}.debug.html"
|
38
|
+
|
39
|
+
puts " Dumping content before html post processing to #{outname}..."
|
40
|
+
|
41
|
+
File.open( outname, 'w' ) do |f|
|
42
|
+
f.write( content )
|
43
|
+
end
|
44
|
+
|
45
|
+
content
|
46
|
+
end
|
47
|
+
|
48
|
+
# use it to dump content before text-to-html conversion
|
49
|
+
|
50
|
+
def dump_content_to_file_debug_text( content )
|
51
|
+
|
52
|
+
# NB: using attribs from mixed in class
|
53
|
+
# - opts
|
54
|
+
# - outdir
|
55
|
+
|
56
|
+
return content unless opts.verbose?
|
57
|
+
|
58
|
+
outname = "#{outdir}/#{@name}.debug.text"
|
59
|
+
|
60
|
+
puts " Dumping content before text-to-html conversion to #{outname}..."
|
61
|
+
|
62
|
+
File.open( outname, 'w' ) do |f|
|
63
|
+
f.write( content )
|
64
|
+
end
|
65
|
+
|
66
|
+
content
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end # module DebugFilter
|
71
|
+
end # module Slideshow
|
72
|
+
|
73
|
+
class Slideshow::Gen
|
74
|
+
include Slideshow::DebugFilter
|
75
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Slideshow
|
4
|
+
module HeadersFilter
|
5
|
+
|
6
|
+
def leading_headers( content_with_headers )
|
7
|
+
|
8
|
+
# todo: lets user override headers with command line options
|
9
|
+
# that is, lets you override options using commandline switch
|
10
|
+
|
11
|
+
# read source document; split off optional header from source
|
12
|
+
# strip leading optional headers (key/value pairs) including optional empty lines
|
13
|
+
|
14
|
+
read_headers = true
|
15
|
+
content = ""
|
16
|
+
|
17
|
+
keys = [] # track header keys for stats
|
18
|
+
|
19
|
+
content_with_headers.each_line do |line|
|
20
|
+
if read_headers && line =~ /^\s*(\w[\w-]*)[ \t]*:[ \t]*(.*)/
|
21
|
+
key = $1.downcase
|
22
|
+
value = $2.strip
|
23
|
+
|
24
|
+
keys << key
|
25
|
+
|
26
|
+
logger.debug " adding header: key=>#{key}< value=>#{value}<"
|
27
|
+
headers.put( key, value )
|
28
|
+
elsif line =~ /^\s*$/
|
29
|
+
content << line unless read_headers
|
30
|
+
else
|
31
|
+
read_headers = false
|
32
|
+
content << line
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
puts " Reading #{keys.length} headers: #{keys.join(', ')}..."
|
37
|
+
|
38
|
+
content
|
39
|
+
end
|
40
|
+
|
41
|
+
end # module HeadersFilter
|
42
|
+
end # module Slideshow
|
43
|
+
|
44
|
+
class Slideshow::Gen
|
45
|
+
include Slideshow::HeadersFilter
|
46
|
+
end
|