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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90665a1c1eabe3028319ef3fdbde4770ebe1eeb22273bb6aa421a10a37455825
4
- data.tar.gz: 7a8806195aee81dcacdc0e06895cf9873fe8b0db37f4fdd4a109b4aadc1369ed
3
+ metadata.gz: ee1ddb005d017b3ff2770792c609726b0781a610438ded6478fe341fd80fd0c6
4
+ data.tar.gz: 0c0e8e5e6d8a90ad22ec76f55c4e16d04d5ed088a029fc2ecb6e9ed58eb26364
5
5
  SHA512:
6
- metadata.gz: 0abe5786bea69019220f0b1248729602effcae72161f0b2f2f65f271c7508d396deb1c06b60c37d57ebf6080daa3fb7dfeb30fbba2aa5e697b16f084b9d30168
7
- data.tar.gz: b954bf3927f4ce7306c3b9a3e95f2232ccfd0ad639fdf9edb82af65a1b30dc105ee724fdd3f801fe145c736effb1564644c7b331f1b39cfb6c3b2c3910f95ec3
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 options[:file]
23
- if Mkmatter::Methods.check_if_jekyll
24
- @questions = Mkmatter::Questions::Page.new(HILINE).ask
25
- answers = Mkmatter::Answers.new(@questions, options.fetch(:publish, nil))
26
- if options.fetch(:index, nil)
27
- filename = 'index.' + answers.file_format.downcase
28
- else
29
- filename = answers.title.to_slug + '.' + answers.file_format.downcase
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
- path = Pathname("./#{filename}").realdirpath
33
- if HILINE.agree('Would you like to put this page into a subdirectory?', true)
34
- HILINE.say("What path? (directories will be created if they don't exist) ")
35
- HILINE.say("Don't use a path starting with a slash, just put a relative path.")
36
- HILINE.say('good => path/to/dir ‖ bad => /absolute/paths/are/bad/mmkay')
37
- folder = HILINE.ask('? ') do |q|
38
- q.confirm = true
39
- q.default = '.'
40
- q.validate = /^[^\/].*$/
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
- File.open(path.to_path, 'a') do |fd|
52
- answers.to_h = {:layout => 'page'}
53
- fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
54
- fd.puts '---'
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
- Mkmatter::Methods.launch_editor(options[:editor], path)
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
- @questions = Mkmatter::Questions::Page.new(HILINE).ask
63
- answers = Mkmatter::Answers.new(@questions, options.fetch(:publish, nil))
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 options[:draft] and options[:file]
79
- if Mkmatter::Methods.check_if_jekyll
80
- # @questions = Mkmatter::Questions::Post.new(HILINE).ask
81
- @questions = Mkmatter::Questions::Post.new.ask
82
- answers = Mkmatter::Answers.new(@questions, options[:publish])
83
- file_folder = '_drafts'
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
- path = Pathname("./#{file_folder}/#{filename}").realdirpath
87
- if HILINE.agree('Would you like to put this page into a subdirectory?', true)
88
- HILINE.say("What path? (directories will be created if they don't exist)")
89
- HILINE.say("Don't use a path starting with a slash, just put a relative path.")
90
- HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <%= color('Bad', 'red', :bold) %>: /absolute/paths/are/bad/mmkay")
91
- folder = HILINE.ask('? ') do |q|
92
- q.confirm = true
93
- q.default = '.'
94
- q.validate = /^[^\/].*$/
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
- File.open(path.to_path, 'a') do |fd|
106
- answers.to_h = {:layout => 'post'}
107
- fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
108
- fd.puts '---'
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
- Mkmatter::Methods.launch_editor(options[:editor], path)
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
- elsif options[:file] and options[:draft].nil? or options[:draft] == false
116
-
117
- if Mkmatter::Methods.check_if_jekyll
118
- # @questions = Mkmatter::Questions::Post.new(HILINE).ask
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
- elsif options[:draft].nil? and options[:file].nil?
156
- @questions = Mkmatter::Questions::Post.new.ask
157
- # @questions = Mkmatter::Questions::Post.new(HILINE).ask
158
- answers = Mkmatter::Answers.new(@questions, options[:publish])
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
@@ -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("<% HighLine.color('NOTE', :bold, :red) %>: Input is <% HighLine.color('NOT', :bold, :red) %> evaluated!")
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
- self.extra_fields = fields
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
@@ -1,5 +1,5 @@
1
1
  module Mkmatter
2
- VERSION = '3.1.13'
2
+ VERSION = '3.1.14'
3
3
 
4
4
  # Return gem information for certain commands and options
5
5
  class GemInfo
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.13
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-04-30 00:00:00.000000000 Z
11
+ date: 2025-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline