slideshow 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY.md +4 -0
  3. data/Manifest.txt +3 -48
  4. data/{README.markdown → README.md} +134 -132
  5. data/Rakefile +26 -17
  6. data/lib/slideshow.rb +19 -97
  7. data/lib/slideshow/cli/main.rb +38 -20
  8. data/lib/slideshow/cli/main_utils.rb +10 -4
  9. data/lib/slideshow/cli/opts.rb +3 -1
  10. data/lib/slideshow/cli/version.rb +26 -0
  11. metadata +63 -147
  12. data/History.markdown +0 -171
  13. data/config/slideshow.builtin.yml +0 -8
  14. data/config/slideshow.index.yml +0 -61
  15. data/config/slideshow.yml +0 -76
  16. data/lib/slideshow/cli/commands/fetch.rb +0 -121
  17. data/lib/slideshow/cli/commands/gen.rb +0 -330
  18. data/lib/slideshow/cli/commands/gen_templates.rb +0 -52
  19. data/lib/slideshow/cli/commands/list.rb +0 -70
  20. data/lib/slideshow/cli/commands/plugins.rb +0 -44
  21. data/lib/slideshow/cli/commands/quick.rb +0 -86
  22. data/lib/slideshow/config.rb +0 -241
  23. data/lib/slideshow/filters/debug_filter.rb +0 -74
  24. data/lib/slideshow/filters/headers_filter.rb +0 -45
  25. data/lib/slideshow/filters/slide_filter.rb +0 -113
  26. data/lib/slideshow/filters/text_filter.rb +0 -140
  27. data/lib/slideshow/headers.rb +0 -87
  28. data/lib/slideshow/helpers/background_helper.rb +0 -121
  29. data/lib/slideshow/helpers/capture_helper.rb +0 -136
  30. data/lib/slideshow/helpers/directive_helper.rb +0 -43
  31. data/lib/slideshow/helpers/markdown_helper.rb +0 -18
  32. data/lib/slideshow/helpers/source_helper.rb +0 -39
  33. data/lib/slideshow/helpers/step_helper.rb +0 -33
  34. data/lib/slideshow/helpers/syntax/coderay_helper.rb +0 -84
  35. data/lib/slideshow/helpers/syntax/sh_helper.rb +0 -61
  36. data/lib/slideshow/helpers/syntax/uv_helper.rb +0 -90
  37. data/lib/slideshow/helpers/text_helper.rb +0 -130
  38. data/lib/slideshow/manifest_helpers.rb +0 -94
  39. data/lib/slideshow/markup/markdown.rb +0 -18
  40. data/lib/slideshow/markup/mediawiki.rb +0 -38
  41. data/lib/slideshow/markup/rest.rb +0 -17
  42. data/lib/slideshow/markup/textile.rb +0 -68
  43. data/lib/slideshow/plugin_helpers.rb +0 -62
  44. data/lib/slideshow/slide.rb +0 -118
  45. data/lib/slideshow/version.rb +0 -3
  46. data/templates/s6.txt +0 -27
  47. data/templates/s6.txt.gen +0 -19
  48. data/templates/s6/jquery.js +0 -8176
  49. data/templates/s6/jquery.microsoft.js +0 -31
  50. data/templates/s6/jquery.slideshow.js +0 -534
  51. data/templates/s6/print.css +0 -1
  52. data/templates/s6/projection.css +0 -109
  53. data/templates/s6/screen.css +0 -50
  54. data/templates/slides.html.erb +0 -55
  55. data/templates/slides.pdf.html.erb +0 -62
  56. data/templates/style.css.erb +0 -91
  57. data/templates/welcome.text +0 -167
  58. data/templates/welcome.txt.quick +0 -6
@@ -1,52 +0,0 @@
1
- module Slideshow
2
-
3
- class GenTemplates
4
-
5
-
6
- include LogUtils::Logging
7
-
8
- ### fix: remove opts, use config (wrapped!!)
9
-
10
- def initialize( opts, config )
11
- @opts = opts
12
- @config = config
13
- end
14
-
15
- attr_reader :opts, :config
16
-
17
- def run
18
- manifest_name = opts.manifest
19
- manifest_name = manifest_name.downcase.gsub( '.txt', '' ) # remove (optional) .txt ending
20
- logger.debug "manifest=#{manifest_name}"
21
-
22
- # check for builtin generator manifests
23
- manifests = installed_generator_manifests.select { |m| m[0] == manifest_name+'.txt.gen' }
24
-
25
- if manifests.empty?
26
- puts "*** error: unknown generator template pack '#{manifest_name}'"
27
- # todo: list installed manifests
28
- exit 2
29
- end
30
-
31
- manifestsrc = manifests[0][1]
32
- pakpath = opts.output_path
33
-
34
- logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" )
35
-
36
- Pakman::Copier.new( logger ).copy_pak( manifestsrc, pakpath )
37
- end
38
-
39
- private
40
-
41
- def installed_generator_manifests
42
- # 1) search gem/templates
43
-
44
- patterns = [
45
- "#{Slideshow.root}/templates/*.txt.gen"
46
- ]
47
-
48
- Pakman::Finder.new( logger ).find_manifests( patterns )
49
- end
50
-
51
- end # class GenTemplates
52
- end # module Slideshow
@@ -1,70 +0,0 @@
1
- module Slideshow
2
-
3
- class List
4
-
5
- include LogUtils::Logging
6
-
7
- include ManifestHelper
8
-
9
- ### fix: remove opts, use config (wrapped!!)
10
-
11
- def initialize( opts, config )
12
- @opts = opts
13
- @config = config
14
- end
15
-
16
- attr_reader :opts, :config
17
-
18
- def run
19
- home = Env.home
20
- ## replace home w/ ~ (to make out more readable (shorter))
21
- ## e.g. use gsub( home, '~' )
22
-
23
- puts ''
24
- puts 'Installed plugins in search path'
25
-
26
- installed_plugin_manifest_patterns.each_with_index do |pattern,i|
27
- puts " [#{i+1}] #{pattern.gsub(home,'~')}"
28
- end
29
- puts ' include:'
30
-
31
- installed_plugin_manifests.each do |manifest|
32
- pakname = manifest[0].gsub('.txt','').gsub('.plugin','')
33
- manifestpath = manifest[1].gsub(home,'~')
34
- puts "%16s (%s)" % [pakname,manifestpath]
35
- end
36
-
37
- puts ''
38
- puts 'Installed quickstarter packs in search path'
39
-
40
- installed_quick_manifest_patterns.each_with_index do |pattern,i|
41
- puts " [#{i+1}] #{pattern.gsub(home,'~')}"
42
- end
43
- puts ' include:'
44
-
45
- installed_quick_manifests.each do |manifest|
46
- pakname = manifest[0].gsub('.txt','').gsub('.quick','')
47
- manifestpath = manifest[1].gsub(home,'~')
48
- puts "%16s (%s)" % [pakname,manifestpath]
49
- end
50
-
51
-
52
- puts ''
53
- puts 'Installed template packs in search path'
54
-
55
- installed_template_manifest_patterns.each_with_index do |pattern,i|
56
- puts " [#{i+1}] #{pattern.gsub(home,'~')}"
57
- end
58
- puts ' include:'
59
-
60
- installed_template_manifests.each do |manifest|
61
- pakname = manifest[0].gsub('.txt','')
62
- manifestpath = manifest[1].gsub(home,'~')
63
- puts "%16s (%s)" % [pakname,manifestpath]
64
- end
65
-
66
- end
67
-
68
- end # class List
69
-
70
- end # class Slideshow
@@ -1,44 +0,0 @@
1
- module Slideshow
2
-
3
- class Plugins
4
-
5
- include LogUtils::Logging
6
-
7
- include PluginHelper
8
-
9
- ### fix: remove opts, use config (wrapped!!)
10
-
11
- def initialize( opts, config )
12
- @opts = opts
13
- @config = config
14
- end
15
-
16
- attr_reader :opts, :config
17
-
18
- def run
19
- home = Env.home
20
- ## replace home w/ ~ (to make out more readable (shorter))
21
- ## e.g. use gsub( home, '~' )
22
-
23
- puts ''
24
- puts 'Plugin scripts on the load path'
25
-
26
- find_plugin_patterns.each_with_index do |pattern,i|
27
- puts " [#{i+1}] #{pattern.gsub(home,'~')}"
28
- end
29
- puts ' include:'
30
-
31
- plugins = find_plugins
32
- if plugins.empty?
33
- puts " -- none --"
34
- else
35
- plugins.each do |plugin|
36
- ## NB: use full_path - since Ruby 1.9.2 - ./ no longer included in load path for security
37
- plugin_fullpath = File.expand_path( plugin )
38
- puts " #{plugin.gsub(home,'~')} (#{plugin_fullpath})"
39
- end
40
- end
41
- end
42
-
43
- end # class Plugins
44
- end # module Slideshow
@@ -1,86 +0,0 @@
1
- module Slideshow
2
-
3
- class Quick
4
-
5
- include LogUtils::Logging
6
-
7
- include ManifestHelper
8
-
9
- ### fix: remove opts, use config (wrapped!!)
10
-
11
- def initialize( opts, config )
12
- @opts = opts
13
- @config = config
14
- end
15
-
16
- attr_reader :opts, :config
17
-
18
- def run
19
- manifest_name = opts.quick_manifest.gsub('.txt','').gsub('.quick','') # make sure we get name w/o .quick and .txt extension
20
-
21
- ### todo:fix: always download quickstart templates (except welcome?)
22
- # how to make sure the won't go stale in the cache after the download?
23
-
24
- manifests = installed_quick_manifests
25
- matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') }
26
-
27
- if matches.empty?
28
- fetch_pak( manifest_name )
29
-
30
- # retry
31
- manifests = installed_quick_manifests
32
- matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') }
33
- if matches.empty?
34
- puts "*** error: quickstart template #{manifest_name} not found"
35
- exit 2
36
- end
37
- end
38
-
39
- manifestsrc = matches[0][1]
40
- pakpath = opts.output_path
41
-
42
- logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" )
43
-
44
- Pakman::Copier.new( logger ).copy_pak( manifestsrc, pakpath )
45
- end
46
-
47
- ## todo rename to fetch_quick_pak??
48
- ## share/use same code in fetch too??
49
-
50
- def fetch_pak( shortcut )
51
-
52
- sources = config.map_fetch_shortcut( shortcut )
53
-
54
- if sources.empty?
55
- puts "*** error: no mapping found for shortcut '#{shortcut}'."
56
- exit 2
57
- end
58
-
59
- sources = sources.select { |s| s.include?('.txt.quick') || s.include?('.quick.txt') }
60
-
61
- if sources.empty?
62
- puts "*** error: no quick mapping found for shortcut '#{shortcut}'."
63
- exit 2
64
- end
65
-
66
- src = sources[0]
67
-
68
- puts " Mapping quick shortcut '#{shortcut}' to: #{src}"
69
-
70
-
71
- # src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
72
- # src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
73
- uri = URI.parse( src )
74
- logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
75
-
76
- pakname = File.basename( uri.path ).downcase.gsub('.txt','')
77
- pakpath = File.expand_path( "#{config.config_dir}/templates/#{pakname}" )
78
-
79
- logger.debug "pakname >#{pakname}<"
80
- logger.debug "pakpath >#{pakpath}<"
81
-
82
- Pakman::Fetcher.new( logger ).fetch_pak( src, pakpath )
83
- end # method fetch_pak
84
-
85
- end # class GenTemplates
86
- end # module Slideshow
@@ -1,241 +0,0 @@
1
- module Slideshow
2
-
3
- class Config
4
-
5
- include LogUtils::Logging
6
-
7
- def initialize( opts )
8
- @opts = opts
9
- end
10
-
11
- attr_reader :opts
12
-
13
- def header_level
14
- @opts.header_level
15
- end
16
-
17
- def slide?
18
- @opts.slide?
19
- end
20
-
21
- def takahashi?
22
- @opts.takahashi?
23
- end
24
-
25
-
26
- # todo/fix: fix references after this move to here, that is, Config class
27
- # - used in syntax/uv_helper (use config.cache_dir to access?)
28
-
29
- def cache_dir
30
- File.join( Env.home, '.slideshow' )
31
- end
32
-
33
- def config_dir
34
- unless @config_dir # first time? calculate config_dir value to "cache"
35
- @config_dir = opts.config_path
36
-
37
- # make sure path exists
38
- FileUtils.makedirs( @config_dir ) unless File.directory? @config_dir
39
- end
40
-
41
- @config_dir
42
- end
43
-
44
-
45
- def shortcut_index_file
46
- ## e.g. ~/slideshow.index.yml
47
- File.join( Env.home, 'slideshow.index.yml' )
48
- end
49
-
50
-
51
- def load_shortcuts
52
- # load default index/registry for shortcuts
53
- props_shortcuts_default_file = File.join( Slideshow.root, 'config', 'slideshow.index.yml' )
54
- @props_shortcuts = @props_shortcuts_default = Props.load_file( props_shortcuts_default_file )
55
-
56
- # check for update (slideshow.index.yml) in home folder
57
-
58
- props_shortcuts_home_file = File.join( Env.home, 'slideshow.index.yml' )
59
- if File.exists?( props_shortcuts_home_file )
60
- puts "Loading shortcut index from '#{props_shortcuts_home_file}'..."
61
- @props_shortcuts = @props_shortcuts_home = Props.load_file( props_shortcuts_home_file, @props_shortcuts )
62
- end
63
-
64
- # todo: add props from (optional) fetch section from 'standard' props (e.g. props[:fetch])
65
- # - allows user to add own shortcuts in slideshow.yml settings
66
- end
67
-
68
-
69
- def map_fetch_shortcut( key )
70
- # NB: always returns an array!!! 0,1 or more entries
71
- # - no value - return empty ary
72
-
73
- ## todo: normalize key???
74
- value = @props.fetch_from_section( 'fetch', key, @props_shortcuts.fetch( key, nil ))
75
-
76
- if value.nil?
77
- []
78
- elsif value.kind_of?( String )
79
- [value]
80
- else # assume it's an array already; ## todo: check if it's an array
81
- value
82
- end
83
- end
84
-
85
-
86
- def default_fetch_shortcuts
87
- ## NB: used by install --all
88
-
89
- ['s6blank',
90
- 's6syntax',
91
- 's5blank',
92
- 's5themes',
93
- 'g5',
94
- 'slidy',
95
- 'deck.js',
96
- 'impress.js',
97
- 'analytics'
98
- ]
99
-
100
- ## todo: use @props_shortcuts keys
101
- # and use
102
- #
103
- # fetch_shortcuts = fetch_shortcuts.clone
104
- # fetch_shortcuts.delete( 'fullerscreen' ) # obsolete (do not promote any longer)
105
- # fetch_shortcuts.delete( 'slippy' ) # needs update/maintainer anyone?
106
- # fetch_shortcuts.delete( 'shower' ) # needs update/maintainer anyone?
107
- # etc. to strip keys for all install
108
- end
109
-
110
-
111
- def load
112
-
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
-
121
- props_default_file = File.join( Slideshow.root, 'config', 'slideshow.yml' )
122
- @props = @props_default = Props.load_file_with_erb( props_default_file, binding() )
123
-
124
- # check for user settings (slideshow.yml) in home folder
125
-
126
- props_home_file = File.join( Env.home, 'slideshow.yml' )
127
- if File.exists?( props_home_file )
128
- puts "Loading settings from '#{props_home_file}'..."
129
- @props = @props_home = Props.load_file_with_erb( props_home_file, binding(), @props )
130
- end
131
-
132
- # check for user settings (slideshow.yml) in working folder
133
-
134
- props_work_file = File.join( '.', 'slideshow.yml' )
135
- if File.exists?( props_work_file )
136
- puts "Loading settings from '#{props_work_file}'..."
137
- @props = @props_work = Props.load_file_with_erb( props_work_file, binding(), @props )
138
- end
139
-
140
- # load shortcuts
141
- load_shortcuts
142
- end
143
-
144
- def dump # dump settings for debugging
145
- puts "Slideshow settings:"
146
- @props_builtin.dump if @props_builtin
147
- @props_default.dump if @props_default
148
- @props_home.dump if @props_home
149
- @props_work.dump if @props_work
150
-
151
- puts "Slideshow shortcuts:"
152
- @props_shortcuts_default.dump if @props_shortcuts_default
153
- @props_shortcuts_home.dump if @props_shortcuts_home
154
- ## todo: add props from 'standard' props via fetch key
155
-
156
- ## todo: add more config settings?
157
- end
158
-
159
-
160
- def header( key )
161
- @props.fetch_from_section( 'headers', normalize_key( key ), nil )
162
- end
163
-
164
-
165
- def markdown_post_processing?( lib )
166
- ## todo: normalize key/lib???
167
- @props.fetch_from_section( lib, 'post-processing', true )
168
- end
169
-
170
- def known_rest_extnames
171
- @props.fetch_from_section( 'rest', 'extnames', [] )
172
- end
173
-
174
- def known_textile_extnames
175
- @props.fetch_from_section( 'textile', 'extnames', [] )
176
- end
177
-
178
- def known_mediawiki_extnames
179
- @props.fetch_from_section( 'mediawiki', 'extnames', [] )
180
- end
181
-
182
- def known_markdown_extnames
183
- ## delegate config to Markdown gem for now
184
- ## todo/fix: how to pass on setting to Markdown gem??
185
- Markdown.extnames
186
- end
187
-
188
- def known_extnames
189
- # returns an array of known file extensions e.g.
190
- # [ '.textile', '.t' ]
191
- #
192
- # using nested key
193
- # textile:
194
- # extnames: [ .textile, .t ]
195
- #
196
- # ruby check: is it better self. ?? or more confusing
197
- # possible conflict only with write access (e.g. prop=)
198
-
199
- known_textile_extnames + known_markdown_extnames + known_mediawiki_extnames + known_rest_extnames
200
- end
201
-
202
- def text_filters
203
- @props.fetch( 'filters', [] )
204
- end
205
-
206
- def google_analytics_code
207
- @props.fetch_from_section( 'analytics', 'google', nil )
208
- end
209
-
210
- def helper_renames
211
- ## NB: for now user cannot override/extent renames
212
- @props_builtin['helper']['renames']
213
- end
214
-
215
- def helper_unparsed
216
- ## NB: for now user cannot override/extent unparsed helpers
217
- # use unparsed params (passed along a single string)
218
- @props_builtin['helper']['unparsed']
219
- end
220
-
221
- def helper_exprs
222
- ## NB: for now user cannot override/extent helper exprs
223
- # allow expression as directives (no need for %end block)
224
- # by default directives are assumed statements (e.g. %mydir %end)
225
- @props_builtin['helper']['exprs']
226
- end
227
-
228
- private
229
-
230
- def normalize_key( key )
231
- # make key all lower case/downcase (e.g. Content-Type => content-type)
232
- # replace _ with - (e.g. gradient_color => gradient-color)
233
- # todo: replace space(s) with - ??
234
- # todo: strip leading and trailing spaces - possible use case ??
235
-
236
- key.to_s.downcase.tr( '_', '-' )
237
- end
238
-
239
- end # class Config
240
-
241
- end # module Slideshow