slideshow 1.1.0.beta7 → 1.1.0.beta8

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.
@@ -0,0 +1,66 @@
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
@@ -0,0 +1,32 @@
1
+ module Slideshow
2
+
3
+ class List
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
+ def run
19
+ manifests = installed_template_manifests
20
+
21
+ puts ''
22
+ puts 'Installed templates include:'
23
+
24
+ manifests.each do |manifest|
25
+ puts " #{manifest[0]} (#{manifest[1]})"
26
+ end
27
+ end
28
+
29
+
30
+ end # class List
31
+
32
+ end # class Slideshow
@@ -2,10 +2,39 @@ module Slideshow
2
2
 
3
3
  class Config
4
4
 
5
- def initialize
6
- # do nothing for now
5
+ def initialize( logger, opts )
6
+ @logger = logger
7
+ @opts = opts
7
8
  end
8
9
 
10
+ attr_reader :logger, :opts
11
+
12
+
13
+ # todo/fix: fix references after this move to here, that is, Config class
14
+ # - used in syntax/uv_helper (use config.cache_dir to access?)
15
+
16
+ def cache_dir
17
+ File.join( Env.home, '.slideshow' )
18
+ end
19
+
20
+ def config_dir
21
+ unless @config_dir # first time? calculate config_dir value to "cache"
22
+
23
+ if opts.config_path
24
+ @config_dir = opts.config_path
25
+ else
26
+ @config_dir = cache_dir
27
+ end
28
+
29
+ # make sure path exists
30
+ FileUtils.makedirs( @config_dir ) unless File.directory? @config_dir
31
+ end
32
+
33
+ @config_dir
34
+ end
35
+
36
+
37
+
9
38
  def load
10
39
 
11
40
  # load builtin config file @ <gem>/config/slideshow.yml
@@ -24,10 +24,10 @@ def uv_worker( code, opts )
24
24
  uv_first_time = session.fetch( :uv_first_time, true )
25
25
  if uv_first_time
26
26
  session[ :uv_first_time ] = false
27
- logger.debug "cache_dir=#{cache_dir}"
27
+ logger.debug "cache_dir=#{config.cache_dir}"
28
28
 
29
- FileUtils.mkdir(cache_dir) unless File.exists?(cache_dir) if cache_dir
30
- Uv.copy_files "xhtml", cache_dir
29
+ FileUtils.mkdir(config.cache_dir) unless File.exists?(config.cache_dir) if config.cache_dir
30
+ Uv.copy_files "xhtml", config.cache_dir
31
31
  end
32
32
 
33
33
  # first time this theme gets used add it to content_for hash for templates to include
@@ -35,7 +35,7 @@ def uv_worker( code, opts )
35
35
  if uv_themes[ theme ].nil?
36
36
  uv_themes[ theme ] = true
37
37
 
38
- theme_content = File.read( "#{cache_dir}/css/#{theme}.css" )
38
+ theme_content = File.read( "#{config.cache_dir}/css/#{theme}.css" )
39
39
 
40
40
  theme_out = %{/* styles for ultraviolet code syntax highlighting theme '#{theme}' */\n\n}
41
41
  theme_out << theme_content
@@ -81,8 +81,8 @@ module Slideshow
81
81
  "#{Slideshow.root}/templates/*.txt"
82
82
  ]
83
83
  config_patterns = [
84
- "#{config_dir}/templates/*.txt",
85
- "#{config_dir}/templates/*/*.txt"
84
+ "#{config.config_dir}/templates/*.txt",
85
+ "#{config.config_dir}/templates/*/*.txt"
86
86
  ]
87
87
  current_patterns = [
88
88
  "templates/*.txt",
@@ -98,8 +98,4 @@ module Slideshow
98
98
  end
99
99
 
100
100
  end # module Manifest
101
- end # module Slideshow
102
-
103
- class Slideshow::Gen
104
- include Slideshow::Manifest
105
- end
101
+ end # module Slideshow
@@ -0,0 +1,130 @@
1
+ module Slideshow
2
+
3
+ class Runner
4
+
5
+ def initialize
6
+ @logger = Logger.new(STDOUT)
7
+ @logger.level = Logger::INFO
8
+
9
+ @opts = Opts.new
10
+ @config = Config.new( @logger, @opts )
11
+ @headers = Headers.new( @config )
12
+ end
13
+
14
+ attr_reader :logger, :opts, :config, :headers
15
+
16
+
17
+
18
+ def load_plugins
19
+
20
+ patterns = []
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)
23
+
24
+ patterns.each do |pattern|
25
+ pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
26
+ Dir.glob( pattern ) do |plugin|
27
+ begin
28
+ puts "Loading plugins in '#{plugin}'..."
29
+ require( plugin )
30
+ rescue Exception => e
31
+ puts "** error: failed loading plugins in '#{plugin}': #{e}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def run( args )
39
+
40
+ opt=OptionParser.new do |cmd|
41
+
42
+ cmd.banner = "Usage: slideshow [options] name"
43
+
44
+ cmd.on( '-o', '--output PATH', 'Output Path' ) { |path| opts.output_path = path }
45
+
46
+ cmd.on( '-g', '--generate', 'Generate Slide Show Templates (Using Built-In S6 Pack)' ) { opts.generate = true }
47
+
48
+ cmd.on( "-t", "--template MANIFEST", "Template Manifest" ) do |t|
49
+ # todo: do some checks on passed in template argument
50
+ opts.manifest = t
51
+ end
52
+
53
+ # ?? opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s }
54
+ # ?? opts.on( "--version", "Show version" ) {}
55
+
56
+ # ?? cmd.on( '-i', '--include PATH', 'Load Path' ) { |s| opts.put( 'include', s ) }
57
+
58
+ cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |uri|
59
+ opts.fetch_uri = uri
60
+ end
61
+
62
+ cmd.on( '-c', '--config PATH', 'Configuration Path (default is ~/.slideshow)' ) do |path|
63
+ opts.config_path = path
64
+ end
65
+
66
+ cmd.on( '-l', '--list', 'List Installed Templates' ) { opts.list = true }
67
+
68
+ # todo: find different letter for debug trace switch (use v for version?)
69
+ cmd.on( "-v", "--verbose", "Show debug trace" ) do
70
+ logger.datetime_format = "%H:%H:%S"
71
+ logger.level = Logger::DEBUG
72
+ end
73
+
74
+ usage =<<EOS
75
+
76
+ Slide Show (S9) is a free web alternative to PowerPoint or KeyNote in Ruby
77
+
78
+ #{cmd.help}
79
+
80
+ Examples:
81
+ slideshow microformats
82
+ slideshow microformats.textile # Process slides using Textile
83
+ slideshow microformats.text # Process slides using Markdown
84
+ slideshow microformats.rst # Process slides using reStructuredText
85
+ slideshow -o slides microformats # Output slideshow to slides folder
86
+
87
+ More examles:
88
+ slideshow -g # Generate slide show templates using built-in S6 pack
89
+
90
+ slideshow -l # List installed slide show templates
91
+ slideshow -f s5blank # Fetch (install) S5 blank starter template from internet
92
+ slideshow -t s5blank microformats # Use your own slide show templates (e.g. s5blank)
93
+
94
+ Further information:
95
+ http://slideshow.rubyforge.org
96
+
97
+ EOS
98
+
99
+
100
+ cmd.on_tail( "-h", "--help", "Show this message" ) do
101
+ puts usage
102
+ exit
103
+ end
104
+ end
105
+
106
+ opt.parse!( args )
107
+
108
+ config.load
109
+
110
+ puts Slideshow.generator
111
+
112
+ if opts.list?
113
+ List.new( logger, opts, config ).run ### todo: remove opts (merge access into config)
114
+ elsif opts.generate?
115
+ GenTemplates.new( logger, opts, config ).run ### todo: remove opts
116
+ elsif opts.fetch?
117
+ Fetch.new( logger, opts, config ).run ### todo: remove opts
118
+ else
119
+ load_plugins # check for optional plugins/extension in ./lib folder
120
+
121
+ args.each do |fn|
122
+ Gen.new( logger, opts, config, headers ).create_slideshow( fn )
123
+ end
124
+ end
125
+ end
126
+
127
+
128
+ end # class Runner
129
+
130
+ end # module Slideshow
@@ -1,3 +1,3 @@
1
1
  module Slideshow
2
- VERSION = '1.1.0.beta7'
2
+ VERSION = '1.1.0.beta8'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 682290833
4
+ hash: 62724110
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
9
  - 0
10
10
  - beta
11
- - 7
12
- version: 1.1.0.beta7
11
+ - 8
12
+ version: 1.1.0.beta8
13
13
  platform: ruby
14
14
  authors:
15
15
  - Gerald Bauer
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-06-12 00:00:00 Z
20
+ date: 2012-06-16 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: RedCloth
@@ -153,13 +153,15 @@ files:
153
153
  - config/slideshow.builtin.yml
154
154
  - config/slideshow.yml
155
155
  - lib/slideshow.rb
156
+ - lib/slideshow/commands/fetch.rb
157
+ - lib/slideshow/commands/gen.rb
158
+ - lib/slideshow/commands/gen_templates.rb
159
+ - lib/slideshow/commands/list.rb
156
160
  - lib/slideshow/config.rb
157
- - lib/slideshow/fetch.rb
158
161
  - lib/slideshow/filters/debug_filter.rb
159
162
  - lib/slideshow/filters/headers_filter.rb
160
163
  - lib/slideshow/filters/slide_filter.rb
161
164
  - lib/slideshow/filters/text_filter.rb
162
- - lib/slideshow/gen.rb
163
165
  - lib/slideshow/headers.rb
164
166
  - lib/slideshow/helpers/analytics_helper.rb
165
167
  - lib/slideshow/helpers/background_helper.rb
@@ -178,6 +180,7 @@ files:
178
180
  - lib/slideshow/markup/rest.rb
179
181
  - lib/slideshow/markup/textile.rb
180
182
  - lib/slideshow/opts.rb
183
+ - lib/slideshow/runner.rb
181
184
  - lib/slideshow/slide.rb
182
185
  - lib/slideshow/version.rb
183
186
  - templates/s6.txt