jekyll-page-boilerplate 4.1.1 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll_page_boilerplate/msg/description.md +4 -1
- data/lib/jekyll_page_boilerplate/msg/gem_description.md +15 -0
- data/lib/jekyll_page_boilerplate/page.rb +24 -14
- data/lib/jekyll_page_boilerplate/version.rb +1 -1
- data/lib/jekyll_page_boilerplate_cli.rb +4 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7fd37de6ea8e3b6858fa19bb1015d60513602ff83e99608c68467cf08c86775
|
4
|
+
data.tar.gz: 7655f8d5b0afed1e3e86ffd2f5922f9c8ef1a433e4e1ec3c1c57f38e6704bcfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bef77e3449efe9f265ea6255731ff8aea525fc93bba54c00445ba12dfa4c17055e00e61211184dfded8fbd946e72a10e971378f82f04b1521fcd8ad3350d88a5
|
7
|
+
data.tar.gz: 476247fa459c5170f7490b1179837800a9ab0b961db857d3442da6e6a8a8ad462151ce82b3f3134b77bab4bba7225014def6af01311d8ca52538563eca9327c4
|
@@ -5,7 +5,10 @@ A boilerplate is a markdown file you place under the `_boilerplates` folder to g
|
|
5
5
|
---
|
6
6
|
_boilerplate: # boilerplate settings
|
7
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.
|
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.
|
9
12
|
title: {{ boilerplate.title }} # tags like this will be replaced
|
10
13
|
layout: post # everthing else will be copied to the new post.
|
11
14
|
author: John Doe
|
@@ -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
|
+
|
@@ -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 =
|
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
|
|
@@ -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
|
-
|
57
|
+
scan_slug
|
58
|
+
@config['file'] ||= @config['slug']
|
48
59
|
|
49
60
|
scan_template :@body
|
50
61
|
scan_template :@head
|
@@ -69,13 +80,22 @@ 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
|
73
|
-
instance_variable_get(var).gsub! /\{{2}\s{0,}boilerplate\.#{
|
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
|
@@ -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)
|
@@ -10,15 +10,17 @@ class JekyllPageBoilerplate::Application < Bales::Application
|
|
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, *custom, title: nil, path: nil, timestamp: nil, suffix: nil|
|
20
|
+
action do |plate, *custom, title: nil, slug: nil, path: nil, timestamp: nil, suffix: nil|
|
19
21
|
custom = Hash[custom.map {|v| v.split('=')}]
|
20
22
|
JekyllPageBoilerplate.page plate, custom.merge({
|
21
|
-
title: title, path: path,
|
23
|
+
title: title, path: path, slug: slug,
|
22
24
|
suffix: suffix, timestamp: timestamp
|
23
25
|
})
|
24
26
|
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.
|
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
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bales
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/jekyll_page_boilerplate/list.rb
|
77
77
|
- lib/jekyll_page_boilerplate/msg.rb
|
78
78
|
- lib/jekyll_page_boilerplate/msg/description.md
|
79
|
+
- lib/jekyll_page_boilerplate/msg/gem_description.md
|
79
80
|
- lib/jekyll_page_boilerplate/page.rb
|
80
81
|
- lib/jekyll_page_boilerplate/version.rb
|
81
82
|
- lib/jekyll_page_boilerplate_cli.rb
|