slideshow 1.1.0 → 1.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +7 -7
- data/Rakefile +3 -5
- data/lib/slideshow.rb +8 -7
- data/lib/slideshow/cli/commands/fetch.rb +53 -0
- data/lib/slideshow/{commands → cli/commands}/gen.rb +9 -3
- data/lib/slideshow/cli/commands/gen_templates.rb +53 -0
- data/lib/slideshow/{commands → cli/commands}/list.rb +8 -5
- data/lib/slideshow/{opts.rb → cli/opts.rb} +2 -2
- data/lib/slideshow/{runner.rb → cli/runner.rb} +37 -38
- data/lib/slideshow/config.rb +1 -6
- data/lib/slideshow/manifest_helpers.rb +38 -0
- data/lib/slideshow/version.rb +1 -1
- metadata +28 -24
- data/lib/slideshow/commands/fetch.rb +0 -101
- data/lib/slideshow/commands/gen_templates.rb +0 -66
- data/lib/slideshow/manifest.rb +0 -101
data/Manifest.txt
CHANGED
@@ -6,10 +6,12 @@ bin/slideshow
|
|
6
6
|
config/slideshow.builtin.yml
|
7
7
|
config/slideshow.yml
|
8
8
|
lib/slideshow.rb
|
9
|
-
lib/slideshow/commands/fetch.rb
|
10
|
-
lib/slideshow/commands/gen.rb
|
11
|
-
lib/slideshow/commands/gen_templates.rb
|
12
|
-
lib/slideshow/commands/list.rb
|
9
|
+
lib/slideshow/cli/commands/fetch.rb
|
10
|
+
lib/slideshow/cli/commands/gen.rb
|
11
|
+
lib/slideshow/cli/commands/gen_templates.rb
|
12
|
+
lib/slideshow/cli/commands/list.rb
|
13
|
+
lib/slideshow/cli/opts.rb
|
14
|
+
lib/slideshow/cli/runner.rb
|
13
15
|
lib/slideshow/config.rb
|
14
16
|
lib/slideshow/filters/debug_filter.rb
|
15
17
|
lib/slideshow/filters/headers_filter.rb
|
@@ -28,12 +30,10 @@ lib/slideshow/helpers/syntax/sh_helper.rb
|
|
28
30
|
lib/slideshow/helpers/syntax/uv_helper.rb
|
29
31
|
lib/slideshow/helpers/table_helper.rb
|
30
32
|
lib/slideshow/helpers/text_helper.rb
|
31
|
-
lib/slideshow/
|
33
|
+
lib/slideshow/manifest_helpers.rb
|
32
34
|
lib/slideshow/markup/markdown.rb
|
33
35
|
lib/slideshow/markup/rest.rb
|
34
36
|
lib/slideshow/markup/textile.rb
|
35
|
-
lib/slideshow/opts.rb
|
36
|
-
lib/slideshow/runner.rb
|
37
37
|
lib/slideshow/slide.rb
|
38
38
|
lib/slideshow/version.rb
|
39
39
|
templates/s6.txt
|
data/Rakefile
CHANGED
@@ -16,12 +16,10 @@ Hoe.spec 'slideshow' do
|
|
16
16
|
['RedCloth','>= 4.2.9'],
|
17
17
|
['markdown','>= 0.4.0'],
|
18
18
|
['textutils','>= 0.2.0'],
|
19
|
-
['
|
20
|
-
['
|
19
|
+
['props','>= 0.2.0'],
|
20
|
+
['pakman','>= 0.1.0']
|
21
21
|
]
|
22
|
-
|
23
|
-
self.remote_rdoc_dir = 'doc'
|
24
|
-
|
22
|
+
|
25
23
|
# switch extension to .rdoc for gihub formatting
|
26
24
|
self.readme_file = 'README.rdoc'
|
27
25
|
self.history_file = 'History.rdoc'
|
data/lib/slideshow.rb
CHANGED
@@ -35,21 +35,22 @@ class Env
|
|
35
35
|
end # class Env
|
36
36
|
|
37
37
|
require 'textutils' # text filters and helpers
|
38
|
+
require 'pakman' # template pack manager
|
38
39
|
|
39
40
|
|
40
41
|
# our own code
|
41
42
|
require 'slideshow/version'
|
42
|
-
require 'slideshow/opts'
|
43
43
|
require 'slideshow/headers'
|
44
44
|
require 'slideshow/config'
|
45
|
-
require 'slideshow/
|
45
|
+
require 'slideshow/manifest_helpers'
|
46
46
|
require 'slideshow/slide'
|
47
|
-
require 'slideshow/runner'
|
48
47
|
|
49
|
-
require 'slideshow/
|
50
|
-
require 'slideshow/
|
51
|
-
require 'slideshow/commands/
|
52
|
-
require 'slideshow/commands/
|
48
|
+
require 'slideshow/cli/opts'
|
49
|
+
require 'slideshow/cli/runner'
|
50
|
+
require 'slideshow/cli/commands/fetch'
|
51
|
+
require 'slideshow/cli/commands/gen'
|
52
|
+
require 'slideshow/cli/commands/gen_templates'
|
53
|
+
require 'slideshow/cli/commands/list'
|
53
54
|
|
54
55
|
require 'slideshow/markup/textile'
|
55
56
|
require 'slideshow/markup/markdown'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Slideshow
|
2
|
+
|
3
|
+
class Fetch
|
4
|
+
|
5
|
+
### fix: remove opts, use config (wrapped!!)
|
6
|
+
|
7
|
+
def initialize( logger, opts, config )
|
8
|
+
@logger = logger
|
9
|
+
@opts = opts
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :logger, :opts, :config
|
14
|
+
|
15
|
+
|
16
|
+
def run
|
17
|
+
logger.debug "fetch_uri=#{opts.fetch_uri}"
|
18
|
+
|
19
|
+
src = opts.fetch_uri
|
20
|
+
|
21
|
+
## check for builtin shortcut (assume no / or \)
|
22
|
+
if src.index( '/' ).nil? && src.index( '\\' ).nil?
|
23
|
+
shortcut = src.clone
|
24
|
+
src = config.map_fetch_shortcut( src )
|
25
|
+
|
26
|
+
if src.nil?
|
27
|
+
puts "** Error: No mapping found for fetch shortcut '#{shortcut}'."
|
28
|
+
return
|
29
|
+
end
|
30
|
+
puts " Mapping fetch shortcut '#{shortcut}' to: #{src}"
|
31
|
+
end
|
32
|
+
|
33
|
+
# src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
|
34
|
+
# src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
|
35
|
+
uri = URI.parse( src )
|
36
|
+
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
|
37
|
+
|
38
|
+
basename = File.basename( uri.path, '.*' ) # e.g. fullerscreen (without extension)
|
39
|
+
logger.debug "basename: #{basename}"
|
40
|
+
|
41
|
+
pakpath = File.expand_path( "#{config.config_dir}/templates/#{basename}" )
|
42
|
+
logger.debug "pakpath: #{pakpath}"
|
43
|
+
|
44
|
+
## note: code moved to its own gem, that is, pakman
|
45
|
+
## see https://github.com/geraldb/pakman
|
46
|
+
|
47
|
+
Pakman::Fetcher.new( logger ).fetch_pak( src, pakpath )
|
48
|
+
end # method run
|
49
|
+
|
50
|
+
|
51
|
+
end # class Fetch
|
52
|
+
|
53
|
+
end # module Slideshow
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module Slideshow
|
2
2
|
|
3
|
+
## fix:/todo: move generation code out of command into its own class
|
4
|
+
## not residing/depending on cli
|
5
|
+
|
3
6
|
class Gen
|
4
7
|
|
5
|
-
include
|
8
|
+
include ManifestHelper
|
6
9
|
|
7
10
|
### fix: remove opts, use config (wrapped!!)
|
8
11
|
|
@@ -163,7 +166,7 @@ class Gen
|
|
163
166
|
|
164
167
|
# check if file exists (if yes use custom template package!) - allows you to override builtin package with same name
|
165
168
|
if File.exists?( manifest_path_or_name )
|
166
|
-
manifest =
|
169
|
+
manifest = Pakman::Manifest.load_file( logger, manifest_path_or_name )
|
167
170
|
else
|
168
171
|
# check for builtin manifests
|
169
172
|
manifests = installed_template_manifests
|
@@ -175,7 +178,7 @@ class Gen
|
|
175
178
|
exit 2
|
176
179
|
end
|
177
180
|
|
178
|
-
manifest =
|
181
|
+
manifest = Pakman::Manifest.load_file( logger, matches[0][1] )
|
179
182
|
end
|
180
183
|
|
181
184
|
|
@@ -250,6 +253,9 @@ class Gen
|
|
250
253
|
end
|
251
254
|
|
252
255
|
|
256
|
+
###
|
257
|
+
## fix: move code into Pakman::Gen/Generator or Templater
|
258
|
+
|
253
259
|
#### fix/todo:
|
254
260
|
##
|
255
261
|
## check for .erb file extension for trigger for erb processing
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Slideshow
|
2
|
+
|
3
|
+
class GenTemplates
|
4
|
+
|
5
|
+
|
6
|
+
### fix: remove opts, use config (wrapped!!)
|
7
|
+
|
8
|
+
def initialize( logger, opts, config )
|
9
|
+
@logger = logger
|
10
|
+
@opts = opts
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :logger, :opts, :config
|
15
|
+
|
16
|
+
def run
|
17
|
+
manifest_name = opts.manifest
|
18
|
+
logger.debug "manifest=#{manifest_name}"
|
19
|
+
|
20
|
+
manifests = installed_generator_manifests
|
21
|
+
|
22
|
+
# check for builtin generator manifests
|
23
|
+
matches = manifests.select { |m| m[0] == manifest_name+".gen" }
|
24
|
+
|
25
|
+
if matches.empty?
|
26
|
+
puts "*** error: unknown template manifest '#{manifest_name}'"
|
27
|
+
# todo: list installed manifests
|
28
|
+
exit 2
|
29
|
+
end
|
30
|
+
|
31
|
+
manifestsrc = matches[0][1]
|
32
|
+
pakpath = opts.output_path
|
33
|
+
|
34
|
+
Pakman::Copier.new( logger ).copy_pak( manifestsrc, pakpath )
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def installed_generator_manifests
|
40
|
+
# 1) search gem/templates
|
41
|
+
|
42
|
+
builtin_patterns = [
|
43
|
+
"#{Slideshow.root}/templates/*.txt.gen"
|
44
|
+
]
|
45
|
+
|
46
|
+
## note: code moved to its own gem, that is, pakman
|
47
|
+
## see https://github.com/geraldb/pakman
|
48
|
+
|
49
|
+
Pakman::Finder.new( logger ).find_manifests( builtin_patterns )
|
50
|
+
end
|
51
|
+
|
52
|
+
end # class GenTemplates
|
53
|
+
end # module Slideshow
|
@@ -2,7 +2,7 @@ module Slideshow
|
|
2
2
|
|
3
3
|
class List
|
4
4
|
|
5
|
-
include
|
5
|
+
include ManifestHelper
|
6
6
|
|
7
7
|
### fix: remove opts, use config (wrapped!!)
|
8
8
|
|
@@ -14,19 +14,22 @@ class List
|
|
14
14
|
|
15
15
|
attr_reader :logger, :opts, :config
|
16
16
|
|
17
|
-
|
18
17
|
def run
|
19
18
|
manifests = installed_template_manifests
|
20
19
|
|
21
20
|
puts ''
|
22
|
-
puts 'Installed
|
21
|
+
puts 'Installed template packs in search path'
|
22
|
+
|
23
|
+
installed_template_manifest_patterns.each_with_index do |pattern,i|
|
24
|
+
puts " [#{i+1}] #{pattern}"
|
25
|
+
end
|
26
|
+
puts ' include:'
|
23
27
|
|
24
28
|
manifests.each do |manifest|
|
25
|
-
puts "
|
29
|
+
puts "%16s (%s)" % [manifest[0], manifest[1]]
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
|
-
|
30
33
|
end # class List
|
31
34
|
|
32
35
|
end # class Slideshow
|
@@ -14,25 +14,23 @@ class Runner
|
|
14
14
|
attr_reader :logger, :opts, :config, :headers
|
15
15
|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
patterns << "#{config.config_dir}/lib/**/*.rb"
|
22
|
-
patterns << 'lib/**/*.rb' unless Slideshow.root == File.expand_path( '.' ) # don't include lib if we are in repo (don't include slideshow/lib)
|
17
|
+
def load_plugins
|
18
|
+
patterns = []
|
19
|
+
patterns << "#{config.config_dir}/lib/**/*.rb"
|
20
|
+
patterns << 'lib/**/*.rb' unless Slideshow.root == File.expand_path( '.' ) # don't include lib if we are in repo (don't include slideshow/lib)
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
patterns.each do |pattern|
|
23
|
+
pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
|
24
|
+
Dir.glob( pattern ) do |plugin|
|
25
|
+
begin
|
26
|
+
puts "Loading plugins in '#{plugin}'..."
|
27
|
+
require( plugin )
|
28
|
+
rescue Exception => e
|
29
|
+
puts "** error: failed loading plugins in '#{plugin}': #{e}"
|
30
|
+
end
|
32
31
|
end
|
33
32
|
end
|
34
|
-
end
|
35
|
-
end
|
33
|
+
end # method load_plugins
|
36
34
|
|
37
35
|
|
38
36
|
def find_file_with_known_extension( fn )
|
@@ -52,7 +50,6 @@ end
|
|
52
50
|
|
53
51
|
|
54
52
|
def find_files( file_or_dir_or_pattern )
|
55
|
-
|
56
53
|
filtered_files = []
|
57
54
|
|
58
55
|
## for now process/assume only single file
|
@@ -72,21 +69,22 @@ end
|
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
75
|
-
filtered_files
|
76
|
-
|
72
|
+
filtered_files
|
77
73
|
end # method find_files
|
78
74
|
|
79
75
|
|
80
76
|
|
81
77
|
def run( args )
|
82
78
|
|
79
|
+
config.load
|
80
|
+
|
83
81
|
opt=OptionParser.new do |cmd|
|
84
82
|
|
85
83
|
cmd.banner = "Usage: slideshow [options] name"
|
86
84
|
|
87
|
-
cmd.on( '-o', '--output PATH',
|
85
|
+
cmd.on( '-o', '--output PATH', "Output Path (default is #{opts.output_path})" ) { |path| opts.output_path = path }
|
88
86
|
|
89
|
-
cmd.on( "-t", "--template MANIFEST", "Template Manifest (default is
|
87
|
+
cmd.on( "-t", "--template MANIFEST", "Template Manifest (default is #{opts.manifest})" ) do |t|
|
90
88
|
# todo: do some checks on passed in template argument
|
91
89
|
opts.manifest = t
|
92
90
|
end
|
@@ -104,30 +102,32 @@ def run( args )
|
|
104
102
|
|
105
103
|
# ?? cmd.on( '-i', '--include PATH', 'Load Path' ) { |s| opts.put( 'include', s ) }
|
106
104
|
|
107
|
-
cmd.on( '-c', '--config PATH', 'Configuration Path (default is ~/.slideshow)' ) do |path|
|
108
|
-
opts.config_path = path
|
109
|
-
end
|
110
|
-
|
111
105
|
cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |uri|
|
112
106
|
opts.fetch_uri = uri
|
113
107
|
end
|
114
108
|
|
115
|
-
cmd.on( '-g', '--generate', 'Generate Slide Show Templates (Using Built-In S6 Pack)' ) { opts.generate = true }
|
116
|
-
|
117
109
|
cmd.on( '-l', '--list', 'List Installed Templates' ) { opts.list = true }
|
118
110
|
|
119
|
-
|
120
|
-
|
121
|
-
logger.datetime_format = "%H:%H:%S"
|
122
|
-
logger.level = Logger::DEBUG
|
111
|
+
cmd.on( '-c', '--config PATH', "Configuration Path (default is #{opts.config_path})" ) do |path|
|
112
|
+
opts.config_path = path
|
123
113
|
end
|
114
|
+
|
115
|
+
cmd.on( '-g', '--generate', 'Generate Slide Show Templates (using built-in S6 Pack)' ) { opts.generate = true }
|
116
|
+
|
117
|
+
## fix:/todo: add generator for quickstart
|
118
|
+
cmd.on( '-q', '--quick', 'Generate Quickstart Slide Show Sample') { }
|
124
119
|
|
125
|
-
## todo: add --version
|
126
120
|
|
127
|
-
cmd.on( '--version', "Show version" ) do
|
121
|
+
cmd.on( '-v', '--version', "Show version" ) do
|
128
122
|
puts Slideshow.generator
|
129
123
|
exit
|
130
124
|
end
|
125
|
+
|
126
|
+
cmd.on( "--verbose", "Show debug trace" ) do
|
127
|
+
logger.datetime_format = "%H:%H:%S"
|
128
|
+
logger.level = Logger::DEBUG
|
129
|
+
end
|
130
|
+
|
131
131
|
|
132
132
|
cmd.on_tail( "-h", "--help", "Show this message" ) do
|
133
133
|
puts <<EOS
|
@@ -138,12 +138,13 @@ Slide Show (S9) is a free web alternative to PowerPoint or KeyNote in Ruby
|
|
138
138
|
|
139
139
|
Examples:
|
140
140
|
slideshow microformats
|
141
|
-
slideshow microformats.
|
142
|
-
slideshow microformats.
|
143
|
-
slideshow microformats.rst # Process slides using reStructuredText
|
141
|
+
slideshow microformats.text # Process slides using Markdown (#{config.known_markdown_extnames.join(', ')})
|
142
|
+
slideshow microformats.textile # Process slides using Textile (#{config.known_textile_extnames.join(', ')})
|
143
|
+
slideshow microformats.rst # Process slides using reStructuredText (#{config.known_rest_extnames.join(', ')})
|
144
144
|
slideshow -o slides microformats # Output slideshow to slides folder
|
145
145
|
|
146
146
|
More examles:
|
147
|
+
slideshow -q # Generate quickstart slide show sample
|
147
148
|
slideshow -g # Generate slide show templates using built-in S6 pack
|
148
149
|
|
149
150
|
slideshow -l # List installed slide show templates
|
@@ -160,8 +161,6 @@ EOS
|
|
160
161
|
|
161
162
|
opt.parse!( args )
|
162
163
|
|
163
|
-
config.load
|
164
|
-
|
165
164
|
puts Slideshow.generator
|
166
165
|
|
167
166
|
if opts.list?
|
data/lib/slideshow/config.rb
CHANGED
@@ -22,12 +22,7 @@ class Config
|
|
22
22
|
|
23
23
|
def config_dir
|
24
24
|
unless @config_dir # first time? calculate config_dir value to "cache"
|
25
|
-
|
26
|
-
if opts.config_path
|
27
|
-
@config_dir = opts.config_path
|
28
|
-
else
|
29
|
-
@config_dir = cache_dir
|
30
|
-
end
|
25
|
+
@config_dir = opts.config_path
|
31
26
|
|
32
27
|
# make sure path exists
|
33
28
|
FileUtils.makedirs( @config_dir ) unless File.directory? @config_dir
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Slideshow
|
2
|
+
|
3
|
+
module ManifestHelper
|
4
|
+
|
5
|
+
## shared methods for handling manifest lookups
|
6
|
+
|
7
|
+
def installed_template_manifest_patterns
|
8
|
+
# 1) search ./templates
|
9
|
+
# 2) search config_dir/templates
|
10
|
+
# 3) search gem/templates
|
11
|
+
|
12
|
+
builtin_patterns = [
|
13
|
+
"#{Slideshow.root}/templates/*.txt"
|
14
|
+
]
|
15
|
+
config_patterns = [
|
16
|
+
"#{config.config_dir}/templates/*.txt",
|
17
|
+
"#{config.config_dir}/templates/*/*.txt"
|
18
|
+
]
|
19
|
+
current_patterns = [
|
20
|
+
"templates/*.txt",
|
21
|
+
"templates/*/*.txt"
|
22
|
+
]
|
23
|
+
|
24
|
+
patterns = []
|
25
|
+
patterns += current_patterns unless Slideshow.root == File.expand_path( '.' ) # don't include working dir if we test code from repo (don't include slideshow/templates)
|
26
|
+
patterns += config_patterns
|
27
|
+
patterns += builtin_patterns
|
28
|
+
end
|
29
|
+
|
30
|
+
def installed_template_manifests
|
31
|
+
## note: code moved to its own gem, that is, pakman
|
32
|
+
## see https://github.com/geraldb/pakman
|
33
|
+
|
34
|
+
Pakman::Finder.new( logger ).find_manifests( installed_template_manifest_patterns )
|
35
|
+
end
|
36
|
+
|
37
|
+
end # module Manifest
|
38
|
+
end # module Slideshow
|
data/lib/slideshow/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideshow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -399806770
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 1.2.0.beta1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Gerald Bauer
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-06-
|
20
|
+
date: 2012-06-18 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
name: RedCloth
|
@@ -66,35 +68,35 @@ dependencies:
|
|
66
68
|
type: :runtime
|
67
69
|
version_requirements: *id003
|
68
70
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
71
|
+
name: props
|
70
72
|
prerelease: false
|
71
73
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
74
|
none: false
|
73
75
|
requirements:
|
74
76
|
- - ">="
|
75
77
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
78
|
+
hash: 23
|
77
79
|
segments:
|
78
80
|
- 0
|
79
|
-
-
|
81
|
+
- 2
|
80
82
|
- 0
|
81
|
-
version: 0.
|
83
|
+
version: 0.2.0
|
82
84
|
type: :runtime
|
83
85
|
version_requirements: *id004
|
84
86
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
87
|
+
name: pakman
|
86
88
|
prerelease: false
|
87
89
|
requirement: &id005 !ruby/object:Gem::Requirement
|
88
90
|
none: false
|
89
91
|
requirements:
|
90
92
|
- - ">="
|
91
93
|
- !ruby/object:Gem::Version
|
92
|
-
hash:
|
94
|
+
hash: 27
|
93
95
|
segments:
|
94
96
|
- 0
|
95
|
-
-
|
97
|
+
- 1
|
96
98
|
- 0
|
97
|
-
version: 0.
|
99
|
+
version: 0.1.0
|
98
100
|
type: :runtime
|
99
101
|
version_requirements: *id005
|
100
102
|
- !ruby/object:Gem::Dependency
|
@@ -151,10 +153,12 @@ files:
|
|
151
153
|
- config/slideshow.builtin.yml
|
152
154
|
- config/slideshow.yml
|
153
155
|
- lib/slideshow.rb
|
154
|
-
- lib/slideshow/commands/fetch.rb
|
155
|
-
- lib/slideshow/commands/gen.rb
|
156
|
-
- lib/slideshow/commands/gen_templates.rb
|
157
|
-
- lib/slideshow/commands/list.rb
|
156
|
+
- lib/slideshow/cli/commands/fetch.rb
|
157
|
+
- lib/slideshow/cli/commands/gen.rb
|
158
|
+
- lib/slideshow/cli/commands/gen_templates.rb
|
159
|
+
- lib/slideshow/cli/commands/list.rb
|
160
|
+
- lib/slideshow/cli/opts.rb
|
161
|
+
- lib/slideshow/cli/runner.rb
|
158
162
|
- lib/slideshow/config.rb
|
159
163
|
- lib/slideshow/filters/debug_filter.rb
|
160
164
|
- lib/slideshow/filters/headers_filter.rb
|
@@ -173,12 +177,10 @@ files:
|
|
173
177
|
- lib/slideshow/helpers/syntax/uv_helper.rb
|
174
178
|
- lib/slideshow/helpers/table_helper.rb
|
175
179
|
- lib/slideshow/helpers/text_helper.rb
|
176
|
-
- lib/slideshow/
|
180
|
+
- lib/slideshow/manifest_helpers.rb
|
177
181
|
- lib/slideshow/markup/markdown.rb
|
178
182
|
- lib/slideshow/markup/rest.rb
|
179
183
|
- lib/slideshow/markup/textile.rb
|
180
|
-
- lib/slideshow/opts.rb
|
181
|
-
- lib/slideshow/runner.rb
|
182
184
|
- lib/slideshow/slide.rb
|
183
185
|
- lib/slideshow/version.rb
|
184
186
|
- templates/s6.txt
|
@@ -220,12 +222,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
223
|
none: false
|
222
224
|
requirements:
|
223
|
-
- - "
|
225
|
+
- - ">"
|
224
226
|
- !ruby/object:Gem::Version
|
225
|
-
hash:
|
227
|
+
hash: 25
|
226
228
|
segments:
|
227
|
-
-
|
228
|
-
|
229
|
+
- 1
|
230
|
+
- 3
|
231
|
+
- 1
|
232
|
+
version: 1.3.1
|
229
233
|
requirements: []
|
230
234
|
|
231
235
|
rubyforge_project: slideshow
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module Slideshow
|
2
|
-
|
3
|
-
class Fetch
|
4
|
-
|
5
|
-
include Manifest # gets us methods like installed_template_manifests, etc.
|
6
|
-
|
7
|
-
### fix: remove opts, use config (wrapped!!)
|
8
|
-
|
9
|
-
def initialize( logger, opts, config )
|
10
|
-
@logger = logger
|
11
|
-
@opts = opts
|
12
|
-
@config = config
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :logger, :opts, :config
|
16
|
-
|
17
|
-
def fetch_file( dest, src )
|
18
|
-
|
19
|
-
## note: code moved to its own gem, that is, fetcher
|
20
|
-
## see https://github.com/geraldb/fetcher
|
21
|
-
|
22
|
-
# nb: in new method src comes first (and dest second - might be optional in the future)
|
23
|
-
Fetcher::Worker.new( logger ).copy( src, dest )
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def run
|
28
|
-
logger.debug "fetch_uri=#{opts.fetch_uri}"
|
29
|
-
|
30
|
-
src = opts.fetch_uri
|
31
|
-
|
32
|
-
## check for builtin shortcut (assume no / or \)
|
33
|
-
if src.index( '/' ).nil? && src.index( '\\' ).nil?
|
34
|
-
shortcut = src.clone
|
35
|
-
src = config.map_fetch_shortcut( src )
|
36
|
-
|
37
|
-
if src.nil?
|
38
|
-
puts "** Error: No mapping found for fetch shortcut '#{shortcut}'."
|
39
|
-
return
|
40
|
-
end
|
41
|
-
puts " Mapping fetch shortcut '#{shortcut}' to: #{src}"
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
# src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
|
46
|
-
# src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
|
47
|
-
uri = URI.parse( src )
|
48
|
-
|
49
|
-
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
|
50
|
-
|
51
|
-
dirname = File.dirname( uri.path )
|
52
|
-
basename = File.basename( uri.path, '.*' ) # e.g. fullerscreen (without extension)
|
53
|
-
filename = File.basename( uri.path ) # e.g. fullerscreen.txt (with extension)
|
54
|
-
|
55
|
-
logger.debug "dirname: #{dirname}"
|
56
|
-
logger.debug "basename: #{basename}, filename: #{filename}"
|
57
|
-
|
58
|
-
dlbase = "#{uri.scheme}://#{uri.host}:#{uri.port}#{dirname}"
|
59
|
-
pkgpath = File.expand_path( "#{config.config_dir}/templates/#{basename}" )
|
60
|
-
|
61
|
-
logger.debug "dlpath: #{dlbase}"
|
62
|
-
logger.debug "pkgpath: #{pkgpath}"
|
63
|
-
|
64
|
-
FileUtils.makedirs( pkgpath ) unless File.directory? pkgpath
|
65
|
-
|
66
|
-
puts "Fetching template package '#{basename}'"
|
67
|
-
puts " : from '#{dlbase}'"
|
68
|
-
puts " : saving to '#{pkgpath}'"
|
69
|
-
|
70
|
-
# download manifest
|
71
|
-
dest = "#{pkgpath}/#{filename}"
|
72
|
-
|
73
|
-
puts " Downloading manifest '#{filename}'..."
|
74
|
-
|
75
|
-
fetch_file( dest, src )
|
76
|
-
|
77
|
-
manifest = load_manifest_core( dest )
|
78
|
-
|
79
|
-
# download templates listed in manifest
|
80
|
-
manifest.each do |values|
|
81
|
-
values[1..-1].each do |file|
|
82
|
-
|
83
|
-
dest = "#{pkgpath}/#{file}"
|
84
|
-
|
85
|
-
# make sure path exists
|
86
|
-
destpath = File.dirname( dest )
|
87
|
-
FileUtils.makedirs( destpath ) unless File.directory? destpath
|
88
|
-
|
89
|
-
src = "#{dlbase}/#{file}"
|
90
|
-
|
91
|
-
puts " Downloading template '#{file}'..."
|
92
|
-
fetch_file( dest, src )
|
93
|
-
end
|
94
|
-
end
|
95
|
-
puts "Done."
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
end # class Fetch
|
100
|
-
|
101
|
-
end # module Slideshow
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Slideshow
|
2
|
-
|
3
|
-
class GenTemplates
|
4
|
-
|
5
|
-
include Manifest # gets us methods like installed_template_manifests, etc.
|
6
|
-
|
7
|
-
### fix: remove opts, use config (wrapped!!)
|
8
|
-
|
9
|
-
def initialize( logger, opts, config )
|
10
|
-
@logger = logger
|
11
|
-
@opts = opts
|
12
|
-
@config = config
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :logger, :opts, :config
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def with_output_path( dest, output_path )
|
20
|
-
dest_full = File.expand_path( dest, output_path )
|
21
|
-
logger.debug "dest_full=#{dest_full}"
|
22
|
-
|
23
|
-
# make sure dest path exists
|
24
|
-
dest_path = File.dirname( dest_full )
|
25
|
-
logger.debug "dest_path=#{dest_path}"
|
26
|
-
FileUtils.makedirs( dest_path ) unless File.directory? dest_path
|
27
|
-
dest_full
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def run
|
32
|
-
manifest_name = opts.manifest
|
33
|
-
logger.debug "manifest=#{manifest_name}"
|
34
|
-
|
35
|
-
manifests = installed_generator_manifests
|
36
|
-
|
37
|
-
# check for builtin generator manifests
|
38
|
-
matches = manifests.select { |m| m[0] == manifest_name+".gen" }
|
39
|
-
|
40
|
-
if matches.empty?
|
41
|
-
puts "*** error: unknown template manifest '#{manifest_name}'"
|
42
|
-
# todo: list installed manifests
|
43
|
-
exit 2
|
44
|
-
end
|
45
|
-
|
46
|
-
manifest = load_manifest( matches[0][1] )
|
47
|
-
|
48
|
-
# expand output path in current dir and make sure output path exists
|
49
|
-
outpath = File.expand_path( opts.output_path )
|
50
|
-
logger.debug "outpath=#{outpath}"
|
51
|
-
FileUtils.makedirs( outpath ) unless File.directory? outpath
|
52
|
-
|
53
|
-
manifest.each do |entry|
|
54
|
-
dest = entry[0]
|
55
|
-
source = entry[1]
|
56
|
-
|
57
|
-
puts "Copying to #{dest} from #{source}..."
|
58
|
-
FileUtils.copy( source, with_output_path( dest, outpath ) )
|
59
|
-
end
|
60
|
-
|
61
|
-
puts "Done."
|
62
|
-
end
|
63
|
-
|
64
|
-
end # class GenTemplates
|
65
|
-
|
66
|
-
end # class Slideshow
|
data/lib/slideshow/manifest.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
module Slideshow
|
2
|
-
module Manifest
|
3
|
-
|
4
|
-
def load_manifest_core( path )
|
5
|
-
manifest = []
|
6
|
-
|
7
|
-
File.open( path ).readlines.each_with_index do |line,i|
|
8
|
-
case line
|
9
|
-
when /^\s*$/
|
10
|
-
# skip empty lines
|
11
|
-
when /^\s*#.*$/
|
12
|
-
# skip comment lines
|
13
|
-
else
|
14
|
-
logger.debug "line #{i+1}: #{line.strip}"
|
15
|
-
values = line.strip.split( /[ <,+]+/ )
|
16
|
-
|
17
|
-
# add source for shortcuts (assumes relative path; if not issue warning/error)
|
18
|
-
values << values[0] if values.size == 1
|
19
|
-
|
20
|
-
manifest << values
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
manifest
|
25
|
-
end
|
26
|
-
|
27
|
-
def load_manifest( path )
|
28
|
-
|
29
|
-
filename = path
|
30
|
-
|
31
|
-
puts " Loading template manifest #{filename}..."
|
32
|
-
manifest = load_manifest_core( filename )
|
33
|
-
|
34
|
-
# post-processing
|
35
|
-
# normalize all source paths (1..-1) /make full path/add template dir
|
36
|
-
|
37
|
-
templatesdir = File.dirname( path )
|
38
|
-
logger.debug "templatesdir=#{templatesdir}"
|
39
|
-
|
40
|
-
manifest.each do |values|
|
41
|
-
(1..values.size-1).each do |i|
|
42
|
-
values[i] = "#{templatesdir}/#{values[i]}"
|
43
|
-
logger.debug " path[#{i}]=>#{values[i]}<"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
manifest
|
48
|
-
end
|
49
|
-
|
50
|
-
def find_manifests( patterns )
|
51
|
-
manifests = []
|
52
|
-
|
53
|
-
patterns.each do |pattern|
|
54
|
-
pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
|
55
|
-
logger.debug "Checking #{pattern}"
|
56
|
-
Dir.glob( pattern ) do |file|
|
57
|
-
logger.debug " Found manifest: #{file}"
|
58
|
-
manifests << [ File.basename( file ), file ]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
manifests
|
63
|
-
end
|
64
|
-
|
65
|
-
def installed_generator_manifests
|
66
|
-
# 1) search gem/templates
|
67
|
-
|
68
|
-
builtin_patterns = [
|
69
|
-
"#{Slideshow.root}/templates/*.txt.gen"
|
70
|
-
]
|
71
|
-
|
72
|
-
find_manifests( builtin_patterns )
|
73
|
-
end
|
74
|
-
|
75
|
-
def installed_template_manifests
|
76
|
-
# 1) search ./templates
|
77
|
-
# 2) search config_dir/templates
|
78
|
-
# 3) search gem/templates
|
79
|
-
|
80
|
-
builtin_patterns = [
|
81
|
-
"#{Slideshow.root}/templates/*.txt"
|
82
|
-
]
|
83
|
-
config_patterns = [
|
84
|
-
"#{config.config_dir}/templates/*.txt",
|
85
|
-
"#{config.config_dir}/templates/*/*.txt"
|
86
|
-
]
|
87
|
-
current_patterns = [
|
88
|
-
"templates/*.txt",
|
89
|
-
"templates/*/*.txt"
|
90
|
-
]
|
91
|
-
|
92
|
-
patterns = []
|
93
|
-
patterns += current_patterns unless Slideshow.root == File.expand_path( '.' ) # don't include working dir if we test code from repo (don't include slideshow/templates)
|
94
|
-
patterns += config_patterns
|
95
|
-
patterns += builtin_patterns
|
96
|
-
|
97
|
-
find_manifests( patterns )
|
98
|
-
end
|
99
|
-
|
100
|
-
end # module Manifest
|
101
|
-
end # module Slideshow
|