dsm-portfolio-plugin 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/dsm-portfolio-plugin.rb +53 -55
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00431e89dfb0e6c1fe1b8baf4f24ae60af356798
|
4
|
+
data.tar.gz: 9779fca24f3784f8cd7d7c74bc4cef13247ed938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c082bbddafb07aaf5db413b060c7107b0e0eea00ec7dca807eff17ac4314b4cb719d473d7056b4bff3980f8464ca52d4e0de303d7fb5a26c19ad1c33b0ba2076
|
7
|
+
data.tar.gz: b6162c6eaeabd4b8a3bfc7c0562af9a4d78c13c9e319f896833934d19195e713bba0b267532c5f0d5ed2fc0eda6bb40f8365ee5fa4216b29b35108d9d1fde824
|
data/lib/dsm-portfolio-plugin.rb
CHANGED
@@ -2,69 +2,67 @@
|
|
2
2
|
module Jekyll
|
3
3
|
# Define custom commands.
|
4
4
|
module Commands
|
5
|
-
class NewProject <
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Jekyll::Commands::Project.process(args, options)
|
17
|
-
end
|
5
|
+
class NewProject < Command
|
6
|
+
def self.init_with_program(prog)
|
7
|
+
prog.command(:project) do |c|
|
8
|
+
c.syntax 'project NAME'
|
9
|
+
c.description 'Creates a new project with the given NAME'
|
10
|
+
|
11
|
+
c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
|
12
|
+
c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
|
13
|
+
|
14
|
+
c.action do |args, options|
|
15
|
+
Jekyll::Commands::Project.process(args, options)
|
18
16
|
end
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
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
|
20
|
+
def self.process(args, options = {})
|
21
|
+
raise ArgumentError.new('You must specify a name.') if args.empty?
|
52
22
|
|
53
|
-
|
54
|
-
end
|
23
|
+
# layout = options["layout"].nil? ? "post" : options["layout"]
|
55
24
|
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
25
|
+
# Create options for each post type.
|
26
|
+
ext = "md"
|
27
|
+
date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
|
28
|
+
|
29
|
+
title = args.shift
|
30
|
+
name = title.gsub(' ', '-').downcase
|
60
31
|
|
61
32
|
# TODO: Replace this with smart filling from data file and template file.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
33
|
+
post_types = []
|
34
|
+
|
35
|
+
post_types.push('vignette')
|
36
|
+
post_types.push('summary')
|
37
|
+
|
38
|
+
# raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
|
39
|
+
|
40
|
+
# For every post-type in subfolder...
|
41
|
+
post_types.each do |file_type|
|
42
|
+
# Format file path.
|
43
|
+
post_path = file_name(name, post_type, ext, date)
|
44
|
+
|
45
|
+
# Create file.
|
46
|
+
File.open(post_path, "w") do |f|
|
47
|
+
# Fill it with appropriate front-matter.
|
48
|
+
f.puts(front_matter(post_type, title))
|
49
|
+
end
|
67
50
|
end
|
51
|
+
|
52
|
+
puts "New posts created at ./_posts/#{date.strftime('%Y-%m-%d')}-#{name}.\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns the filename of the draft, as a String
|
56
|
+
def self.file_name(name, post_type, ext, date)
|
57
|
+
"_posts/#{date.strftime('%Y-%m-%d')}-#{name}/#{post_type}.#{ext}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# TODO: Replace this with smart filling from data file and template file.
|
61
|
+
def self.front_matter(layout, title)
|
62
|
+
"---
|
63
|
+
layout: #{layout}
|
64
|
+
title: #{title}
|
65
|
+
---"
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|