jekyll-page-boilerplate 4.0.1 → 4.2.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
  SHA256:
3
- metadata.gz: 17477700177377cd7125dcdaab31a6c5ccc853d7f4a2ad866fb055680803f41e
4
- data.tar.gz: 2b03a6cca499eb059c8842fd1a5c4dbeefef44b538d2bd92df738fd795c9a10b
3
+ metadata.gz: c7fd37de6ea8e3b6858fa19bb1015d60513602ff83e99608c68467cf08c86775
4
+ data.tar.gz: 7655f8d5b0afed1e3e86ffd2f5922f9c8ef1a433e4e1ec3c1c57f38e6704bcfd
5
5
  SHA512:
6
- metadata.gz: 91381a908df2713f69036642a842f84da601f8616219ea362b18ded8f8c189452498a40d29c972f7e1832ba414ef8d4fdcd0bbf03aa97e8426582acb665c7b66
7
- data.tar.gz: 7522e8fe98b9beb92b057f1159776ea53c9075fcede91b1a4d0c5632646fb0e25f602931a6b32b84d0bc4c061edaf49ed00715f1d51c70870c4355e0ee809bf0
6
+ metadata.gz: bef77e3449efe9f265ea6255731ff8aea525fc93bba54c00445ba12dfa4c17055e00e61211184dfded8fbd946e72a10e971378f82f04b1521fcd8ad3350d88a5
7
+ data.tar.gz: 476247fa459c5170f7490b1179837800a9ab0b961db857d3442da6e6a8a8ad462151ce82b3f3134b77bab4bba7225014def6af01311d8ca52538563eca9327c4
@@ -0,0 +1,32 @@
1
+ A boilerplate is a markdown file you place under the `_boilerplates` folder to generate new pages for jekyll.
2
+
3
+ `_boilerplates/post.md`
4
+
5
+ ---
6
+ _boilerplate: # boilerplate settings
7
+ path: _posts # the path to create the new page under.
8
+ timestamp: true # when true new post/pages will include the date in the filename.
9
+ # a custom slug overrides the timestamp setting
10
+ slug: '{{ title }}-{{ date }}{{ suffix }}'
11
+ # slug is a template for the filename, it cant take the same tags everything else.
12
+ title: {{ boilerplate.title }} # tags like this will be replaced
13
+ layout: post # everthing else will be copied to the new post.
14
+ author: John Doe
15
+
16
+
17
+ `$ boilerplate post -T "Another one about pottery"` would create a new file `_posts/yyyy-mm-dd-another-one-about-pottery.markdown`
18
+
19
+ ---
20
+ title: Another one about pottery
21
+ created: 'yyyy-mm-dd hh:mm:ss -0000'
22
+ layout: post
23
+ author: John Doe
24
+
25
+
26
+ Available Tags `{{ boilerplate.xxx }}`:
27
+ - `.title`, `.name`
28
+ - `.path`, `.file`, `.suffix`
29
+ - `.time`, `.date`, `.timestamp`
30
+ - `.random_url`
31
+ - Custom tags you provide in the command `bplate post custom=1`
32
+ - And anything you put under the `_boilerplate:` header
@@ -0,0 +1,15 @@
1
+ A boilerplate is a markdown file you place under the `_boilerplates/<boilerplate>.md` folder to generate new pages for jekyll.
2
+
3
+
4
+ It can automatically timestamp and title new pages.
5
+
6
+
7
+ It will also replacing any `{{ boilerplate.xxx }}` tags with content. Available tags include `.time, .title, .date, .random_url`.
8
+
9
+
10
+ You can also provide custom tags with `boilerplate post nav_order=1` > `{{ boilerplate.nav_order }}`.
11
+
12
+
13
+ In the boilerplate header you can specify options like the path to generate pages under and if filenames should be timestamped. `_boilerplate: > path: '_posts/'`
14
+
15
+
@@ -1,8 +1,18 @@
1
1
 
2
2
  module JekyllPageBoilerplate::Msg
3
3
 
4
+ SUMMARY = "A jekyll plugin that allows you to create new pages or posts from a boilerplate through the terminal."
5
+
4
6
  def self.file name
5
- puts File.read(File.join(__dir__, 'msg', name))
7
+ puts self.read_file name
8
+ end
9
+
10
+ def self.description
11
+ self.read_file('description.md')
12
+ end
13
+
14
+ def self.read_file name
15
+ File.read(File.join(__dir__, 'msg', name))
6
16
  end
7
17
 
8
18
  def self.error(**msgs)
@@ -9,7 +9,10 @@ class JekyllPageBoilerplate::Page
9
9
  FILE_DATE_FORMATE = '%Y-%m-%d'
10
10
  READ_CONFIG_REGEX = /[\r\n\s]{0,}^_boilerplate:(\s*^[\t ]{1,2}.+$)+[\r\s\n]{0,}(?![^\r\s\n])/
11
11
  READ_FILE_REGEX = /^-{3}\s*^(?<head>[\s\S]*)^-{3}\s^(?<body>[\s\S]*)/
12
- TAGS_REGEX = /(?<tag>\{{2}\s{0,}boilerplate\.(?<key>[^\{\}\.\s]+)\s{0,}\}{2})/
12
+ TAGS_REGEX = /\{{2}\s{0,}boilerplate\.([^\{\}\.\s]+)\s{0,}\}{2}/
13
+ TAG_SLUG = /\{{2}\s{0,}([^\{\}\.\s]+)\s{0,}\}{2}/
14
+
15
+
13
16
 
14
17
  attr_reader :config
15
18
 
@@ -21,7 +24,7 @@ class JekyllPageBoilerplate::Page
21
24
 
22
25
  def initialize boilerplate, options
23
26
  options.compact!
24
- options.transform_keys! {|k| k.to_s}
27
+ options.transform_keys!(&:to_s)
25
28
  plate_path = get_boilerplate_path(boilerplate).to_s
26
29
 
27
30
  abort_unless_file_exists( plate_path )
@@ -34,6 +37,13 @@ class JekyllPageBoilerplate::Page
34
37
  @config = get_config(parsed_file['head']).merge(options)
35
38
  @config['suffix'] ||= plate_path[/\.\w+$/]
36
39
  @config['name'] ||= plate_path[/.*(?=\.)/] || plate_path
40
+ unless @config['slug']
41
+ if @config['timestamp']
42
+ @config['slug'] = '{{ date }}-{{ title }}{{ suffix }}'
43
+ else
44
+ @config['slug'] = '{{ title }}{{ suffix }}'
45
+ end
46
+ end
37
47
  @head = get_head(parsed_file['head'])
38
48
  @body = get_body(parsed_file['body'])
39
49
  end
@@ -44,7 +54,8 @@ class JekyllPageBoilerplate::Page
44
54
 
45
55
  abort_unless_file_exists(@config['path'])
46
56
 
47
- @config['file'] ||= get_new_page_filename(@config['title'] || @config['name'])
57
+ scan_slug
58
+ @config['file'] ||= @config['slug']
48
59
 
49
60
  scan_template :@body
50
61
  scan_template :@head
@@ -69,21 +80,30 @@ class JekyllPageBoilerplate::Page
69
80
  end
70
81
 
71
82
  def scan_template var
72
- instance_variable_get(var).scan(TAGS_REGEX).uniq.each do |tag, key|
73
- instance_variable_get(var).gsub! /\{{2}\s{0,}boilerplate\.#{key}\s{0,}\}{2}/, get_tag_value(key)
83
+ instance_variable_get(var).scan(TAGS_REGEX).flatten.uniq.each do |tag|
84
+ instance_variable_get(var).gsub! /\{{2}\s{0,}boilerplate\.#{tag}\s{0,}\}{2}/, get_tag_value(tag)
74
85
  end
75
86
  end
76
87
 
88
+ def scan_slug
89
+ @config['slug'].scan(TAG_SLUG).flatten.uniq do |tag|
90
+ @config['slug'].gsub! /\{{2}\s{0,}#{tag}\s{0,}\}{2}/, get_tag_value(tag)
91
+ end
92
+ @config['slug'].gsub!(/[^0-9A-Za-z\.\-_]/, '-')
93
+ @config['slug'].downcase!
94
+ end
95
+
77
96
  def get_tag_value(key)
78
97
  return @config[key] if @config[key]
98
+ return @config['name'] if key == 'title'
79
99
  key = key.split('=')
80
100
  return Tag.send(key[0].to_sym, *key[1]&.split(','))
81
101
  end
82
102
 
83
103
  class Tag
84
104
  class << self
85
- def missing_method
86
- nil
105
+ def method_missing *args
106
+ ''
87
107
  end
88
108
 
89
109
  def random_url length = nil
@@ -113,16 +133,6 @@ class JekyllPageBoilerplate::Page
113
133
  end
114
134
 
115
135
 
116
- def get_new_page_filename title
117
- title = title.to_url
118
- title = "#{title}#{@config['suffix']}"
119
- if @config['timestamp']
120
- title = "#{@config['date']}-#{title}"
121
- end
122
- return title
123
- end
124
-
125
-
126
136
 
127
137
  def abort_if_file_exists(file_path)
128
138
  if File.exist?(file_path)
@@ -1,5 +1,3 @@
1
1
  module JekyllPageBoilerplate
2
- VERSION = "4.0.1"
3
-
4
- DESCRIPTION = "A jekyll plugin that allows you to create new pages or posts from a boilerplate through the terminal."
2
+ VERSION = "4.2.1"
5
3
  end
@@ -21,7 +21,7 @@ module JekyllPageBoilerplate
21
21
  end
22
22
 
23
23
  def self.readme
24
- Msg.file 'readme.md'
24
+ Msg.file 'description.md'
25
25
  end
26
26
 
27
27
  def self.page boilerplate_name, options
@@ -3,28 +3,26 @@ require 'jekyll_page_boilerplate'
3
3
 
4
4
  class JekyllPageBoilerplate::Application < Bales::Application
5
5
  version JekyllPageBoilerplate::VERSION
6
- description JekyllPageBoilerplate::DESCRIPTION
7
-
6
+ description JekyllPageBoilerplate::Msg.description
7
+ summary JekyllPageBoilerplate::Msg::SUMMARY
8
8
  # `boilerplate <page>`
9
9
  option :title, type: String, long_form: '--title', short_form: '-T',
10
10
  description: "`path/<title>.md`"
11
11
  option :path, type: String, long_form: '--path', short_form: '-p',
12
12
  description: "`<path>/title.md`"
13
+ option :slug, type: String, long_form: '--slug', short_form: '-u',
14
+ description: "`path/<slug-template>` `{{title}}-{{date}}{{suffix}}`"
13
15
  option :timestamp, type: TrueClass, long_form: '--timestamp', short_form: '-s',
14
16
  description: "`path/<time.now>-title.md`"
15
17
  option :suffix, type: String, long_form: '--suffix', short_form: '-x',
16
18
  description: "`path/title.<md, markdown, txt>`"
17
19
 
18
- action do |plate, title: nil, path: nil, timestamp: nil, suffix: nil|
19
- JekyllPageBoilerplate.page plate, {title: title, path: path, suffix: suffix, timestamp: timestamp}
20
- end
21
-
22
- # `boilerplate readme`
23
- command 'readme' do
24
- description "Helpful info"
25
- action do
26
- JekyllPageBoilerplate.readme
27
- end
20
+ action do |plate, *custom, title: nil, slug: nil, path: nil, timestamp: nil, suffix: nil|
21
+ custom = Hash[custom.map {|v| v.split('=')}]
22
+ JekyllPageBoilerplate.page plate, custom.merge({
23
+ title: title, path: path, slug: slug,
24
+ suffix: suffix, timestamp: timestamp
25
+ })
28
26
  end
29
27
 
30
28
  # `boilerplate help`
@@ -32,7 +30,7 @@ class JekyllPageBoilerplate::Application < Bales::Application
32
30
 
33
31
  # `boilerplate init`
34
32
  command 'init' do
35
- description "Creates an example boilerplate."
33
+ summary "Creates an example boilerplate."
36
34
  action do
37
35
  JekyllPageBoilerplate.init
38
36
  end
@@ -40,7 +38,7 @@ class JekyllPageBoilerplate::Application < Bales::Application
40
38
 
41
39
  # `boilerplate list`
42
40
  command 'list' do
43
- description "List all the boilerplates"
41
+ summary "List all the boilerplates"
44
42
  action do
45
43
  JekyllPageBoilerplate.list
46
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-page-boilerplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Ferney
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-11 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bales
@@ -44,8 +44,22 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.8.5
47
- description: A jekyll plugin that allows you to create new pages or posts from a boilerplate
48
- through the terminal.
47
+ description: |+
48
+ A boilerplate is a markdown file you place under the `_boilerplates/<boilerplate>.md` folder to generate new pages for jekyll.
49
+
50
+
51
+ It can automatically timestamp and title new pages.
52
+
53
+
54
+ It will also replacing any `{{ boilerplate.xxx }}` tags with content. Available tags include `.time, .title, .date, .random_url`.
55
+
56
+
57
+ You can also provide custom tags with `boilerplate post nav_order=1` > `{{ boilerplate.nav_order }}`.
58
+
59
+
60
+ In the boilerplate header you can specify options like the path to generate pages under and if filenames should be timestamped. `_boilerplate: > path: '_posts/'`
61
+
62
+
49
63
  email:
50
64
  - sean@codekarma.dev
51
65
  executables:
@@ -61,7 +75,8 @@ files:
61
75
  - lib/jekyll_page_boilerplate/init.rb
62
76
  - lib/jekyll_page_boilerplate/list.rb
63
77
  - lib/jekyll_page_boilerplate/msg.rb
64
- - lib/jekyll_page_boilerplate/msg/readme.md
78
+ - lib/jekyll_page_boilerplate/msg/description.md
79
+ - lib/jekyll_page_boilerplate/msg/gem_description.md
65
80
  - lib/jekyll_page_boilerplate/page.rb
66
81
  - lib/jekyll_page_boilerplate/version.rb
67
82
  - lib/jekyll_page_boilerplate_cli.rb
@@ -89,5 +104,6 @@ requirements: []
89
104
  rubygems_version: 3.2.3
90
105
  signing_key:
91
106
  specification_version: 4
92
- summary: A jekyll plugin that creates new pages from boilerplates
107
+ summary: A jekyll plugin that allows you to create new pages or posts from a boilerplate
108
+ through the terminal.
93
109
  test_files: []
@@ -1,30 +0,0 @@
1
- A boilerplate is a markdown file in the `_boilerplates` folder.
2
-
3
- ie. `_boilerplates/post.md`
4
- ---
5
- _boilerplate: # boilerplate settings
6
- path: _posts # the path to create the new page under.
7
- timestap: true # when true new post/pages will include the date in the filename.
8
-
9
- title: {{ boilerplate.title }}
10
- layout: post # everthing else will be copied to the new post.
11
- author: John Doe
12
-
13
- `$ boilerplate post -T "Another one about pottery"` would create a new file `_posts/yyyy-mm-dd-another-one-about-pottery.markdown`
14
- ---
15
- title: Another one about pottery
16
- created: 'yyyy-mm-dd hh:mm:ss -0000'
17
- layout: post
18
- author: John Doe
19
- ---
20
-
21
- Available Tags with `{{ boilerplate.xxx }}`:
22
- - `.title`, `.name`
23
- - `.path`, `.file`, `.suffix`
24
- - `.time`, `.date`, `.timestamp`
25
- - `.random_url`
26
- - And anything you put under the `_boilerplate:` header
27
-
28
-
29
-
30
- Use `boilerplate help` for more details