dsm-portfolio-plugin 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dsm-portfolio-plugin.rb +88 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4bbff02d40d1010a055f83592f62d9575238933
4
- data.tar.gz: a52f6089c72bec317aa4ddbc7a16f10229d68d41
3
+ metadata.gz: 58a8d7966ac4de141730a5cd8281732f59997d26
4
+ data.tar.gz: 0d9bb4e2370bf48634dd307baf4ce57a10d80678
5
5
  SHA512:
6
- metadata.gz: cc3d614a174e013baa9ad5d823742539d376f8902fc005d4962d743129478cf4d9239519337f855c362c696701badfede57d160eda057830e9ae318eb0d65096
7
- data.tar.gz: 237ee2648f324425549471e9100024f7b22a9ff33e7e709a2b3f4c85ff8f66d8e4cc25a877e4b6137985edf6836cf3dc50392cfc26593e8157b85565b4a573e8
6
+ metadata.gz: 5fd3a930efc6c58f277825990453d1dc46e499f2485891524da483fdbb24ae25a6733d38b76f6943fbd1190d4efa53b2596efbb2f588dfd24c0c12ddc3bc111d
7
+ data.tar.gz: 48b14437c3cfe6bad7c8825c4079651decfcd7a4aa68eb5959c232d3c6b12beab4f7c07fdef92c58cf33580d88361dd2edb1a2cd62553e5c32eaab0ffe6c8c45
@@ -1,5 +1,74 @@
1
- # TODO: Comment
1
+ # TODO: Comment!
2
2
  module Jekyll
3
+ # Define custom commands.
4
+ module Commands
5
+ class NewProject < Jekyll::Command
6
+ class << self
7
+ def self.init_with_program(prog)
8
+ prog.command(:project) do |c|
9
+ c.syntax 'project NAME'
10
+ c.description 'Creates a new project with the given NAME'
11
+
12
+ c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
13
+ c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
14
+
15
+ c.action do |args, options|
16
+ Jekyll::Commands::Project.process(args, options)
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.process(args, options = {})
22
+ raise ArgumentError.new('You must specify a name.') if args.empty?
23
+
24
+ # layout = options["layout"].nil? ? "post" : options["layout"]
25
+
26
+ # Create options for each post type.
27
+ ext = "md"
28
+ date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
29
+
30
+ title = args.shift
31
+ name = title.gsub(' ', '-').downcase
32
+
33
+ # TODO: Replace this with smart filling from data file and template file.
34
+ post_types = []
35
+
36
+ post_types.push('vignette')
37
+ post_types.push('summary')
38
+
39
+ # raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
40
+
41
+ # For every post-type in subfolder...
42
+ post_types.each do |file_type|
43
+ # Format file path.
44
+ post_path = file_name(name, post_type, ext, date)
45
+
46
+ # Create file.
47
+ File.open(post_path, "w") do |f|
48
+ # Fill it with appropriate front-matter.
49
+ f.puts(front_matter(post_type, title))
50
+ end
51
+ end
52
+
53
+ puts "New posts created at ./_posts/#{date.strftime('%Y-%m-%d')}-#{name}.\n"
54
+ end
55
+
56
+ # Returns the filename of the draft, as a String
57
+ def self.file_name(name, post_type, ext, date)
58
+ "_posts/#{date.strftime('%Y-%m-%d')}-#{name}/#{post_type}.#{ext}"
59
+ end
60
+
61
+ # TODO: Replace this with smart filling from data file and template file.
62
+ def self.front_matter(layout, title)
63
+ "---
64
+ layout: #{layout}
65
+ title: #{title}
66
+ ---"
67
+ end
68
+ end
69
+ end
70
+ end
71
+
3
72
  class ProjectGenerator < Generator
4
73
  safe true
5
74
  priority :highest
@@ -57,18 +126,28 @@ module Jekyll
57
126
  competencyTally[:count] += 1
58
127
  else
59
128
  # Add entry.
60
- context['active_vignette'][:competencies].push({
61
- 'id': competency['id'],
62
- 'count': 1
63
- })
129
+ if competency
130
+ context['active_vignette'][:competencies].push({
131
+ 'id': competency['id'],
132
+ 'count': 1,
133
+ 'linked': true
134
+ })
135
+ else
136
+ context['active_vignette'][:competencies].push({
137
+ 'id': @competencyId,
138
+ 'count': 1,
139
+ 'linked': false
140
+ })
141
+ end
64
142
  end
65
143
  end
66
144
 
67
145
  # Render if available.
68
146
  if competency
69
- "<span class=\"a-pill\">#{competency['id']}</span>"
147
+ # <a href="#" class="badge badge-primary">Primary</a>
148
+ " <a href=\"#{context.registers[:site].baseurl}/competencies##{competency['id']}\" class=\"badge badge-primary\">#{competency['id']}</a>"
70
149
  else
71
- "<span class=\"a-pill a-pill--error\">\"#{@competencyId}\" undefined</span>"
150
+ " <span class=\"badge badge-danger\">#{@competencyId} undefined</span>"
72
151
  end
73
152
  end
74
153
  end
@@ -105,9 +184,9 @@ module Jekyll
105
184
  # Render text as normal.
106
185
  rendered = super
107
186
  # Wrap in page-specific markup.
108
- classString = 'o-vignette-blocks__block'
187
+ classString = 'vignette-block'
109
188
  if context['page']['vignettes'].size == 1
110
- classString += ' o-vignette-blocks__block--active'
189
+ classString += ' active'
111
190
  end
112
191
  "<div class=\"#{classString}\" id=\"block-#{context['page']['vignettes'].size - 1}\">#{rendered}</div>"
113
192
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsm-portfolio-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Hills
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll