mkmatter 3.1.16 → 3.1.17
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/.ruby-version +1 -1
- data/README.md +32 -11
- data/bin/console +15 -15
- data/bin/mkmatter +7 -7
- data/bin/setup +6 -6
- data/lib/mkmatter/answers.rb +46 -15
- data/lib/mkmatter/cli/app.rb +109 -56
- data/lib/mkmatter/cli/descriptions.rb +17 -12
- data/lib/mkmatter/cli/subs/new.rb +63 -106
- data/lib/mkmatter/cli/subs.rb +0 -1
- data/lib/mkmatter/helpers.rb +89 -0
- data/lib/mkmatter/questions.rb +114 -221
- data/lib/mkmatter/version.rb +1 -1
- data/mkmatter.gemspec +62 -63
- data/spec/class_option_spec.rb +2 -2
- data/spec/descriptions_spec.rb +3 -5
- data/spec/questions_spec.rb +48 -68
- data/spec/spec_helper.rb +1 -0
- metadata +46 -61
@@ -1,113 +1,70 @@
|
|
1
|
-
require 'highline'
|
2
|
-
require 'thor'
|
3
|
-
require 'mkmatter/cli/descriptions'
|
4
|
-
require 'mkmatter/cli/methods'
|
5
|
-
require 'mkmatter/questions'
|
6
|
-
require 'mkmatter/answers'
|
7
|
-
module Mkmatter
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# require 'highline'
|
2
|
+
# require 'thor'
|
3
|
+
# require 'mkmatter/cli/descriptions'
|
4
|
+
# require 'mkmatter/cli/methods'
|
5
|
+
# require 'mkmatter/questions'
|
6
|
+
# require 'mkmatter/answers'
|
7
|
+
# module Mkmatter
|
8
|
+
# module App
|
9
|
+
# module Classes
|
10
|
+
# # Generate 'New' Content
|
11
|
+
# class NewContent < Thor
|
12
|
+
# include Thor::Actions
|
13
|
+
# HILINE = HighLine.new($stdin, $stderr, 40)
|
14
|
+
# option :publish, :type => :boolean
|
15
|
+
# option :file, :type => :boolean, :default => true
|
16
|
+
# option :index, :type => :boolean, :default => nil
|
17
|
+
# method_options %w( template -t ) => :boolean
|
18
|
+
# desc 'page [options]', 'make front matter (and possibly content) for a jekyll page'
|
19
|
+
# long_desc Mkmatter::App::Descriptions::New::PAGE
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
# def page
|
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
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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 = /^[^\/].*$/
|
40
|
+
# end
|
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
|
47
|
+
# end
|
48
|
+
# path = Pathname(folder).realdirpath.join(filename)
|
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)
|
56
|
+
# else
|
57
|
+
# $stderr.puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
58
|
+
# exit 1
|
59
|
+
# end
|
60
|
+
# end
|
61
61
|
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
def post
|
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
|
76
|
-
|
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 = /^[^\/].*$/
|
86
|
-
end
|
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
|
93
|
-
end
|
94
|
-
path = Pathname(folder).realdirpath.join(filename)
|
95
|
-
end
|
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 '---'
|
100
|
-
end
|
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
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
63
|
+
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# end
|
111
68
|
# elsif options[:draft].nil? or options[:draft] == false
|
112
69
|
|
113
70
|
# if Mkmatter::Methods.check_if_jekyll
|
data/lib/mkmatter/cli/subs.rb
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
def get_time_zone_full(time_object)
|
2
|
+
require 'tzinfo'
|
3
|
+
offset = time_object.utc_offset
|
4
|
+
if offset.is_a?(Integer)
|
5
|
+
offset = offset / 3600 # Convert seconds to hours
|
6
|
+
elsif offset.is_a?(String) && offset.include?(':')
|
7
|
+
# If the offset is in the format "+HH:MM" or "-HH:MM"
|
8
|
+
parts = offset.split(':')
|
9
|
+
offset = parts[0].to_i + (parts[1].to_i / 60.0)
|
10
|
+
|
11
|
+
elsif offset.is_a?(String) && offset.length == 1
|
12
|
+
# Single character offset, e.g. "Z" for UTC, or "A" for UTC-1
|
13
|
+
# Not commonly used, but handling it for completeness
|
14
|
+
case offset.upcase
|
15
|
+
when 'Z'
|
16
|
+
offset = '+0000' # UTC
|
17
|
+
when 'A'
|
18
|
+
offset = '+0100' # UTC+1
|
19
|
+
when 'B'
|
20
|
+
offset = '+0200' # UTC+2
|
21
|
+
when 'C'
|
22
|
+
offset = '+0300' # UTC+3
|
23
|
+
when 'D'
|
24
|
+
offset = '+0400' # UTC+4
|
25
|
+
when 'E'
|
26
|
+
offset = '+0500' # UTC+5
|
27
|
+
when 'F'
|
28
|
+
offset = '+0600' # UTC+6
|
29
|
+
when 'G'
|
30
|
+
offset = '+0700' # UTC+7
|
31
|
+
when 'H'
|
32
|
+
offset = '+0800' # UTC+8
|
33
|
+
when 'I'
|
34
|
+
offset = '+0900' # UTC+9
|
35
|
+
when 'K'
|
36
|
+
offset = '+1000' # UTC+10
|
37
|
+
when 'L'
|
38
|
+
offset = '+1100' # UTC+11
|
39
|
+
when 'M'
|
40
|
+
offset = '+1200' # UTC+12
|
41
|
+
when 'N'
|
42
|
+
offset = '-0100' # UTC-1
|
43
|
+
when 'O'
|
44
|
+
offset = '-0200' # UTC-2
|
45
|
+
when 'P'
|
46
|
+
offset = '-0300' # UTC-3
|
47
|
+
when 'Q'
|
48
|
+
# US Eastern Time
|
49
|
+
# US Eastern Time is UTC-4, but it can also be UTC-5 during Daylight Saving Time
|
50
|
+
offset = '-0400' # UTC-4
|
51
|
+
return 'Eastern Time (US & Canada)' if time_object.zone == 'EDT' || time_object.zone == 'EST'
|
52
|
+
when 'R' # US Central Time
|
53
|
+
# US Central Time is UTC-5, but it can also be UTC-6 during Daylight Saving Time
|
54
|
+
offset = '-0500' # UTC-5
|
55
|
+
return 'Central Time (US & Canada)' if time_object.zone == 'CDT' || time_object.zone == 'CST'
|
56
|
+
when 'S'
|
57
|
+
# US Mountain Time
|
58
|
+
# US Mountain Time is UTC-6, but it can also be UTC-7 during Daylight Saving Time
|
59
|
+
offset = '-0600' # UTC-6
|
60
|
+
return 'Mountain Time (US & Canada)' if time_object.zone == 'MDT' || time_object.zone == 'MST'
|
61
|
+
when 'T'
|
62
|
+
# US Pacific Time
|
63
|
+
# US Pacific Time is UTC-7, but it can also be UTC-8 during Daylight Saving Time
|
64
|
+
offset = '-0700' # UTC-7
|
65
|
+
return 'Pacific Time (US & Canada)' if time_object.zone == 'PDT' || time_object.zone == 'PST'
|
66
|
+
when 'U'
|
67
|
+
# US Alaska Time
|
68
|
+
# US Alaska Time is UTC-8, but it can also be UTC-9 during Daylight Saving Time
|
69
|
+
offset = '-0800' # UTC-8
|
70
|
+
return 'Alaska Time (US & Canada)' if time_object.zone == 'AKDT' || time_object.zone == 'AKST'
|
71
|
+
when 'V'
|
72
|
+
# US Hawaii-Aleutian Time
|
73
|
+
# US Hawaii-Aleutian Time is UTC-9, but it can also be UTC-10 during Daylight Saving Time
|
74
|
+
# Note: Hawaii does not observe Daylight Saving Time
|
75
|
+
offset = '-0900' # UTC-9
|
76
|
+
when 'W'
|
77
|
+
offset = '-1000' # UTC-10
|
78
|
+
when 'X'
|
79
|
+
offset = '-1100' # UTC-11
|
80
|
+
when 'Y'
|
81
|
+
offset = '-1200' # UTC-12
|
82
|
+
else
|
83
|
+
raise ArgumentError, "Invalid time zone offset character: #{offset}"
|
84
|
+
end
|
85
|
+
else
|
86
|
+
raise ArgumentError, "Invalid time zone offset format: #{offset}"
|
87
|
+
end
|
88
|
+
# puts "Offset: #{offset}"
|
89
|
+
end
|
data/lib/mkmatter/questions.rb
CHANGED
@@ -1,250 +1,143 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
module Mkmatter
|
4
|
-
module Questions
|
5
|
-
def self.ask(cls)
|
1
|
+
require "highline"
|
2
|
+
require "ostruct"
|
6
3
|
|
7
|
-
|
4
|
+
module Mkmatter
|
5
|
+
class Questions
|
6
|
+
attr :answers
|
7
|
+
@hl = HighLine.new
|
8
|
+
# def self.ask(cls)
|
9
|
+
# known_questions = const_get(cls).methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
10
|
+
# known_questions.each do |m|
|
11
|
+
# @answers[:layout] = cls.to_s.lower
|
12
|
+
# @answers[m.to_s.gsub(/^get_[0-9]{3}_/, "")] = method(m).call
|
13
|
+
# end
|
14
|
+
# @answers
|
15
|
+
# end
|
16
|
+
|
17
|
+
def ask(type, include_post_qs)
|
18
|
+
known_questions = methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
19
|
+
if type != "post"
|
20
|
+
if include_post_qs
|
21
|
+
else
|
22
|
+
post_only_questions = [
|
23
|
+
:get_002_tags,
|
24
|
+
:get_003_categories,
|
25
|
+
:get_006_summary,
|
26
|
+
]
|
27
|
+
2.times do
|
28
|
+
for q in known_questions
|
29
|
+
if post_only_questions.include?(q)
|
30
|
+
known_questions.delete(q)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# puts known_questions
|
36
|
+
end
|
8
37
|
known_questions.each do |m|
|
9
|
-
@answers[:layout] =
|
10
|
-
@answers[m.to_s.gsub(/^get_[0-9]{3}_/,
|
38
|
+
@answers[:layout] = type
|
39
|
+
@answers[m.to_s.gsub(/^get_[0-9]{3}_/, "")] = method(m).call
|
11
40
|
end
|
12
41
|
@answers
|
13
42
|
end
|
14
43
|
|
15
|
-
|
16
|
-
|
44
|
+
# @!visibility private
|
45
|
+
def initialize
|
46
|
+
@answers = OpenStruct.new
|
17
47
|
@hl = HighLine.new
|
48
|
+
end
|
18
49
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
# @!visibility private
|
29
|
-
def initialize
|
30
|
-
@answers = OpenStruct.new
|
31
|
-
@hl = HighLine.new
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_001_title
|
35
|
-
hl = @hl
|
36
|
-
title = hl.ask 'Title: '
|
37
|
-
if hl.agree("Would you like it 'titleized' (Title instead of title)? ")
|
38
|
-
title.titleize
|
39
|
-
else
|
40
|
-
title
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Array]
|
45
|
-
def get_002_tags
|
46
|
-
hl = @hl
|
47
|
-
hl.ask("Tags? (write one on each line, then type '.') ") do |q|
|
48
|
-
q.gather = '.'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# @return [Array]
|
53
|
-
def get_003_categories
|
54
|
-
hl = @hl
|
55
|
-
hl.ask("Categories? (write one on each line, then type '.') ") do |q|
|
56
|
-
q.gather = '.'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [String]
|
61
|
-
def get_004_time_zone
|
62
|
-
hl = @hl
|
63
|
-
custom = nil
|
64
|
-
timezone = hl.choose do |m|
|
65
|
-
m.header = 'Time Zone? (select by number)'
|
66
|
-
m.choice('Eastern Time (US & Canada)') do
|
67
|
-
return 'Eastern Time (US & Canada)'
|
68
|
-
end
|
69
|
-
m.choice('Central Time (US & Canada)') do
|
70
|
-
return 'Central Time (US & Canada)'
|
71
|
-
end
|
72
|
-
m.choice :neither
|
73
|
-
m.prompt = '? '
|
74
|
-
end
|
75
|
-
custom = hl.ask('Other Time Zone: ', String) if timezone == :neither
|
76
|
-
return unless custom
|
77
|
-
|
78
|
-
hl.say('Checking TimeZone Validity')
|
79
|
-
print '.'
|
80
|
-
sleep(0.05)
|
81
|
-
5.times do
|
82
|
-
print '.'
|
83
|
-
sleep(0.05)
|
84
|
-
puts ''
|
85
|
-
TimeZone.find_tzinfo custom
|
86
|
-
end
|
87
|
-
custom
|
88
|
-
end
|
89
|
-
|
90
|
-
# @return [String]
|
91
|
-
def get_005_file_format
|
92
|
-
hl = @hl
|
93
|
-
hl.choose do |menu|
|
94
|
-
menu.header = 'Choose whether you want HTML or Markdown'
|
95
|
-
menu.choice 'html' do
|
96
|
-
return 'html'
|
97
|
-
end
|
98
|
-
menu.choice 'md' do
|
99
|
-
return 'md'
|
100
|
-
end
|
101
|
-
menu.prompt = '? '
|
102
|
-
end
|
103
|
-
end
|
104
|
-
# @return [String]
|
105
|
-
def get_006_extra_fields
|
106
|
-
hl = @hl
|
107
|
-
custom_fields = nil
|
108
|
-
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
109
|
-
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
110
|
-
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
111
|
-
hl.say("<% color('NOTE', :bold, :red) %>: Input is <% color('NOT', :bold, :red) %> evaluated!")
|
112
|
-
custom_fields = hl.ask('Fields?') do |q|
|
113
|
-
q.gather = /^EOL$/
|
114
|
-
end
|
115
|
-
end
|
116
|
-
if custom_fields
|
117
|
-
fields = Hash.new
|
118
|
-
custom_fields.each do |field|
|
119
|
-
field = field.split(/=>/)
|
120
|
-
fields.store(field[0].to_s, field[1])
|
121
|
-
end
|
122
|
-
|
123
|
-
elsif custom_fields.nil?
|
124
|
-
hl.say('No extra fields were added.')
|
125
|
-
return
|
126
|
-
else
|
127
|
-
end
|
128
|
-
custom_fields
|
50
|
+
def get_001_title
|
51
|
+
hl = @hl
|
52
|
+
title = hl.ask "Title: "
|
53
|
+
if hl.agree("Would you like it 'titleized' (Title instead of title)? ", true)
|
54
|
+
title.titleize
|
55
|
+
else
|
56
|
+
title
|
129
57
|
end
|
130
|
-
# @return [OpenStruct]
|
131
58
|
end
|
132
|
-
class Page
|
133
|
-
attr :answers
|
134
|
-
@hl = HighLine.new
|
135
59
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
@answers
|
60
|
+
# @return [Array]
|
61
|
+
def get_002_tags
|
62
|
+
hl = @hl
|
63
|
+
hl.ask("Tags? (write one on each line, then press '.' then press 'Enter')") do |q|
|
64
|
+
q.gather = '.'
|
143
65
|
end
|
66
|
+
end
|
144
67
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
68
|
+
# @return [Array]
|
69
|
+
def get_003_categories
|
70
|
+
hl = @hl
|
71
|
+
hl.ask("Categories? (write one on each line, then press '.' then press 'Enter')") do |q|
|
72
|
+
q.gather = '.'
|
149
73
|
end
|
74
|
+
end
|
150
75
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
76
|
+
# @return [String]
|
77
|
+
def get_004_file_format
|
78
|
+
hl = @hl
|
79
|
+
hl.choose do |menu|
|
80
|
+
menu.header = "Choose whether you want HTML or Markdown"
|
81
|
+
menu.choice "html" do
|
82
|
+
return "html"
|
158
83
|
end
|
159
|
-
|
160
|
-
|
161
|
-
# @return [Array]
|
162
|
-
def get_002_tags
|
163
|
-
hl = @hl
|
164
|
-
hl.ask("Tags? (write one on each line, then type '.') ") do |q|
|
165
|
-
q.gather = '.'
|
84
|
+
menu.choice "md" do
|
85
|
+
return "md"
|
166
86
|
end
|
87
|
+
menu.prompt = "? "
|
167
88
|
end
|
89
|
+
end
|
168
90
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
91
|
+
# @return [String]
|
92
|
+
def get_005_extra_fields
|
93
|
+
hl = @hl
|
94
|
+
fields = {}
|
95
|
+
custom_fields = nil
|
96
|
+
cfh = nil
|
97
|
+
if hl.agree("Do you want to add custom fields? ", true)
|
98
|
+
hl.say(<<~EXTRA_FIELDS)
|
99
|
+
These fields will be usable as {{LAYOUT_TYPE.FIELD}} in pages/posts etc.
|
100
|
+
Your fields should be inputted as FIELD=>TEXT HERE
|
101
|
+
Type 'EOL' on a new line then press Enter when you are done.
|
102
|
+
<%= color('NOTE', :bold, RED) %>: Input is <%= color('NOT', :bold, RED) %> evaluated!
|
103
|
+
EXTRA_FIELDS
|
104
|
+
custom_fields = hl.ask("Fields?") do |q|
|
173
105
|
q.gather = '.'
|
174
106
|
end
|
175
107
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
hl = @hl
|
180
|
-
custom = nil
|
181
|
-
timezone = hl.choose do |m|
|
182
|
-
m.header = 'Time Zone? (select by number)'
|
183
|
-
m.choice('Eastern Time (US & Canada)') do
|
184
|
-
return 'Eastern Time (US & Canada)'
|
185
|
-
end
|
186
|
-
m.choice('Central Time (US & Canada)') do
|
187
|
-
return 'Central Time (US & Canada)'
|
188
|
-
end
|
189
|
-
m.choice :neither
|
190
|
-
m.prompt = '? '
|
108
|
+
if !custom_fields.empty?
|
109
|
+
custom_fields.each do |field|
|
110
|
+
fields.store(field.to_sym, 'nil')
|
191
111
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
sleep(0.05)
|
201
|
-
puts ''
|
202
|
-
TimeZone.find_tzinfo custom
|
112
|
+
end
|
113
|
+
if custom_fields.empty?
|
114
|
+
hl.say("No extra fields were added.")
|
115
|
+
return
|
116
|
+
else
|
117
|
+
hl.say("#{fields} #{fields.class}")
|
118
|
+
cfh = hl.ask("Value of field '<%= key %>'?") do |q|
|
119
|
+
q.gather = fields
|
203
120
|
end
|
204
|
-
custom
|
205
121
|
end
|
122
|
+
cfh
|
123
|
+
end
|
206
124
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
hl = @hl
|
224
|
-
custom_fields = nil
|
225
|
-
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
226
|
-
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
227
|
-
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
228
|
-
hl.say("<% HighLine.color('NOTE', :bold, :red) %>: Input is <% HighLine.color('NOT', :bold, :red) %> evaluated!")
|
229
|
-
custom_fields = hl.ask('Fields?') do |q|
|
230
|
-
q.gather = /^EOL$/
|
231
|
-
end
|
232
|
-
end
|
233
|
-
if custom_fields
|
234
|
-
fields = Hash.new
|
235
|
-
custom_fields.each do |field|
|
236
|
-
field = field.split(/=>/)
|
237
|
-
fields.store(field[0].to_s, field[1])
|
238
|
-
end
|
239
|
-
self.extra_fields = fields
|
240
|
-
elsif custom_fields.nil?
|
241
|
-
hl.say('No extra fields were added.')
|
242
|
-
return
|
243
|
-
else
|
244
|
-
end
|
245
|
-
custom_fields
|
246
|
-
end
|
247
|
-
# @return [OpenStruct]
|
125
|
+
# @return [OpenStruct]
|
126
|
+
def get_006_summary
|
127
|
+
hl = @hl
|
128
|
+
summary = nil
|
129
|
+
summary_if = hl.agree("Summary? ", true)
|
130
|
+
if summary_if
|
131
|
+
summary = hl.ask(<<~SUMMARYDOC) do |q|
|
132
|
+
Input a summary of the post.
|
133
|
+
This will be outputted as a summary in the front matter.
|
134
|
+
This is useful for a post that is long and you want to
|
135
|
+
show a summary of the post.
|
136
|
+
SUMMARYDOC
|
137
|
+
q.gather = "."
|
138
|
+
end
|
139
|
+
end
|
140
|
+
summary.join("\n")
|
248
141
|
end
|
249
142
|
end
|
250
143
|
end
|
data/lib/mkmatter/version.rb
CHANGED