bridgetown-core 1.0.0.alpha1 → 1.0.0.alpha2
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 +35 -0
- data/Rakefile +5 -5
- data/lib/bridgetown-core/cache.rb +3 -5
- data/lib/bridgetown-core/cleaner.rb +2 -2
- data/lib/bridgetown-core/collection.rb +4 -6
- data/lib/bridgetown-core/commands/base.rb +4 -3
- data/lib/bridgetown-core/commands/build.rb +20 -19
- data/lib/bridgetown-core/commands/concerns/actions.rb +2 -2
- data/lib/bridgetown-core/commands/console.rb +3 -3
- data/lib/bridgetown-core/commands/doctor.rb +10 -8
- data/lib/bridgetown-core/commands/new.rb +5 -3
- data/lib/bridgetown-core/commands/plugins.rb +7 -9
- data/lib/bridgetown-core/commands/serve/servlet.rb +4 -4
- data/lib/bridgetown-core/commands/serve.rb +25 -27
- data/lib/bridgetown-core/commands/webpack.rb +1 -1
- data/lib/bridgetown-core/component.rb +1 -5
- data/lib/bridgetown-core/concerns/site/configurable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/content.rb +2 -2
- data/lib/bridgetown-core/concerns/site/extensible.rb +3 -4
- data/lib/bridgetown-core/concerns/site/localizable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/ssr.rb +1 -1
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
- data/lib/bridgetown-core/configuration.rb +1 -1
- data/lib/bridgetown-core/converter.rb +1 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +1 -1
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/smartypants.rb +1 -0
- data/lib/bridgetown-core/drops/drop.rb +4 -4
- data/lib/bridgetown-core/entry_filter.rb +1 -0
- data/lib/bridgetown-core/filters/url_filters.rb +1 -1
- data/lib/bridgetown-core/filters.rb +11 -12
- data/lib/bridgetown-core/frontmatter_defaults.rb +5 -7
- data/lib/bridgetown-core/generated_page.rb +1 -3
- data/lib/bridgetown-core/generators/prototype_generator.rb +36 -37
- data/lib/bridgetown-core/helpers.rb +1 -1
- data/lib/bridgetown-core/hooks.rb +2 -2
- data/lib/bridgetown-core/liquid_renderer.rb +1 -3
- data/lib/bridgetown-core/log_adapter.rb +1 -1
- data/lib/bridgetown-core/log_writer.rb +1 -1
- data/lib/bridgetown-core/model/base.rb +2 -2
- data/lib/bridgetown-core/model/builder_origin.rb +1 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +2 -2
- data/lib/bridgetown-core/publisher.rb +1 -1
- data/lib/bridgetown-core/rack/routes.rb +1 -5
- data/lib/bridgetown-core/rack/static_indexes.rb +2 -2
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/renderer.rb +1 -1
- data/lib/bridgetown-core/resource/base.rb +7 -7
- data/lib/bridgetown-core/resource/permalink_processor.rb +3 -2
- data/lib/bridgetown-core/resource/taxonomy_term.rb +1 -5
- data/lib/bridgetown-core/resource/transformer.rb +7 -5
- data/lib/bridgetown-core/ruby_template_view.rb +1 -3
- data/lib/bridgetown-core/static_file.rb +5 -7
- data/lib/bridgetown-core/tags/find.rb +6 -6
- data/lib/bridgetown-core/tags/highlight.rb +5 -5
- data/lib/bridgetown-core/tags/include.rb +22 -19
- data/lib/bridgetown-core/tags/post_url.rb +6 -6
- data/lib/bridgetown-core/tags/render_content.rb +2 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
- data/lib/bridgetown-core/url.rb +3 -3
- data/lib/bridgetown-core/utils.rb +7 -9
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +2 -2
- data/lib/bridgetown-core.rb +2 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a735962a1880837aa59641e65afa3985f0ebb091861ae32972d0b875229cfc7d
|
4
|
+
data.tar.gz: a64d7710c18a4c80805bd7196eacd07387fa1b3061616e8ed2b4de8b9a228871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c136fee524ff82c30ceedcc8ef0ef11fc877ac82066c6bd1d16e0d55cc47391b2b211b72c9f2229d7d83685edb98968e516d2eea09510a1c7c3c4ab0466e6e9
|
7
|
+
data.tar.gz: 05b65d5c57dfdbd0dcea25ab15875b637868ecd4c69a76a288fe23dd64dc06eb2c3ee6ec980f30b3957888859fbed2e7771a007cf7188cf7572808a17a5c9372
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
inherit_from: ../.rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
Exclude:
|
6
|
+
- "*.gemspec"
|
7
|
+
- bin/**/*
|
8
|
+
- exe/**/*
|
9
|
+
- benchmark/**/*
|
10
|
+
- script/**/*
|
11
|
+
- vendor/**/*
|
12
|
+
- tmp/**/*
|
13
|
+
- test/source/**/*
|
14
|
+
- lib/site_template/Rakefile
|
15
|
+
- lib/site_template/config.ru
|
16
|
+
- lib/site_template/config/**/*
|
17
|
+
- lib/site_template/plugins/site_builder.rb
|
18
|
+
|
19
|
+
Lint/ConstantDefinitionInBlock:
|
20
|
+
Exclude:
|
21
|
+
- test/test_filters.rb
|
22
|
+
- test/test_liquid_extensions.rb
|
23
|
+
- test/test_site.rb
|
24
|
+
|
25
|
+
Lint/MissingSuper:
|
26
|
+
Exclude:
|
27
|
+
- test/test_liquid_extensions.rb
|
28
|
+
|
29
|
+
Performance/CollectionLiteralInLoop:
|
30
|
+
Exclude:
|
31
|
+
- test/test_filters.rb
|
32
|
+
|
33
|
+
Style/StringConcatenation:
|
34
|
+
Exclude:
|
35
|
+
- test/test_apply_command.rb
|
data/Rakefile
CHANGED
@@ -13,16 +13,16 @@ Rake::TestTask.new(:test) do |test|
|
|
13
13
|
test.verbose = true
|
14
14
|
end
|
15
15
|
|
16
|
-
require
|
16
|
+
require "yard"
|
17
17
|
YARD::Rake::YardocTask.new(:yard) do |t|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
t.files = ["lib/**/*.rb"]
|
19
|
+
t.options = ["--no-output"]
|
20
|
+
t.stats_options = ["--list-undoc"]
|
21
21
|
end
|
22
22
|
|
23
23
|
namespace :yard do
|
24
24
|
task :serve do
|
25
|
-
port = ENV[
|
25
|
+
port = ENV["YARD_PORT"] || "8808"
|
26
26
|
sh("yard server --reload -p #{port}")
|
27
27
|
end
|
28
28
|
end
|
@@ -82,11 +82,9 @@ module Bridgetown
|
|
82
82
|
return @cache[key] if @cache.key?(key)
|
83
83
|
|
84
84
|
path = path_to(hash(key))
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
raise
|
89
|
-
end
|
85
|
+
raise unless disk_cache_enabled? && File.file?(path) && File.readable?(path)
|
86
|
+
|
87
|
+
@cache[key] = load(path)
|
90
88
|
end
|
91
89
|
|
92
90
|
# Add an item to cache
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
# Handles the cleanup of a site's destination before it is built.
|
5
5
|
class Cleaner
|
6
|
-
HIDDEN_FILE_REGEX = %r
|
6
|
+
HIDDEN_FILE_REGEX = %r!/\.{1,2}$!.freeze
|
7
7
|
attr_reader :site
|
8
8
|
|
9
9
|
def initialize(site)
|
@@ -104,7 +104,7 @@ module Bridgetown
|
|
104
104
|
#
|
105
105
|
# Returns the regular expression
|
106
106
|
def keep_file_regex
|
107
|
-
%r!\A#{Regexp.quote(site.dest)}
|
107
|
+
%r!\A#{Regexp.quote(site.dest)}/(#{Regexp.union(site.config.keep_files).source})!
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -190,7 +190,7 @@ module Bridgetown
|
|
190
190
|
# @param label [String] the possibly-unsafe label
|
191
191
|
# @return [String] sanitized version of the label.
|
192
192
|
def sanitize_label(label)
|
193
|
-
label.gsub(%r![^a-z0-9_
|
193
|
+
label.gsub(%r![^a-z0-9_\-.]!i, "")
|
194
194
|
end
|
195
195
|
|
196
196
|
# Produce a representation of this Collection for use in Liquid.
|
@@ -215,9 +215,7 @@ module Bridgetown
|
|
215
215
|
# Used by Resource's permalink processor
|
216
216
|
# @return [String]
|
217
217
|
def default_permalink
|
218
|
-
metadata.fetch("permalink")
|
219
|
-
"/:collection/:path/"
|
220
|
-
end
|
218
|
+
metadata.fetch("permalink", "/:collection/:path/")
|
221
219
|
end
|
222
220
|
|
223
221
|
# Extract options for this collection from the site configuration.
|
@@ -227,7 +225,7 @@ module Bridgetown
|
|
227
225
|
site.config.collections[label] || HashWithDotAccess::Hash.new
|
228
226
|
end
|
229
227
|
|
230
|
-
def merge_data_resources # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
228
|
+
def merge_data_resources # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
231
229
|
data_contents = {}
|
232
230
|
|
233
231
|
sanitize_filename = ->(name) do
|
@@ -349,7 +347,7 @@ module Bridgetown
|
|
349
347
|
|
350
348
|
def order_with_warning(sort_key, resource, order)
|
351
349
|
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in" \
|
352
|
-
|
350
|
+
" #{resource.relative_path}"
|
353
351
|
order
|
354
352
|
end
|
355
353
|
|
@@ -17,9 +17,10 @@ module Bridgetown
|
|
17
17
|
class << self
|
18
18
|
# Override single character commands if necessary
|
19
19
|
def find_command_possibilities(subcommand)
|
20
|
-
|
20
|
+
case subcommand
|
21
|
+
when "c"
|
21
22
|
["console"]
|
22
|
-
|
23
|
+
when "s"
|
23
24
|
["start"]
|
24
25
|
else
|
25
26
|
super
|
@@ -53,7 +54,7 @@ module Bridgetown
|
|
53
54
|
cmd = cmd.split("[")
|
54
55
|
args = []
|
55
56
|
if cmd[1]
|
56
|
-
args = cmd[1].gsub(
|
57
|
+
args = cmd[1].gsub("\\,", "__COMMA__").delete_suffix!("]").split(",").map do |item|
|
57
58
|
item.gsub("__COMMA__", ",")
|
58
59
|
end
|
59
60
|
end
|
@@ -23,7 +23,7 @@ module Bridgetown
|
|
23
23
|
|
24
24
|
def self.print_startup_message
|
25
25
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
26
|
-
|
26
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
|
27
27
|
end
|
28
28
|
|
29
29
|
# Build your bridgetown site
|
@@ -46,7 +46,7 @@ module Bridgetown
|
|
46
46
|
|
47
47
|
if config_options.fetch("skip_initial_build", false)
|
48
48
|
Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
|
49
|
-
|
49
|
+
" This may result in an out-of-date site."
|
50
50
|
else
|
51
51
|
build_site(config_options)
|
52
52
|
end
|
@@ -78,19 +78,20 @@ module Bridgetown
|
|
78
78
|
Bridgetown.logger.info "Generating…"
|
79
79
|
@site.process
|
80
80
|
Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
81
|
+
" #{(Time.now - t).ceil(2)} seconds."
|
82
|
+
|
83
|
+
return unless config_options[:using_puma]
|
84
|
+
|
85
|
+
require "socket"
|
86
|
+
external_ip = Socket.ip_address_list.find do |ai|
|
87
|
+
ai.ipv4? && !ai.ipv4_loopback?
|
88
|
+
end&.ip_address
|
89
|
+
scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
90
|
+
port = config_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
91
|
+
Bridgetown.logger.info ""
|
92
|
+
Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
|
93
|
+
Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
|
94
|
+
Bridgetown.logger.info ""
|
94
95
|
end
|
95
96
|
|
96
97
|
# Watch for file changes and rebuild the site.
|
@@ -114,10 +115,10 @@ module Bridgetown
|
|
114
115
|
Bridgetown.logger.info "Source:", source
|
115
116
|
Bridgetown.logger.info "Destination:", destination
|
116
117
|
# TODO: work with arrays
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
return unless config_options["plugins_dir"].is_a?(String)
|
119
|
+
|
120
|
+
plugins_dir = File.expand_path(config_options["plugins_dir"])
|
121
|
+
Bridgetown.logger.info "Custom Plugins:", plugins_dir if Dir.exist?(plugins_dir)
|
121
122
|
end
|
122
123
|
end
|
123
124
|
end
|
@@ -25,7 +25,7 @@ module Bridgetown
|
|
25
25
|
create_file("plugins/builders/#{filename}", data, verbose: false)
|
26
26
|
end
|
27
27
|
|
28
|
-
def javascript_import(data = nil, filename: "index.js")
|
28
|
+
def javascript_import(data = nil, filename: "index.js") # rubocop:todo Metrics/PerceivedComplexity
|
29
29
|
data ||= yield if block_given?
|
30
30
|
data += "\n" unless data.chars.last == "\n"
|
31
31
|
|
@@ -97,7 +97,7 @@ module Bridgetown
|
|
97
97
|
github_match = GITHUB_REGEX.match(arg)
|
98
98
|
|
99
99
|
arg = if arg.start_with?("https://gist.github.com")
|
100
|
-
arg.sub(
|
100
|
+
arg.sub( # rubocop:disable Style/StringConcatenation
|
101
101
|
"https://gist.github.com", "https://gist.githubusercontent.com"
|
102
102
|
) + "/raw"
|
103
103
|
elsif github_match
|
@@ -32,8 +32,8 @@ module Bridgetown
|
|
32
32
|
require "amazing_print" unless options[:"bypass-ap"]
|
33
33
|
|
34
34
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
35
|
-
|
36
|
-
|
35
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
|
36
|
+
" console…"
|
37
37
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
38
38
|
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
39
39
|
|
@@ -54,7 +54,7 @@ module Bridgetown
|
|
54
54
|
IRB.conf[:IRB_RC]&.call(irb.context)
|
55
55
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
56
56
|
eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
|
57
|
-
Bridgetown.logger.info "Console:", "Now loaded as "
|
57
|
+
Bridgetown.logger.info "Console:", "Now loaded as #{"site".cyan} variable."
|
58
58
|
|
59
59
|
trap("SIGINT") do
|
60
60
|
irb.signal_handle
|
@@ -50,7 +50,7 @@ module Bridgetown
|
|
50
50
|
"Detected '_posts' directory outside custom `collections_dir`!"
|
51
51
|
Bridgetown.logger.warn "",
|
52
52
|
"Please move '#{posts_at_root}' into the custom directory at " \
|
53
|
-
|
53
|
+
"'#{site.in_source_dir(site.config["collections_dir"])}'"
|
54
54
|
false
|
55
55
|
end
|
56
56
|
|
@@ -64,7 +64,7 @@ module Bridgetown
|
|
64
64
|
|
65
65
|
conflicting_urls = true
|
66
66
|
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
67
|
-
|
67
|
+
" for the following pages: #{paths.join(", ")}"
|
68
68
|
end
|
69
69
|
conflicting_urls
|
70
70
|
end
|
@@ -76,9 +76,11 @@ module Bridgetown
|
|
76
76
|
next unless real_urls.uniq.size > 1
|
77
77
|
|
78
78
|
urls_only_differ_by_case = true
|
79
|
-
Bridgetown.logger.warn
|
80
|
-
"
|
81
|
-
"
|
79
|
+
Bridgetown.logger.warn(
|
80
|
+
"Warning:",
|
81
|
+
"The following URLs only differ by case. On a case-insensitive file system one of the" \
|
82
|
+
" URLs will be overwritten by the other: #{real_urls.join(", ")}"
|
83
|
+
)
|
82
84
|
end
|
83
85
|
urls_only_differ_by_case
|
84
86
|
end
|
@@ -117,7 +119,7 @@ module Bridgetown
|
|
117
119
|
return true unless url.nil? || url.empty?
|
118
120
|
|
119
121
|
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
120
|
-
|
122
|
+
"you may encounter problems with some plugins."
|
121
123
|
false
|
122
124
|
end
|
123
125
|
|
@@ -128,7 +130,7 @@ module Bridgetown
|
|
128
130
|
# https://git.io/vFfbx
|
129
131
|
rescue TypeError
|
130
132
|
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
|
131
|
-
|
133
|
+
"check the value of `url` in your config file."
|
132
134
|
false
|
133
135
|
end
|
134
136
|
|
@@ -136,7 +138,7 @@ module Bridgetown
|
|
136
138
|
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
|
137
139
|
|
138
140
|
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
139
|
-
|
141
|
+
"check the value of `url` in your config file."
|
140
142
|
false
|
141
143
|
end
|
142
144
|
end
|
@@ -59,8 +59,10 @@ module Bridgetown
|
|
59
59
|
|
60
60
|
if preserve_source_location?(new_site_path, options)
|
61
61
|
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
|
62
|
-
Bridgetown.logger.abort_with
|
63
|
-
|
62
|
+
Bridgetown.logger.abort_with(
|
63
|
+
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and" \
|
64
|
+
" overwrite any files."
|
65
|
+
)
|
64
66
|
end
|
65
67
|
|
66
68
|
self.destination_root = self.class.created_site_dir = new_site_path
|
@@ -122,7 +124,7 @@ module Bridgetown
|
|
122
124
|
bt_start = "bin/bridgetown start"
|
123
125
|
logger.info ""
|
124
126
|
logger.info "Success!".green, "🎉 Your new Bridgetown site was" \
|
125
|
-
|
127
|
+
" generated in #{cli_path.cyan}."
|
126
128
|
if options["skip-yarn"]
|
127
129
|
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
|
128
130
|
logger.info "You'll probably also want to #{"yarn install".cyan}" \
|
@@ -112,12 +112,12 @@ module Bridgetown
|
|
112
112
|
source_manifest.origin.to_s == directive[0]
|
113
113
|
end
|
114
114
|
|
115
|
-
if manifest
|
115
|
+
if manifest.respond_to?(directive[1].downcase)
|
116
116
|
dir = manifest.send(directive[1].downcase)
|
117
117
|
Bridgetown.logger.info("Opening the #{dir.green} folder for" \
|
118
|
-
|
118
|
+
" #{manifest.origin.to_s.cyan}…")
|
119
119
|
Bridgetown.logger.info("Type #{"exit".yellow} when you're done to" \
|
120
|
-
|
120
|
+
" return to your site root.")
|
121
121
|
puts
|
122
122
|
|
123
123
|
Dir.chdir dir do
|
@@ -133,13 +133,12 @@ module Bridgetown
|
|
133
133
|
Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}")
|
134
134
|
else
|
135
135
|
Bridgetown.logger.warn("Oops!", "I wasn't able to find the" \
|
136
|
-
|
136
|
+
" #{directive[1]} folder for #{directive[0]}")
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
desc "new NAME", "Create a new plugin NAME (please-use-dashes) by" \
|
141
141
|
" cloning the sample plugin repo"
|
142
|
-
# rubocop:disable Layout/LineLength
|
143
142
|
def new(plugin_name)
|
144
143
|
folder_name = plugin_name.underscore
|
145
144
|
name = folder_name.dasherize
|
@@ -187,11 +186,10 @@ module Bridgetown
|
|
187
186
|
say ""
|
188
187
|
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
189
188
|
say_status "Remember:", "Don't forget to rename the SamplePlugin" \
|
190
|
-
|
191
|
-
|
192
|
-
|
189
|
+
" code identifiers and paths to your own" \
|
190
|
+
" indentifer, as well as update your README " \
|
191
|
+
" and CHANGELOG files as necessary."
|
193
192
|
end
|
194
|
-
# rubocop:enable Layout/LineLength
|
195
193
|
|
196
194
|
protected
|
197
195
|
|
@@ -8,7 +8,7 @@ module Bridgetown
|
|
8
8
|
class Servlet < WEBrick::HTTPServlet::FileHandler
|
9
9
|
DEFAULTS = {
|
10
10
|
"Cache-Control" => "private, max-age=0, proxy-revalidate, " \
|
11
|
-
|
11
|
+
"no-store, no-cache, must-revalidate",
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
def initialize(server, root, callbacks)
|
@@ -51,9 +51,9 @@ module Bridgetown
|
|
51
51
|
key = res.header.keys.grep(%r!content-type!i).first
|
52
52
|
typ = res.header[key]
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
return if %r!;\s*charset=!.match?(typ)
|
55
|
+
|
56
|
+
res.header[key] = "#{typ}; charset=#{@bridgetown_opts["encoding"]}"
|
57
57
|
end
|
58
58
|
|
59
59
|
def set_defaults
|
@@ -48,8 +48,9 @@ module Bridgetown
|
|
48
48
|
).freeze
|
49
49
|
|
50
50
|
def serve
|
51
|
-
Bridgetown::Deprecator.deprecation_message
|
52
|
-
"removed in favor of
|
51
|
+
Bridgetown::Deprecator.deprecation_message(
|
52
|
+
"WEBrick (serve) will be removed in favor of Puma (start) in the next Bridgetown release"
|
53
|
+
)
|
53
54
|
|
54
55
|
@mutex = Mutex.new
|
55
56
|
@run_cond = ConditionVariable.new
|
@@ -58,7 +59,6 @@ module Bridgetown
|
|
58
59
|
no_watch = options["watch"] == false
|
59
60
|
|
60
61
|
options = Thor::CoreExt::HashWithIndifferentAccess.new(self.options)
|
61
|
-
|
62
62
|
options["serving"] = true
|
63
63
|
options["watch"] = true unless no_watch
|
64
64
|
|
@@ -88,12 +88,12 @@ module Bridgetown
|
|
88
88
|
require_relative "serve/servlet"
|
89
89
|
|
90
90
|
FileUtils.mkdir_p(destination)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
return unless File.exist?(File.join(destination, "404.html"))
|
92
|
+
|
93
|
+
WEBrick::HTTPResponse.class_eval do
|
94
|
+
def create_error_page
|
95
|
+
@header["Content-Type"] = "text/html; charset=UTF-8"
|
96
|
+
@body = File.read(File.join(@config[:DocumentRoot], "404.html"))
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -211,34 +211,32 @@ module Bridgetown
|
|
211
211
|
begin
|
212
212
|
opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key))
|
213
213
|
rescue StandardError
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
raise
|
218
|
-
end
|
214
|
+
raise unless defined?(OpenSSL::PKey::EC)
|
215
|
+
|
216
|
+
opts[:SSLPrivateKey] = OpenSSL::PKey::EC.new(read_file(src, key))
|
219
217
|
end
|
220
218
|
opts[:SSLEnable] = true
|
221
219
|
end
|
222
220
|
|
223
221
|
def start_callback(detached)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
222
|
+
return if detached
|
223
|
+
|
224
|
+
proc do
|
225
|
+
@mutex.synchronize do
|
226
|
+
@running = true
|
227
|
+
Bridgetown.logger.info("Server running…", "press ctrl-c to stop.")
|
228
|
+
@run_cond.broadcast
|
231
229
|
end
|
232
230
|
end
|
233
231
|
end
|
234
232
|
|
235
233
|
def stop_callback(detached)
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
234
|
+
return if detached
|
235
|
+
|
236
|
+
proc do
|
237
|
+
@mutex.synchronize do
|
238
|
+
@running = false
|
239
|
+
@run_cond.broadcast
|
242
240
|
end
|
243
241
|
end
|
244
242
|
end
|
@@ -66,7 +66,7 @@ module Bridgetown
|
|
66
66
|
|
67
67
|
longest_action = supported_actions.keys.max_by(&:size).size
|
68
68
|
supported_actions.each do |action, description|
|
69
|
-
say action.ljust(longest_action).to_s.bold.blue
|
69
|
+
say "#{action.ljust(longest_action).to_s.bold.blue}\t# #{description}"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -97,9 +97,7 @@ module Bridgetown
|
|
97
97
|
#
|
98
98
|
# @return [String] or nil
|
99
99
|
def content
|
100
|
-
@_content ||=
|
101
|
-
view_context.capture(self, &@_content_block) if @_content_block
|
102
|
-
end
|
100
|
+
@_content ||= (view_context.capture(self, &@_content_block) if @_content_block)
|
103
101
|
end
|
104
102
|
|
105
103
|
# Provide a render helper for evaluation within the component context.
|
@@ -166,7 +164,6 @@ module Bridgetown
|
|
166
164
|
end
|
167
165
|
end
|
168
166
|
|
169
|
-
# rubocop:disable Style/MissingRespondToMissing
|
170
167
|
ruby2_keywords def method_missing(method, *args, &block)
|
171
168
|
if helpers.respond_to?(method.to_sym)
|
172
169
|
helpers.send method.to_sym, *args, &block
|
@@ -178,6 +175,5 @@ module Bridgetown
|
|
178
175
|
def respond_to_missing?(method, include_private = false)
|
179
176
|
helpers.respond_to?(method.to_sym, include_private) || super
|
180
177
|
end
|
181
|
-
# rubocop:enable Style/MissingRespondToMissing
|
182
178
|
end
|
183
179
|
end
|
@@ -165,7 +165,7 @@ class Bridgetown::Site
|
|
165
165
|
dir.is_a?(Array) ? dir : [dir]
|
166
166
|
end
|
167
167
|
local_components_load_paths.map! do |dir|
|
168
|
-
if !!(dir =~ %r
|
168
|
+
if !!(dir =~ %r!^\.\.?/!)
|
169
169
|
# allow ./dir or ../../dir type options
|
170
170
|
File.expand_path(dir.to_s, root_dir)
|
171
171
|
else
|
@@ -5,8 +5,8 @@ class Bridgetown::Site
|
|
5
5
|
module Content
|
6
6
|
def resources_grouped_by_taxonomy(taxonomy)
|
7
7
|
data.site_taxonomies_hash ||= {}
|
8
|
-
data.site_taxonomies_hash[taxonomy.label] ||=
|
9
|
-
|
8
|
+
data.site_taxonomies_hash[taxonomy.label] ||= taxonomy.terms.transform_values do |terms|
|
9
|
+
terms.map(&:resource).sort.reverse
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -40,10 +40,9 @@ class Bridgetown::Site
|
|
40
40
|
# instance implementing the given `Converter` class.
|
41
41
|
def find_converter_instance(klass)
|
42
42
|
@find_converter_instance ||= {}
|
43
|
-
@find_converter_instance[klass] ||=
|
44
|
-
|
45
|
-
|
46
|
-
end
|
43
|
+
@find_converter_instance[klass] ||= converters.find do |converter|
|
44
|
+
converter.instance_of?(klass)
|
45
|
+
end || raise("No Converters found for #{klass}")
|
47
46
|
end
|
48
47
|
|
49
48
|
# Create an array of instances of the subclasses of the class
|
@@ -7,7 +7,7 @@ class Bridgetown::Site
|
|
7
7
|
def locale
|
8
8
|
@locale ||= begin
|
9
9
|
locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym
|
10
|
-
Dir[in_source_dir("_locales")
|
10
|
+
Dir["#{in_source_dir("_locales")}/*.yml"].each do |locale_path|
|
11
11
|
I18n.load_path << locale_path
|
12
12
|
end
|
13
13
|
I18n.available_locales = config[:available_locales]
|
@@ -8,7 +8,7 @@ class Bridgetown::Site
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
# Establish an SSR pipeline for a persistent backend process
|
11
|
-
def start_ssr!
|
11
|
+
def start_ssr! # rubocop:todo Metrics/AbcSize
|
12
12
|
if Bridgetown::Current.site
|
13
13
|
raise Bridgetown::Errors::FatalException, "Bridgetown SSR already started! " \
|
14
14
|
"Check your Rack app for threading issues"
|
@@ -25,7 +25,7 @@ class Bridgetown::Site
|
|
25
25
|
# @return [void]
|
26
26
|
def each_site_file
|
27
27
|
%w(generated_pages static_files_to_write resources_to_write).each do |type|
|
28
|
-
send(type).each do |item|
|
28
|
+
send(type).each do |item| # rubocop:disable Style/ExplicitBlockArgument
|
29
29
|
yield item
|
30
30
|
end
|
31
31
|
end
|