pagemaster 2.0.0 → 2.0.1
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/pagemaster.rb +11 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27df4bed4b0e582657fc8a230c85eccfa46374437c0d985e6b8bb6a22b7caeb4
|
4
|
+
data.tar.gz: c78b9cab7ddd6cbe15f767454b099a17bedf02854606e70a3bfb1800c520e263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7718f1fe806f588f726ef289144fc33e34810dff0fd80fcc4f127fd5aca7df8cc479916dcc67c29314cffd11e271d0ed4dcc712040ab4d6e068d5f43ebc633d3
|
7
|
+
data.tar.gz: b954ed10efd104d6ed3643f4f7844033fd1f6d7f133c2798ed6b697405362635228bd79a31ed0ebfeba97be66c93b95ecd5f9b46363418adbe24b2609422e11d
|
data/lib/pagemaster.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
include FileUtils
|
2
1
|
require 'csv'
|
3
2
|
require 'yaml'
|
4
3
|
require 'json'
|
5
4
|
|
5
|
+
include FileUtils
|
6
|
+
|
6
7
|
# Jekyll comand to generate markdown collection pages from CSV/YML/JSON records
|
7
8
|
class Pagemaster < Jekyll::Command
|
8
9
|
class << self
|
9
10
|
def init_with_program(prog)
|
10
|
-
prog.command(:pagemaster) do |
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
11
|
+
prog.command(:pagemaster) do |c|
|
12
|
+
c.syntax 'pagemaster [options] [args]'
|
13
|
+
c.description 'Generate md pages from collection data.'
|
14
|
+
c.option 'no-perma', '--no-permalink', 'Skips adding hard-coded permalink'
|
15
|
+
c.action { |args, options| execute(args, options) }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def execute(args)
|
19
|
+
def execute(args, options)
|
20
20
|
config = YAML.load_file('_config.yml')
|
21
21
|
abort 'Cannot find collections in config' unless config.key?('collections')
|
22
|
-
perma =
|
22
|
+
perma = false
|
23
|
+
perma = config['permalink'] == 'pretty' ? '/' : '.html' unless options.key? 'no-perma'
|
23
24
|
args.each do |name|
|
24
25
|
abort "Cannot find #{name} in collection config" unless config['collections'].key? name
|
25
26
|
meta = {
|
@@ -62,7 +63,7 @@ class Pagemaster < Jekyll::Command
|
|
62
63
|
data.each do |item|
|
63
64
|
pagename = slug(item.fetch(meta['id_key']))
|
64
65
|
pagepath = dir + '/' + pagename + '.md'
|
65
|
-
item['permalink'] = '/' + name + '/' + pagename + perma
|
66
|
+
item['permalink'] = '/' + name + '/' + pagename + perma if perma
|
66
67
|
item['layout'] = meta['layout']
|
67
68
|
if File.exist?(pagepath)
|
68
69
|
puts "#{pagename}.md already exits. Skipping."
|