puppet-courseware-manager 0.5.0 → 0.5.1

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: e135fcbc76fc11962651ceef46e571a9c5da544b
4
- data.tar.gz: 04f2a882f9c12822ed9f6a865479dab8443c4a22
3
+ metadata.gz: 920d9ead0c7f53930949fc216271fd862730d3af
4
+ data.tar.gz: eacf4a3bfa5f1f90ff38e5eb1d67a80c660101a3
5
5
  SHA512:
6
- metadata.gz: f97ddc37a246bc5fc92dce8b2f979e9b9d264b077211ca0f12db645cdee487406b55eb4e3997e64155fd573c47ea890088e4f9983e225dd77ffeb62cc7c06fdb
7
- data.tar.gz: bc0af0f84e9f0c4fb59069d792656003700e064529dacad54a001ce55c95e8761762b51511670edf96fab4aa9ffe3cbabadd35545cb7faa96425d21153fd2497
6
+ metadata.gz: cb0b92b90e8221ca981d913a0db22c399baaf7b20b82e7b9970018d2df010ddfc6ce16d7316100596c24e2f9c19493d369a4436085ec762e01f42712bf6884e5
7
+ data.tar.gz: 3f17f6a5c3cf8977124686a9de48cefb8837129c6c3f63b54ad42c3ef4e2174415caa7b5829f80a27a33fcbbf018ad0441bf55e07ec866b551e1ea4c0daa5883
data/CHANGELOG.txt CHANGED
@@ -1,6 +1,11 @@
1
1
  # Courseware Manager
2
2
  ## Release Notes
3
3
 
4
+ ### v0.5.1
5
+ * Support modular presentations
6
+ * Allow watermarked PDF files via metadata in showoff
7
+ * Open file storage links during release process
8
+
4
9
  ### v0.5.0 (Public release)
5
10
  * First public release
6
11
  * Not for general consumption, merely for ease of distribution.
data/bin/courseware CHANGED
@@ -27,6 +27,10 @@ optparse = OptionParser.new { |opts|
27
27
  cmdlineopts[:renderer] = opt.to_sym
28
28
  end
29
29
 
30
+ opts.on("-f", "--file FILE", "Presentation file. Defaults to 'showoff.json'.") do |opt|
31
+ cmdlineopts[:presfile] = opt
32
+ end
33
+
30
34
  opts.on("-d", "--debug", "Display debugging messages") do
31
35
  cmdlineopts[:debug] = true
32
36
  end
@@ -56,7 +60,6 @@ config.merge!(cmdlineopts)
56
60
  config[:templates] ||= 'git@github.com:puppetlabs/courseware-templates.git'
57
61
  config[:cachedir] ||= '~/.courseware'
58
62
  config[:stylesheet] ||= 'courseware.css'
59
- config[:presfile] ||= 'showoff.json'
60
63
  config[:renderer] ||= :wkhtmltopdf
61
64
  config[:output] ||= 'pdf'
62
65
  config[:collector] ||= 'http://puppetlabs.com/training/issues?s='
@@ -71,6 +74,16 @@ config[:pdf][:password] ||= 'default'
71
74
  config[:pdf][:protected] ||= true
72
75
  config[:pdf][:watermark] ||= false
73
76
  config[:pdf][:license] ||= nil
77
+ config[:release] ||= {}
78
+ config[:release][:links] ||= []
79
+
80
+ # Validating obsolete slides is special because we have to load all variants;
81
+ # nonetheless, we do need *something* valid there, so drop in a dummy value.
82
+ if ARGV == ['validate', 'obsolete']
83
+ config[:presfile] ||= 'showoff.json'
84
+ else
85
+ config[:presfile] ||= Courseware.choose_variant
86
+ end
74
87
 
75
88
  # expand out all path shortcuts in one single place.
76
89
  [ :cachedir ].each do |path|
data/lib/courseware.rb CHANGED
@@ -45,7 +45,6 @@ class Courseware
45
45
  :course => @manager.coursename,
46
46
  :prefix => @manager.prefix,
47
47
  :version => @repository.current(@manager.prefix),
48
- :variant => Courseware.choose_variant,
49
48
  }
50
49
  Courseware::Printer.new(@config, opts) do |printer|
51
50
  subject.each do |item|
@@ -49,6 +49,8 @@ class Courseware
49
49
  obsolete: Lists all unreferenced images and slides. This reference checks
50
50
  all slides and all CSS stylesheets. Case sensitive.
51
51
 
52
+ Note: This validator will validate all course variants.
53
+
52
54
  missing: Lists all slides that are missing. Note that this does not check
53
55
  for missing image files yet. Case sensitive.
54
56
 
@@ -15,12 +15,11 @@ class Courseware::Manager
15
15
  @warnings = 0
16
16
  @errors = 0
17
17
 
18
- if File.exists?(@config[:presfile])
19
- showoff = JSON.parse(File.read(@config[:presfile]))
20
- @coursename = showoff['name']
21
- @prefix = showoff['name'].gsub(' ', '_')
22
- @sections = showoff['sections']
23
- end
18
+ showoff = Courseware.parse_showoff(@config[:presfile])
19
+ @coursename = showoff['name']
20
+ @prefix = showoff['name'].gsub(' ', '_')
21
+ @sections = showoff['sections']
22
+ @password = showoff['key']
24
23
  end
25
24
 
26
25
  def releasenotes
@@ -68,6 +67,12 @@ class Courseware::Manager
68
67
 
69
68
  @repository.commit(@config[:stylesheet], "Updating for #{@coursename} release #{version}")
70
69
  @repository.tag("#{@prefix}-#{version}", "Releasing #{@coursename} version #{version}")
70
+
71
+ # places the PDF files should be uploaded to
72
+ @config[:release][:links].each do |link|
73
+ system("open #{link}")
74
+ end
75
+
71
76
  puts "Release shipped. Please upload PDF files to printer and break out the bubbly."
72
77
  end
73
78
 
@@ -122,7 +127,6 @@ private
122
127
  :course => @coursename,
123
128
  :prefix => @prefix,
124
129
  :version => version,
125
- :variant => Courseware.choose_variant,
126
130
  }
127
131
  end
128
132
 
@@ -1,6 +1,11 @@
1
1
  class Courseware::Manager
2
2
 
3
3
  def obsolete
4
+ # We need to get all slides from all variants to determine what's obsolete.
5
+ allsections = Dir.glob('*.json').collect do |variant|
6
+ Courseware.parse_showoff(variant)['sections'] rescue nil
7
+ end.flatten.uniq
8
+
4
9
  puts "Obsolete images:"
5
10
  Dir.glob('**/_images/*') do |file|
6
11
  next if File.symlink? file
@@ -16,7 +21,7 @@ class Courseware::Manager
16
21
  next if File.symlink? file
17
22
  next if File.directory? file
18
23
  next if file =~ /^_.*$|^[^\/]*$/
19
- next if @sections.include? file
24
+ next if allsections.include? file
20
25
 
21
26
  puts " * #{file}"
22
27
  @warnings += 1
@@ -6,18 +6,19 @@ class Courseware::Printer
6
6
  @course = opts[:course] or raise 'Course is a required option'
7
7
  @prefix = opts[:prefix] or raise 'Prefix is a required option'
8
8
  @version = opts[:version] or raise 'Version is a required option'
9
- @varfile = opts[:variant] or raise 'Variant is a required option'
9
+ raise unless can_print?
10
10
 
11
+ @varfile = config[:presfile] or raise 'Presentation file is not set properly!'
11
12
  @variant = File.basename(@varfile, '.json') unless @varfile == 'showoff.json'
12
13
 
13
- raise unless can_print?
14
-
15
14
  @pdfopts = "--pdf-title '#{@course}' --pdf-author '#{@config[:pdf][:author]}' --pdf-subject '#{@config[:pdf][:subject]}'"
16
15
  @pdfopts << " --disallow-modify" if @config[:pdf][:protected]
17
16
 
18
17
  if @config[:pdf][:watermark]
19
- @event_id = Courseware.question('Enter the Event ID:')
20
- @password = Courseware.question('Enter desired password:', (@event_id[/-?(\w*)$/, 1] rescue nil))
18
+ showoff = Courseware.parse_showoff(@config[:presfile])
19
+
20
+ @event_id = showoff['event_id'] || Courseware.question('Enter the Event ID:')
21
+ @password = showoff['key'] || Courseware.question('Enter desired password:', (@event_id[/-?(\w*)$/, 1] rescue nil))
21
22
  @watermark_style = File.join(@config[:cachedir], 'templates', 'watermark.css')
22
23
  @watermark_pdf = File.join(@config[:cachedir], 'templates', 'watermark.pdf')
23
24
  end
@@ -123,7 +124,7 @@ class Courseware::Printer
123
124
  begin
124
125
  # Until showoff static knows about -f, we have to schlup around files
125
126
  if @variant
126
- FileUtils.mv 'showoff.json', 'showoff.json.tmp'
127
+ FileUtils.mv 'showoff.json', '.showoff.json.tmp'
127
128
  FileUtils.cp @varfile, 'showoff.json'
128
129
  end
129
130
 
@@ -134,7 +135,7 @@ class Courseware::Printer
134
135
  FileUtils.cp('cobrand.png', File.join('static', 'image', 'cobrand.png'))
135
136
  end
136
137
  ensure
137
- FileUtils.mv('showoff.json.tmp', 'showoff.json') if File.exist? 'showoff.json.tmp'
138
+ FileUtils.mv('.showoff.json.tmp', 'showoff.json') if File.exist? '.showoff.json.tmp'
138
139
  end
139
140
  end
140
141
 
@@ -87,6 +87,25 @@ class Courseware
87
87
  variants[idx]
88
88
  end
89
89
 
90
+ # TODO: I'm not happy with this being here, but I don't see a better place for it just now
91
+ def self.parse_showoff(filename)
92
+ showoff = JSON.parse(File.read(filename))
93
+ sections = showoff['sections'].map do |entry|
94
+ next entry if entry.is_a? String
95
+ next nil unless entry.is_a? Hash
96
+ next nil unless entry.include? 'include'
97
+
98
+ file = entry['include']
99
+ path = File.dirname(file)
100
+ data = JSON.parse(File.read(file))
101
+
102
+ data.map { |source| "#{path}/#{source}" }
103
+ end.flatten.compact
104
+ showoff['sections'] = sections
105
+
106
+ return showoff
107
+ end
108
+
90
109
  def self.get_component(initial)
91
110
  puts 'The component ID for this course can be found at:'
92
111
  puts ' * https://tickets.puppetlabs.com/browse/COURSES/?selectedTab=com.atlassian.jira.jira-projects-plugin:components-panel'
@@ -1,4 +1,4 @@
1
1
  class Courseware
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-courseware-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mdl