mkmatter 3.1.13 → 3.1.14
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/mkmatter/cli/subs/new.rb +103 -120
- data/lib/mkmatter/questions.rb +3 -6
- data/lib/mkmatter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee1ddb005d017b3ff2770792c609726b0781a610438ded6478fe341fd80fd0c6
|
4
|
+
data.tar.gz: 0c0e8e5e6d8a90ad22ec76f55c4e16d04d5ed088a029fc2ecb6e9ed58eb26364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e296cc973212407e248cf12c2d428f9e66edc0b1a06319d40cd2f132b16a74eb114745ecc28cff16e6e93beb5bf971f63eca4f34720b0c13634d5efa4965d58f
|
7
|
+
data.tar.gz: 29dd5eb705e9ef85eb0943499703afc9f0fc56b6e66cc96e139895ed429e9c5609d644d0464185b45264697f57f77fb89d5753ac4a29e1a5fd465581b949d00f
|
@@ -19,51 +19,43 @@ module Mkmatter
|
|
19
19
|
long_desc Mkmatter::App::Descriptions::New::PAGE
|
20
20
|
|
21
21
|
def page
|
22
|
-
if
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
22
|
+
if Mkmatter::Methods.check_if_jekyll
|
23
|
+
@questions = Mkmatter::Questions::Page.new(HILINE).ask
|
24
|
+
answers = Mkmatter::Answers.new(@questions, options.fetch(:publish, nil))
|
25
|
+
if options.fetch(:index, nil)
|
26
|
+
filename = 'index.' + answers.file_format.downcase
|
27
|
+
else
|
28
|
+
filename = answers.title.to_slug + '.' + answers.file_format.downcase
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
folder = Pathname(folder)
|
43
|
-
begin
|
44
|
-
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
45
|
-
rescue Errno::EEXIST
|
46
|
-
HILINE.say("<%= Paint['Error', 'red', :bold] %>: Insufficient Permissions")
|
47
|
-
exit 1
|
48
|
-
end
|
49
|
-
path = Pathname(folder).realdirpath.join(filename)
|
31
|
+
path = Pathname("./#{filename}").realdirpath
|
32
|
+
if HILINE.agree('Would you like to put this page into a subdirectory?', true)
|
33
|
+
HILINE.say("What path? (directories will be created if they don't exist) ")
|
34
|
+
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
35
|
+
HILINE.say('good => path/to/dir ‖ bad => /absolute/paths/are/bad/mmkay')
|
36
|
+
folder = HILINE.ask('? ') do |q|
|
37
|
+
q.confirm = true
|
38
|
+
q.default = '.'
|
39
|
+
q.validate = /^[^\/].*$/
|
50
40
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
41
|
+
folder = Pathname(folder)
|
42
|
+
begin
|
43
|
+
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
44
|
+
rescue Errno::EEXIST
|
45
|
+
HILINE.say("<%= Paint['Error', 'red', :bold] %>: Insufficient Permissions")
|
46
|
+
exit 1
|
55
47
|
end
|
56
|
-
|
57
|
-
else
|
58
|
-
$stderr.puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
59
|
-
exit 1
|
48
|
+
path = Pathname(folder).realdirpath.join(filename)
|
60
49
|
end
|
50
|
+
File.open(path.to_path, 'a') do |fd|
|
51
|
+
answers.to_h = {:layout => 'page'}
|
52
|
+
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
53
|
+
fd.puts '---'
|
54
|
+
end
|
55
|
+
Mkmatter::Methods.launch_editor(options[:editor], path)
|
61
56
|
else
|
62
|
-
|
63
|
-
|
64
|
-
puts ''
|
65
|
-
puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
66
|
-
puts '---'
|
57
|
+
$stderr.puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
58
|
+
exit 1
|
67
59
|
end
|
68
60
|
end
|
69
61
|
|
@@ -75,94 +67,85 @@ module Mkmatter
|
|
75
67
|
long_desc Mkmatter::App::Descriptions::New::POST
|
76
68
|
|
77
69
|
def post
|
78
|
-
if
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
filename = [].concat([answers.slug_date, '-', answers.title.to_slug, '.', answers.file_format.downcase]).join
|
70
|
+
if Mkmatter::Methods.check_if_jekyll
|
71
|
+
# @questions = Mkmatter::Questions::Post.new(HILINE).ask
|
72
|
+
@questions = Mkmatter::Questions::Post.new.ask
|
73
|
+
answers = Mkmatter::Answers.new(@questions, options[:publish])
|
74
|
+
draft_folder = '_drafts'
|
75
|
+
filename = [].concat([answers.slug_date, '-', answers.title.to_slug, '.', answers.file_format.downcase]).join
|
85
76
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
folder = Pathname(folder)
|
97
|
-
begin
|
98
|
-
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
99
|
-
rescue Errno::EEXIST
|
100
|
-
HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
101
|
-
exit 1
|
102
|
-
end
|
103
|
-
path = Pathname(folder).realdirpath.join(filename)
|
77
|
+
path = Pathname("./#{file_folder}/#{filename}").realdirpath
|
78
|
+
if HILINE.agree('Would you like to put this page into a subdirectory?', true)
|
79
|
+
HILINE.say("What path? (directories will be created if they don't exist)")
|
80
|
+
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
81
|
+
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <%= color('Bad', 'red', :bold) %>: /absolute/paths/are/bad/mmkay")
|
82
|
+
folder = HILINE.ask('? ') do |q|
|
83
|
+
q.confirm = true
|
84
|
+
q.default = '.'
|
85
|
+
q.validate = /^[^\/].*$/
|
104
86
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
87
|
+
folder = Pathname(folder)
|
88
|
+
begin
|
89
|
+
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
90
|
+
rescue Errno::EEXIST
|
91
|
+
HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
92
|
+
exit 1
|
109
93
|
end
|
110
|
-
|
111
|
-
else
|
112
|
-
puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
113
|
-
exit 1
|
94
|
+
path = Pathname(folder).realdirpath.join(filename)
|
114
95
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
@questions = Mkmatter::Questions::Post.new.ask
|
120
|
-
answers = Mkmatter::Answers.new(@questions, options[:publish])
|
121
|
-
file_folder = '_posts'
|
122
|
-
filename = [].concat([answers.slug_date, '-', answers.title.to_slug, '.', answers.file_format.downcase]).join('')
|
123
|
-
path = Pathname("./#{file_folder}/#{filename}").realdirpath
|
124
|
-
if HILINE.agree('Would you like to put this post into a subdirectory?', true)
|
125
|
-
HILINE.say('What path?')
|
126
|
-
HILINE.say('----------------')
|
127
|
-
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
128
|
-
HILINE.say("If you enter a path you don't like, you will have manually remove it if you confirm it.")
|
129
|
-
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <% Paint['Bad', :red, :bold] %>: /root/paths/are/bad/mmkay")
|
130
|
-
folder = HILINE.ask('? ') do |q|
|
131
|
-
q.confirm = true
|
132
|
-
q.default = '.'
|
133
|
-
q.validate = /^[^\/].*$/
|
134
|
-
end
|
135
|
-
folder = Pathname("#{file_folder}/#{folder}")
|
136
|
-
begin
|
137
|
-
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
138
|
-
rescue Errno::EEXIST
|
139
|
-
HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
140
|
-
exit 1
|
141
|
-
end
|
142
|
-
path = Pathname(folder).realdirpath.join(filename)
|
143
|
-
end
|
144
|
-
File.open(path.to_path, 'a') do |fd|
|
145
|
-
answers.to_h = {:layout => 'post'}
|
146
|
-
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
147
|
-
fd.puts '---'
|
148
|
-
end
|
149
|
-
|
150
|
-
Mkmatter::Methods.launch_editor(options[:editor], path)
|
151
|
-
else
|
152
|
-
puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
153
|
-
exit 1
|
96
|
+
File.open(path.to_path, 'a') do |fd|
|
97
|
+
answers.to_h = {:layout => 'post'}
|
98
|
+
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
99
|
+
fd.puts '---'
|
154
100
|
end
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
puts ''
|
160
|
-
puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
161
|
-
puts '---'
|
162
|
-
|
101
|
+
Mkmatter::Methods.launch_editor(options[:editor], path)
|
102
|
+
else
|
103
|
+
puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
104
|
+
exit 1
|
163
105
|
end
|
164
106
|
end
|
165
107
|
end
|
166
108
|
end
|
167
109
|
end
|
168
110
|
end
|
111
|
+
elsif options[:draft].nil? or options[:draft] == false
|
112
|
+
|
113
|
+
# if Mkmatter::Methods.check_if_jekyll
|
114
|
+
# # @questions = Mkmatter::Questions::Post.new(HILINE).ask
|
115
|
+
# @questions = Mkmatter::Questions::Post.new.ask
|
116
|
+
# answers = Mkmatter::Answers.new(@questions, options[:publish])
|
117
|
+
# file_folder = '_posts'
|
118
|
+
# filename = [].concat([answers.slug_date, '-', answers.title.to_slug, '.', answers.file_format.downcase]).join('')
|
119
|
+
# path = Pathname("./#{file_folder}/#{filename}").realdirpath
|
120
|
+
# if HILINE.agree('Would you like to put this post into a subdirectory?', true)
|
121
|
+
# HILINE.say('What path?')
|
122
|
+
# HILINE.say('----------------')
|
123
|
+
# HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
124
|
+
# HILINE.say("If you enter a path you don't like, you will have manually remove it if you confirm it.")
|
125
|
+
# HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <% Paint['Bad', :red, :bold] %>: /root/paths/are/bad/mmkay")
|
126
|
+
# folder = HILINE.ask('? ') do |q|
|
127
|
+
# q.confirm = true
|
128
|
+
# q.default = '.'
|
129
|
+
# q.validate = /^[^\/].*$/
|
130
|
+
# end
|
131
|
+
# folder = Pathname("#{file_folder}/#{folder}")
|
132
|
+
# begin
|
133
|
+
# FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
134
|
+
# rescue Errno::EEXIST
|
135
|
+
# HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
136
|
+
# exit 1
|
137
|
+
# end
|
138
|
+
# path = Pathname(folder).realdirpath.join(filename)
|
139
|
+
# end
|
140
|
+
# File.open(path.to_path, 'a') do |fd|
|
141
|
+
# answers.to_h = {:layout => 'post'}
|
142
|
+
# fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
143
|
+
# fd.puts '---'
|
144
|
+
# end
|
145
|
+
|
146
|
+
# Mkmatter::Methods.launch_editor(options[:editor], path)
|
147
|
+
# else
|
148
|
+
# puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
149
|
+
# exit 1
|
150
|
+
# end
|
151
|
+
# end
|
data/lib/mkmatter/questions.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'highline'
|
2
|
+
require 'highline/color'
|
2
3
|
require 'ostruct'
|
3
4
|
module Mkmatter
|
4
5
|
module Questions
|
@@ -14,8 +15,6 @@ module Mkmatter
|
|
14
15
|
|
15
16
|
class Post
|
16
17
|
attr :answers
|
17
|
-
attr :extra_fields
|
18
|
-
@extra_fields = nil
|
19
18
|
@hl = HighLine.new
|
20
19
|
|
21
20
|
def ask
|
@@ -110,7 +109,7 @@ module Mkmatter
|
|
110
109
|
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
111
110
|
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
112
111
|
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
113
|
-
hl.say("<%
|
112
|
+
hl.say("<% color('NOTE', :bold, :red) %>: Input is <% color('NOT', :bold, :red) %> evaluated!")
|
114
113
|
custom_fields = hl.ask('Fields?') do |q|
|
115
114
|
q.gather = /^EOL$/
|
116
115
|
end
|
@@ -121,7 +120,7 @@ module Mkmatter
|
|
121
120
|
field = field.split(/=>/)
|
122
121
|
fields.store(field[0].to_s, field[1])
|
123
122
|
end
|
124
|
-
|
123
|
+
|
125
124
|
elsif custom_fields.nil?
|
126
125
|
hl.say('No extra fields were added.')
|
127
126
|
return
|
@@ -133,8 +132,6 @@ module Mkmatter
|
|
133
132
|
end
|
134
133
|
class Page
|
135
134
|
attr :answers
|
136
|
-
attr :extra_fields
|
137
|
-
@extra_fields = nil
|
138
135
|
@hl = HighLine.new
|
139
136
|
|
140
137
|
def ask
|
data/lib/mkmatter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkmatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|