jekyll-page-boilerplate 4.1.0 → 4.3.0
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/list.rb +1 -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 +31 -15
- data/lib/jekyll_page_boilerplate/version.rb +1 -1
- data/lib/jekyll_page_boilerplate_cli.rb +4 -2
- metadata +19 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11506899d111701050ee623e6f1970e1a6ea1028a597c47ddb09e84d2bda8625
|
4
|
+
data.tar.gz: 79a41ce8ae43e40aab6ece52faab4b0a604f462849a9bb076d8df601cff1409d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57085fc3192f461a8fbdb1bf6dfe722e5eb9447fe608b4be170922192a17c930780d4e25c253a77220ab6dcd697f94c3c2029b2c34546d7f91e0974d679e224d
|
7
|
+
data.tar.gz: 587b236f7a440a0a6d274926267b2fd9e45f83eb11724559b89a5bfba76deb27b99a809f651c96a3d7dabc78dcdce647a961e4961aea8f602aac7c006dc67a48
|
@@ -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 }}'
|
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,16 @@ 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
|
+
@config['basename'] = File.basename(plate_path, '.*')
|
41
|
+
@config['title'] ||= @config['basename']
|
42
|
+
|
43
|
+
unless @config['slug']
|
44
|
+
if @config['timestamp']
|
45
|
+
@config['slug'] = '{{ date }}-{{ title }}'
|
46
|
+
else
|
47
|
+
@config['slug'] = '{{ title }}'
|
48
|
+
end
|
49
|
+
end
|
37
50
|
@head = get_head(parsed_file['head'])
|
38
51
|
@body = get_body(parsed_file['body'])
|
39
52
|
end
|
@@ -44,7 +57,11 @@ class JekyllPageBoilerplate::Page
|
|
44
57
|
|
45
58
|
abort_unless_file_exists(@config['path'])
|
46
59
|
|
47
|
-
|
60
|
+
# puts @config['slug']
|
61
|
+
scan_slug
|
62
|
+
@config['file'] = @config['slug']+@config['suffix']
|
63
|
+
# puts @config['file']
|
64
|
+
# puts @config['title'].inspect
|
48
65
|
|
49
66
|
scan_template :@body
|
50
67
|
scan_template :@head
|
@@ -69,13 +86,22 @@ class JekyllPageBoilerplate::Page
|
|
69
86
|
end
|
70
87
|
|
71
88
|
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\.#{
|
89
|
+
instance_variable_get(var).scan(TAGS_REGEX).flatten.uniq.each do |tag|
|
90
|
+
instance_variable_get(var).gsub! /\{{2}\s{0,}boilerplate\.#{tag}\s{0,}\}{2}/, get_tag_value(tag)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def scan_slug
|
95
|
+
@config['slug'].scan(TAG_SLUG).flatten.uniq.each do |tag|
|
96
|
+
@config['slug'].gsub! /\{{2}\s{0,}#{tag}\s{0,}\}{2}/, get_tag_value(tag)
|
74
97
|
end
|
98
|
+
|
99
|
+
@config['slug'].gsub!(/[^0-9A-Za-z\.\-_]/, '-')
|
100
|
+
@config['slug'].downcase!
|
75
101
|
end
|
76
102
|
|
77
103
|
def get_tag_value(key)
|
78
|
-
return @config[key] if @config[key]
|
104
|
+
return @config[key].to_s if @config[key]
|
79
105
|
key = key.split('=')
|
80
106
|
return Tag.send(key[0].to_sym, *key[1]&.split(','))
|
81
107
|
end
|
@@ -113,16 +139,6 @@ class JekyllPageBoilerplate::Page
|
|
113
139
|
end
|
114
140
|
|
115
141
|
|
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
142
|
|
127
143
|
def abort_if_file_exists(file_path)
|
128
144
|
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>.md` `{{title}}-{{date}}`"
|
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.3.0
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bales
|
@@ -44,19 +44,22 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 2.8.5
|
47
|
-
description:
|
48
|
-
folder to generate new pages for jekyll
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
+
|
60
63
|
email:
|
61
64
|
- sean@codekarma.dev
|
62
65
|
executables:
|
@@ -73,6 +76,7 @@ files:
|
|
73
76
|
- lib/jekyll_page_boilerplate/list.rb
|
74
77
|
- lib/jekyll_page_boilerplate/msg.rb
|
75
78
|
- lib/jekyll_page_boilerplate/msg/description.md
|
79
|
+
- lib/jekyll_page_boilerplate/msg/gem_description.md
|
76
80
|
- lib/jekyll_page_boilerplate/page.rb
|
77
81
|
- lib/jekyll_page_boilerplate/version.rb
|
78
82
|
- lib/jekyll_page_boilerplate_cli.rb
|