bunto 3.0.0 → 3.2.1
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/.rubocop.yml +124 -76
- data/README.markdown +49 -12
- data/{bin → exe}/bunto +18 -14
- data/lib/bunto.rb +83 -78
- data/lib/bunto/cleaner.rb +10 -8
- data/lib/bunto/collection.rb +33 -17
- data/lib/bunto/command.rb +19 -13
- data/lib/bunto/commands/build.rb +22 -14
- data/lib/bunto/commands/clean.rb +9 -8
- data/lib/bunto/commands/doctor.rb +10 -8
- data/lib/bunto/commands/help.rb +4 -3
- data/lib/bunto/commands/new.rb +30 -21
- data/lib/bunto/commands/new_theme.rb +36 -0
- data/lib/bunto/commands/serve.rb +26 -20
- data/lib/bunto/commands/serve/servlet.rb +4 -5
- data/lib/bunto/configuration.rb +187 -125
- data/lib/bunto/converters/markdown.rb +19 -9
- data/lib/bunto/converters/markdown/kramdown_parser.rb +12 -5
- data/lib/bunto/converters/markdown/rdiscount_parser.rb +4 -4
- data/lib/bunto/converters/markdown/redcarpet_parser.rb +90 -84
- data/lib/bunto/convertible.rb +38 -25
- data/lib/bunto/deprecator.rb +11 -6
- data/lib/bunto/desktop.ini +2 -0
- data/lib/bunto/document.rb +53 -51
- data/lib/bunto/drops/bunto_drop.rb +12 -0
- data/lib/bunto/drops/document_drop.rb +40 -5
- data/lib/bunto/drops/drop.rb +49 -10
- data/lib/bunto/drops/excerpt_drop.rb +15 -0
- data/lib/bunto/drops/site_drop.rb +4 -2
- data/lib/bunto/drops/url_drop.rb +4 -4
- data/lib/bunto/entry_filter.rb +64 -19
- data/lib/bunto/errors.rb +6 -3
- data/lib/bunto/excerpt.rb +4 -6
- data/lib/bunto/external.rb +4 -4
- data/lib/bunto/filters.rb +72 -39
- data/lib/bunto/frontmatter_defaults.rb +45 -38
- data/lib/bunto/hooks.rb +21 -21
- data/lib/bunto/layout.rb +4 -8
- data/lib/bunto/liquid_renderer.rb +14 -3
- data/lib/bunto/liquid_renderer/file.rb +5 -1
- data/lib/bunto/liquid_renderer/table.rb +11 -11
- data/lib/bunto/log_adapter.rb +2 -2
- data/lib/bunto/page.rb +10 -10
- data/lib/bunto/plugin.rb +5 -5
- data/lib/bunto/plugin_manager.rb +12 -8
- data/lib/bunto/publisher.rb +1 -1
- data/lib/bunto/reader.rb +11 -7
- data/lib/bunto/readers/data_reader.rb +9 -9
- data/lib/bunto/readers/layout_reader.rb +7 -7
- data/lib/bunto/readers/page_reader.rb +3 -1
- data/lib/bunto/readers/post_reader.rb +9 -10
- data/lib/bunto/readers/static_file_reader.rb +3 -1
- data/lib/bunto/regenerator.rb +50 -28
- data/lib/bunto/related_posts.rb +1 -1
- data/lib/bunto/renderer.rb +33 -23
- data/lib/bunto/site.rb +94 -51
- data/lib/bunto/static_file.rb +33 -26
- data/lib/bunto/stevenson.rb +6 -5
- data/lib/bunto/tags/highlight.rb +50 -35
- data/lib/bunto/tags/include.rb +42 -31
- data/lib/bunto/tags/link.rb +11 -4
- data/lib/bunto/tags/post_url.rb +8 -7
- data/lib/bunto/theme.rb +10 -8
- data/lib/bunto/theme_builder.rb +117 -0
- data/lib/bunto/url.rb +21 -14
- data/lib/bunto/utils.rb +57 -28
- data/lib/bunto/utils/ansi.rb +9 -9
- data/lib/bunto/utils/platforms.rb +2 -2
- data/lib/bunto/version.rb +1 -1
- data/lib/site_template/_config.yml +3 -1
- data/lib/site_template/_posts/0000-00-00-welcome-to-bunto.markdown.erb +3 -3
- data/lib/site_template/about.md +3 -3
- data/lib/site_template/css/main.scss +3 -17
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
- data/lib/theme_template/Gemfile +2 -0
- data/lib/theme_template/LICENSE.txt.erb +21 -0
- data/lib/theme_template/README.md.erb +48 -0
- data/lib/theme_template/_layouts/default.html +1 -0
- data/lib/theme_template/_layouts/page.html +5 -0
- data/lib/theme_template/_layouts/post.html +5 -0
- data/lib/theme_template/example/_config.yml.erb +1 -0
- data/lib/theme_template/example/_post.md +12 -0
- data/lib/theme_template/example/index.html +14 -0
- data/lib/theme_template/example/style.scss +7 -0
- data/lib/theme_template/gitignore.erb +4 -0
- data/lib/theme_template/theme.gemspec.erb +18 -0
- metadata +40 -19
- data/lib/site_template/_includes/footer.html +0 -38
- data/lib/site_template/_includes/head.html +0 -12
- data/lib/site_template/_includes/header.html +0 -27
- data/lib/site_template/_includes/icon-github.html +0 -1
- data/lib/site_template/_includes/icon-github.svg +0 -1
- data/lib/site_template/_includes/icon-twitter.html +0 -1
- data/lib/site_template/_includes/icon-twitter.svg +0 -1
- data/lib/site_template/_layouts/default.html +0 -20
- data/lib/site_template/_layouts/page.html +0 -14
- data/lib/site_template/_layouts/post.html +0 -15
- data/lib/site_template/_sass/_base.scss +0 -200
- data/lib/site_template/_sass/_layout.scss +0 -242
- data/lib/site_template/_sass/_syntax-highlighting.scss +0 -71
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
|
|
3
|
+
class Bunto::Commands::NewTheme < Bunto::Command
|
|
4
|
+
class << self
|
|
5
|
+
def init_with_program(prog)
|
|
6
|
+
prog.command(:"new-theme") do |c|
|
|
7
|
+
c.syntax "new-theme NAME"
|
|
8
|
+
c.description "Creates a new Bunto theme scaffold"
|
|
9
|
+
c.option "code_of_conduct", \
|
|
10
|
+
"-c", "--code-of-conduct", \
|
|
11
|
+
"Include a Code of Conduct. (defaults to false)"
|
|
12
|
+
|
|
13
|
+
c.action do |args, opts|
|
|
14
|
+
Bunto::Commands::NewTheme.process(args, opts)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def process(args, opts)
|
|
20
|
+
if !args || args.empty?
|
|
21
|
+
raise Bunto::Errors::InvalidThemeName, "You must specify a theme name."
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
new_theme_name = args.join("_")
|
|
25
|
+
theme = Bunto::ThemeBuilder.new(new_theme_name, opts)
|
|
26
|
+
if theme.path.exist?
|
|
27
|
+
Bunto.logger.abort_with "Conflict:", "#{theme.path} already exists."
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
theme.create!
|
|
31
|
+
Bunto.logger.info "Your new Bunto theme, #{theme.name}," \
|
|
32
|
+
" is ready for you in #{theme.path}!"
|
|
33
|
+
Bunto.logger.info "For help getting started, read #{theme.path}/README.md."
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/bunto/commands/serve.rb
CHANGED
|
@@ -3,18 +3,17 @@ module Bunto
|
|
|
3
3
|
class Serve < Command
|
|
4
4
|
class << self
|
|
5
5
|
COMMAND_OPTIONS = {
|
|
6
|
-
"ssl_cert"
|
|
7
|
-
"host"
|
|
8
|
-
"open_url"
|
|
9
|
-
"detach"
|
|
10
|
-
"ssl_key"
|
|
11
|
-
"port"
|
|
12
|
-
"
|
|
13
|
-
"show_dir_listing" => ["--show-dir-listing",
|
|
6
|
+
"ssl_cert" => ["--ssl-cert [CERT]", "X.509 (SSL) certificate."],
|
|
7
|
+
"host" => ["host", "-H", "--host [HOST]", "Host to bind to"],
|
|
8
|
+
"open_url" => ["-o", "--open-url", "Launch your site in a browser"],
|
|
9
|
+
"detach" => ["-B", "--detach", "Run the server in the background"],
|
|
10
|
+
"ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
|
|
11
|
+
"port" => ["-P", "--port [PORT]", "Port to listen on"],
|
|
12
|
+
"show_dir_listing" => ["--show-dir-listing",
|
|
14
13
|
"Show a directory listing instead of loading your index file."],
|
|
15
14
|
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
|
|
16
15
|
"Skips the initial site build which occurs before the server is started."]
|
|
17
|
-
}
|
|
16
|
+
}.freeze
|
|
18
17
|
|
|
19
18
|
#
|
|
20
19
|
|
|
@@ -33,7 +32,9 @@ module Bunto
|
|
|
33
32
|
cmd.action do |_, opts|
|
|
34
33
|
opts["serving"] = true
|
|
35
34
|
opts["watch" ] = true unless opts.key?("watch")
|
|
35
|
+
config = opts["config"]
|
|
36
36
|
Build.process(opts)
|
|
37
|
+
opts["config"] = config
|
|
37
38
|
Serve.process(opts)
|
|
38
39
|
end
|
|
39
40
|
end
|
|
@@ -93,7 +94,7 @@ module Bunto
|
|
|
93
94
|
)
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
opts[:DirectoryIndex] = [] if opts[:BuntoOptions][
|
|
97
|
+
opts[:DirectoryIndex] = [] if opts[:BuntoOptions]["show_dir_listing"]
|
|
97
98
|
|
|
98
99
|
enable_ssl(opts)
|
|
99
100
|
enable_logging(opts)
|
|
@@ -107,7 +108,7 @@ module Bunto
|
|
|
107
108
|
WEBrick::Config::FileHandler.merge({
|
|
108
109
|
:FancyIndexing => true,
|
|
109
110
|
:NondisclosureName => [
|
|
110
|
-
|
|
111
|
+
".ht*", "~*"
|
|
111
112
|
]
|
|
112
113
|
})
|
|
113
114
|
end
|
|
@@ -116,12 +117,12 @@ module Bunto
|
|
|
116
117
|
|
|
117
118
|
private
|
|
118
119
|
def server_address(server, opts)
|
|
119
|
-
"%{prefix}://%{address}:%{port}%{baseurl}"
|
|
120
|
-
:prefix
|
|
120
|
+
format("%{prefix}://%{address}:%{port}%{baseurl}", {
|
|
121
|
+
:prefix => server.config[:SSLEnable] ? "https" : "http",
|
|
121
122
|
:baseurl => opts["baseurl"] ? "#{opts["baseurl"]}/" : "",
|
|
122
123
|
:address => server.config[:BindAddress],
|
|
123
|
-
:port
|
|
124
|
-
}
|
|
124
|
+
:port => server.config[:Port]
|
|
125
|
+
})
|
|
125
126
|
end
|
|
126
127
|
|
|
127
128
|
#
|
|
@@ -171,22 +172,27 @@ module Bunto
|
|
|
171
172
|
# forget to add one of the certificates.
|
|
172
173
|
|
|
173
174
|
private
|
|
175
|
+
# rubocop:disable Metrics/AbcSize
|
|
174
176
|
def enable_ssl(opts)
|
|
175
177
|
return if !opts[:BuntoOptions]["ssl_cert"] && !opts[:BuntoOptions]["ssl_key"]
|
|
176
178
|
if !opts[:BuntoOptions]["ssl_cert"] || !opts[:BuntoOptions]["ssl_key"]
|
|
179
|
+
# rubocop:disable Style/RedundantException
|
|
177
180
|
raise RuntimeError, "--ssl-cert or --ssl-key missing."
|
|
178
181
|
end
|
|
179
|
-
|
|
180
182
|
require "openssl"
|
|
181
183
|
require "webrick/https"
|
|
182
|
-
source_key = Bunto.sanitized_path(opts[:BuntoOptions]["source"],
|
|
183
|
-
|
|
184
|
-
opts[:
|
|
184
|
+
source_key = Bunto.sanitized_path(opts[:BuntoOptions]["source"], \
|
|
185
|
+
opts[:BuntoOptions]["ssl_key" ])
|
|
186
|
+
source_certificate = Bunto.sanitized_path(opts[:BuntoOptions]["source"], \
|
|
187
|
+
opts[:BuntoOptions]["ssl_cert"])
|
|
188
|
+
opts[:SSLCertificate] =
|
|
189
|
+
OpenSSL::X509::Certificate.new(File.read(source_certificate))
|
|
185
190
|
opts[:SSLPrivateKey ] = OpenSSL::PKey::RSA.new(File.read(source_key))
|
|
186
191
|
opts[:SSLEnable] = true
|
|
187
192
|
end
|
|
188
193
|
|
|
189
194
|
private
|
|
195
|
+
|
|
190
196
|
def start_callback(detached)
|
|
191
197
|
unless detached
|
|
192
198
|
proc do
|
|
@@ -197,7 +203,7 @@ module Bunto
|
|
|
197
203
|
|
|
198
204
|
private
|
|
199
205
|
def mime_types
|
|
200
|
-
file = File.expand_path(
|
|
206
|
+
file = File.expand_path("../mime.types", File.dirname(__FILE__))
|
|
201
207
|
WEBrick::HTTPUtils.load_mime_types(file)
|
|
202
208
|
end
|
|
203
209
|
end
|
|
@@ -7,7 +7,7 @@ module Bunto
|
|
|
7
7
|
DEFAULTS = {
|
|
8
8
|
"Cache-Control" => "private, max-age=0, proxy-revalidate, " \
|
|
9
9
|
"no-store, no-cache, must-revalidate"
|
|
10
|
-
}
|
|
10
|
+
}.freeze
|
|
11
11
|
|
|
12
12
|
def initialize(server, root, callbacks)
|
|
13
13
|
# So we can access them easily.
|
|
@@ -25,8 +25,7 @@ module Bunto
|
|
|
25
25
|
super || super(req, res, "#{basename}.html")
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
|
|
28
|
+
# rubocop:disable Style/MethodName
|
|
30
29
|
def do_GET(req, res)
|
|
31
30
|
rtn = super
|
|
32
31
|
validate_and_ensure_charset(req, res)
|
|
@@ -38,10 +37,10 @@ module Bunto
|
|
|
38
37
|
|
|
39
38
|
private
|
|
40
39
|
def validate_and_ensure_charset(_req, res)
|
|
41
|
-
key = res.header.keys.grep(
|
|
40
|
+
key = res.header.keys.grep(%r!content-type!i).first
|
|
42
41
|
typ = res.header[key]
|
|
43
42
|
|
|
44
|
-
unless typ =~
|
|
43
|
+
unless typ =~ %r!;\s*charset=!
|
|
45
44
|
res.header[key] = "#{typ}; charset=#{@bunto_opts["encoding"]}"
|
|
46
45
|
end
|
|
47
46
|
end
|
data/lib/bunto/configuration.rb
CHANGED
|
@@ -6,73 +6,94 @@ module Bunto
|
|
|
6
6
|
# Strings rather than symbols are used for compatibility with YAML.
|
|
7
7
|
DEFAULTS = Configuration[{
|
|
8
8
|
# Where things are
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
"source" => Dir.pwd,
|
|
10
|
+
"destination" => File.join(Dir.pwd, "_site"),
|
|
11
|
+
"plugins_dir" => "_plugins",
|
|
12
|
+
"layouts_dir" => "_layouts",
|
|
13
|
+
"data_dir" => "_data",
|
|
14
|
+
"includes_dir" => "_includes",
|
|
15
|
+
"collections" => {},
|
|
16
16
|
|
|
17
17
|
# Handling Reading
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
"safe" => false,
|
|
19
|
+
"include" => [".htaccess"],
|
|
20
|
+
"exclude" => [],
|
|
21
|
+
"keep_files" => [".git", ".svn"],
|
|
22
|
+
"encoding" => "utf-8",
|
|
23
|
+
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
|
24
24
|
|
|
25
25
|
# Filtering Content
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
"show_drafts" => nil,
|
|
27
|
+
"limit_posts" => 0,
|
|
28
|
+
"future" => false,
|
|
29
|
+
"unpublished" => false,
|
|
30
30
|
|
|
31
31
|
# Plugins
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
"whitelist" => [],
|
|
33
|
+
"gems" => [],
|
|
34
34
|
|
|
35
35
|
# Conversion
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
"markdown" => "kramdown",
|
|
37
|
+
"highlighter" => "rouge",
|
|
38
|
+
"lsi" => false,
|
|
39
|
+
"excerpt_separator" => "\n\n",
|
|
40
|
+
"incremental" => false,
|
|
41
41
|
|
|
42
42
|
# Serving
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
"detach" => false, # default to not detaching the server
|
|
44
|
+
"port" => "4000",
|
|
45
|
+
"host" => "127.0.0.1",
|
|
46
|
+
"baseurl" => "",
|
|
47
|
+
"show_dir_listing" => false,
|
|
48
48
|
|
|
49
49
|
# Output Configuration
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
"permalink" => "date",
|
|
51
|
+
"paginate_path" => "/page:num",
|
|
52
|
+
"timezone" => nil, # use the local timezone
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
"quiet" => false,
|
|
55
|
+
"verbose" => false,
|
|
56
|
+
"defaults" => [],
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
"liquid" => {
|
|
59
|
+
"error_mode" => "warn"
|
|
60
60
|
},
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
"rdiscount" => {
|
|
63
|
+
"extensions" => []
|
|
64
64
|
},
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
"redcarpet" => {
|
|
67
|
+
"extensions" => []
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
"kramdown" => {
|
|
71
|
+
"auto_ids" => true,
|
|
72
|
+
"toc_levels" => "1..6",
|
|
73
|
+
"entity_output" => "as_char",
|
|
74
|
+
"smart_quotes" => "lsquo,rsquo,ldquo,rdquo",
|
|
75
|
+
"input" => "GFM",
|
|
76
|
+
"hard_wrap" => false,
|
|
77
|
+
"footnote_nr" => 1
|
|
74
78
|
}
|
|
75
|
-
}]
|
|
79
|
+
}.map { |k, v| [k, v.freeze] }].freeze
|
|
80
|
+
|
|
81
|
+
class << self
|
|
82
|
+
# Static: Produce a Configuration ready for use in a Site.
|
|
83
|
+
# It takes the input, fills in the defaults where values do not
|
|
84
|
+
# exist, and patches common issues including migrating options for
|
|
85
|
+
# backwards compatiblity. Except where a key or value is being fixed,
|
|
86
|
+
# the user configuration will override the defaults.
|
|
87
|
+
#
|
|
88
|
+
# user_config - a Hash or Configuration of overrides.
|
|
89
|
+
#
|
|
90
|
+
# Returns a Configuration filled with defaults and fixed for common
|
|
91
|
+
# problems and backwards-compatibility.
|
|
92
|
+
def from(user_config)
|
|
93
|
+
Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
|
|
94
|
+
.fix_common_issues.add_default_collections
|
|
95
|
+
end
|
|
96
|
+
end
|
|
76
97
|
|
|
77
98
|
# Public: Turn all keys into string
|
|
78
99
|
#
|
|
@@ -91,28 +112,29 @@ module Bunto
|
|
|
91
112
|
#
|
|
92
113
|
# Returns the path to the Bunto source directory
|
|
93
114
|
def source(override)
|
|
94
|
-
get_config_value_with_override(
|
|
115
|
+
get_config_value_with_override("source", override)
|
|
95
116
|
end
|
|
96
117
|
|
|
97
118
|
def quiet(override = {})
|
|
98
|
-
get_config_value_with_override(
|
|
119
|
+
get_config_value_with_override("quiet", override)
|
|
99
120
|
end
|
|
100
121
|
alias_method :quiet?, :quiet
|
|
101
122
|
|
|
102
123
|
def verbose(override = {})
|
|
103
|
-
get_config_value_with_override(
|
|
124
|
+
get_config_value_with_override("verbose", override)
|
|
104
125
|
end
|
|
105
126
|
alias_method :verbose?, :verbose
|
|
106
127
|
|
|
107
128
|
def safe_load_file(filename)
|
|
108
129
|
case File.extname(filename)
|
|
109
|
-
when
|
|
110
|
-
Bunto::External.require_with_graceful_fail(
|
|
130
|
+
when %r!\.toml!i
|
|
131
|
+
Bunto::External.require_with_graceful_fail("toml") unless defined?(TOML)
|
|
111
132
|
TOML.load_file(filename)
|
|
112
|
-
when
|
|
133
|
+
when %r!\.ya?ml!i
|
|
113
134
|
SafeYAML.load_file(filename) || {}
|
|
114
135
|
else
|
|
115
|
-
raise ArgumentError, "No parser for '#{filename}' is available.
|
|
136
|
+
raise ArgumentError, "No parser for '#{filename}' is available.
|
|
137
|
+
Use a .toml or .y(a)ml file instead."
|
|
116
138
|
end
|
|
117
139
|
end
|
|
118
140
|
|
|
@@ -123,12 +145,15 @@ module Bunto
|
|
|
123
145
|
# Returns an Array of config files
|
|
124
146
|
def config_files(override)
|
|
125
147
|
# Adjust verbosity quickly
|
|
126
|
-
Bunto.logger.adjust_verbosity(
|
|
148
|
+
Bunto.logger.adjust_verbosity(
|
|
149
|
+
:quiet => quiet?(override),
|
|
150
|
+
:verbose => verbose?(override)
|
|
151
|
+
)
|
|
127
152
|
|
|
128
153
|
# Get configuration from <source>/_config.yml or <source>/<config_file>
|
|
129
|
-
config_files = override.delete(
|
|
154
|
+
config_files = override.delete("config")
|
|
130
155
|
if config_files.to_s.empty?
|
|
131
|
-
default = %w(yml yaml).find(-> {
|
|
156
|
+
default = %w(yml yaml).find(-> { "yml" }) do |ext|
|
|
132
157
|
File.exist?(Bunto.sanitized_path(source(override), "_config.#{ext}"))
|
|
133
158
|
end
|
|
134
159
|
config_files = Bunto.sanitized_path(source(override), "_config.#{default}")
|
|
@@ -153,7 +178,8 @@ module Bunto
|
|
|
153
178
|
Bunto.logger.warn "Configuration file:", "none"
|
|
154
179
|
{}
|
|
155
180
|
else
|
|
156
|
-
Bunto.logger.error "Fatal:", "The configuration file '#{file}'
|
|
181
|
+
Bunto.logger.error "Fatal:", "The configuration file '#{file}'
|
|
182
|
+
could not be found."
|
|
157
183
|
raise LoadError, "The Configuration file '#{file}' could not be found."
|
|
158
184
|
end
|
|
159
185
|
end
|
|
@@ -169,13 +195,14 @@ module Bunto
|
|
|
169
195
|
|
|
170
196
|
begin
|
|
171
197
|
files.each do |config_file|
|
|
198
|
+
next if config_file.nil? || config_file.empty?
|
|
172
199
|
new_config = read_config_file(config_file)
|
|
173
200
|
configuration = Utils.deep_merge_hashes(configuration, new_config)
|
|
174
201
|
end
|
|
175
202
|
rescue ArgumentError => err
|
|
176
203
|
Bunto.logger.warn "WARNING:", "Error reading configuration. " \
|
|
177
204
|
"Using defaults (and options)."
|
|
178
|
-
$stderr.puts
|
|
205
|
+
$stderr.puts err
|
|
179
206
|
end
|
|
180
207
|
|
|
181
208
|
configuration.fix_common_issues.backwards_compatibilize.add_default_collections
|
|
@@ -197,61 +224,18 @@ module Bunto
|
|
|
197
224
|
def backwards_compatibilize
|
|
198
225
|
config = clone
|
|
199
226
|
# Provide backwards-compatibility
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
" be set from your configuration file(s). Use the"\
|
|
203
|
-
" --[no-]watch/-w command-line option instead."
|
|
204
|
-
config.delete('auto')
|
|
205
|
-
config.delete('watch')
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
if config.key? 'server'
|
|
209
|
-
Bunto::Deprecator.deprecation_message "The 'server' configuration option" \
|
|
210
|
-
" is no longer accepted. Use the 'bunto serve'" \
|
|
211
|
-
" subcommand to serve your site with WEBrick."
|
|
212
|
-
config.delete('server')
|
|
213
|
-
end
|
|
227
|
+
check_auto(config)
|
|
228
|
+
check_server(config)
|
|
214
229
|
|
|
215
|
-
renamed_key
|
|
216
|
-
renamed_key
|
|
217
|
-
renamed_key
|
|
218
|
-
renamed_key
|
|
230
|
+
renamed_key "server_port", "port", config
|
|
231
|
+
renamed_key "plugins", "plugins_dir", config
|
|
232
|
+
renamed_key "layouts", "layouts_dir", config
|
|
233
|
+
renamed_key "data_source", "data_dir", config
|
|
219
234
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
"'pygments' or null."
|
|
225
|
-
|
|
226
|
-
config['highlighter'] = 'pygments' if config['pygments']
|
|
227
|
-
config.delete('pygments')
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
%w(include exclude).each do |option|
|
|
231
|
-
config[option] ||= []
|
|
232
|
-
if config[option].is_a?(String)
|
|
233
|
-
Bunto::Deprecator.deprecation_message "The '#{option}' configuration option" \
|
|
234
|
-
" must now be specified as an array, but you specified" \
|
|
235
|
-
" a string. For now, we've treated the string you provided" \
|
|
236
|
-
" as a list of comma-separated values."
|
|
237
|
-
config[option] = csv_to_array(config[option])
|
|
238
|
-
end
|
|
239
|
-
config[option].map!(&:to_s)
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
if (config['kramdown'] || {}).key?('use_coderay')
|
|
243
|
-
Bunto::Deprecator.deprecation_message "Please change 'use_coderay'" \
|
|
244
|
-
" to 'enable_coderay' in your configuration file."
|
|
245
|
-
config['kramdown']['use_coderay'] = config['kramdown'].delete('enable_coderay')
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku")
|
|
249
|
-
Bunto.logger.abort_with "Error:", "You're using the 'maruku' " \
|
|
250
|
-
"Markdown processor, which has been removed as of 3.0.0. " \
|
|
251
|
-
"We recommend you switch to Kramdown. To do this, replace " \
|
|
252
|
-
"`markdown: maruku` with `markdown: kramdown` in your " \
|
|
253
|
-
"`_config.yml` file."
|
|
254
|
-
end
|
|
235
|
+
check_pygments(config)
|
|
236
|
+
check_include_exclude(config)
|
|
237
|
+
check_coderay(config)
|
|
238
|
+
check_maruku(config)
|
|
255
239
|
|
|
256
240
|
config
|
|
257
241
|
end
|
|
@@ -259,10 +243,12 @@ module Bunto
|
|
|
259
243
|
def fix_common_issues
|
|
260
244
|
config = clone
|
|
261
245
|
|
|
262
|
-
if config.key?(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
246
|
+
if config.key?("paginate") && (!config["paginate"].is_a?(Integer) ||
|
|
247
|
+
config["paginate"] < 1)
|
|
248
|
+
|
|
249
|
+
Bunto.logger.warn "Config Warning:", "The `paginate` key must be a positive" \
|
|
250
|
+
" integer or nil. It's currently set to '#{config["paginate"].inspect}'."
|
|
251
|
+
config["paginate"] = nil
|
|
266
252
|
end
|
|
267
253
|
|
|
268
254
|
config
|
|
@@ -271,14 +257,22 @@ module Bunto
|
|
|
271
257
|
def add_default_collections
|
|
272
258
|
config = clone
|
|
273
259
|
|
|
274
|
-
|
|
260
|
+
# It defaults to `{}`, so this is only if someone sets it to null manually.
|
|
261
|
+
return config if config["collections"].nil?
|
|
275
262
|
|
|
276
|
-
|
|
277
|
-
|
|
263
|
+
# Ensure we have a hash.
|
|
264
|
+
if config["collections"].is_a?(Array)
|
|
265
|
+
config["collections"] = Hash[config["collections"].map { |c| [c, {}] }]
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
config["collections"] = Utils.deep_merge_hashes(
|
|
269
|
+
{ "posts" => {} }, config["collections"]
|
|
270
|
+
).tap do |collections|
|
|
271
|
+
collections["posts"]["output"] = true
|
|
272
|
+
if config["permalink"]
|
|
273
|
+
collections["posts"]["permalink"] ||= style_to_permalink(config["permalink"])
|
|
274
|
+
end
|
|
278
275
|
end
|
|
279
|
-
config['collections']['posts'] ||= {}
|
|
280
|
-
config['collections']['posts']['output'] = true
|
|
281
|
-
config['collections']['posts']['permalink'] = style_to_permalink(config['permalink'])
|
|
282
276
|
|
|
283
277
|
config
|
|
284
278
|
end
|
|
@@ -293,7 +287,6 @@ module Bunto
|
|
|
293
287
|
end
|
|
294
288
|
|
|
295
289
|
private
|
|
296
|
-
|
|
297
290
|
def style_to_permalink(permalink_style)
|
|
298
291
|
case permalink_style.to_sym
|
|
299
292
|
when :pretty
|
|
@@ -315,9 +308,78 @@ module Bunto
|
|
|
315
308
|
# file - the file from which the config was extracted
|
|
316
309
|
#
|
|
317
310
|
# Raises an ArgumentError if given config is not a hash
|
|
311
|
+
private
|
|
318
312
|
def check_config_is_hash!(extracted_config, file)
|
|
319
313
|
unless extracted_config.is_a?(Hash)
|
|
320
|
-
raise ArgumentError
|
|
314
|
+
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
private
|
|
319
|
+
def check_auto(config)
|
|
320
|
+
if config.key?("auto") || config.key?("watch")
|
|
321
|
+
Bunto::Deprecator.deprecation_message "Auto-regeneration can no longer" \
|
|
322
|
+
" be set from your configuration file(s). Use the" \
|
|
323
|
+
" --[no-]watch/-w command-line option instead."
|
|
324
|
+
config.delete("auto")
|
|
325
|
+
config.delete("watch")
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
private
|
|
330
|
+
def check_server(config)
|
|
331
|
+
if config.key?("server")
|
|
332
|
+
Bunto::Deprecator.deprecation_message "The 'server' configuration option" \
|
|
333
|
+
" is no longer accepted. Use the 'bunto serve'" \
|
|
334
|
+
" subcommand to serve your site with WEBrick."
|
|
335
|
+
config.delete("server")
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
private
|
|
340
|
+
def check_pygments(config)
|
|
341
|
+
if config.key?("pygments")
|
|
342
|
+
Bunto::Deprecator.deprecation_message "The 'pygments' configuration option" \
|
|
343
|
+
" has been renamed to 'highlighter'. Please update your" \
|
|
344
|
+
" config file accordingly. The allowed values are 'rouge', " \
|
|
345
|
+
"'pygments' or null."
|
|
346
|
+
|
|
347
|
+
config["highlighter"] = "pygments" if config["pygments"]
|
|
348
|
+
config.delete("pygments")
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
private
|
|
353
|
+
def check_include_exclude(config)
|
|
354
|
+
%w(include exclude).each do |option|
|
|
355
|
+
if config[option].is_a?(String)
|
|
356
|
+
Bunto::Deprecator.deprecation_message "The '#{option}' configuration option" \
|
|
357
|
+
" must now be specified as an array, but you specified" \
|
|
358
|
+
" a string. For now, we've treated the string you provided" \
|
|
359
|
+
" as a list of comma-separated values."
|
|
360
|
+
config[option] = csv_to_array(config[option])
|
|
361
|
+
end
|
|
362
|
+
config[option].map!(&:to_s) if config[option]
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
private
|
|
367
|
+
def check_coderay(config)
|
|
368
|
+
if (config["kramdown"] || {}).key?("use_coderay")
|
|
369
|
+
Bunto::Deprecator.deprecation_message "Please change 'use_coderay'" \
|
|
370
|
+
" to 'enable_coderay' in your configuration file."
|
|
371
|
+
config["kramdown"]["use_coderay"] = config["kramdown"].delete("enable_coderay")
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
private
|
|
376
|
+
def check_maruku(config)
|
|
377
|
+
if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero?
|
|
378
|
+
Bunto.logger.abort_with "Error:", "You're using the 'maruku' " \
|
|
379
|
+
"Markdown processor, which has been removed as of 3.0.0. " \
|
|
380
|
+
"We recommend you switch to Kramdown. To do this, replace " \
|
|
381
|
+
"`markdown: maruku` with `markdown: kramdown` in your " \
|
|
382
|
+
"`_config.yml` file."
|
|
321
383
|
end
|
|
322
384
|
end
|
|
323
385
|
end
|