bridgetown-core 1.0.0.alpha1 → 1.0.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- 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/start.rb +6 -6
- data/lib/bridgetown-core/commands/webpack.rb +1 -1
- data/lib/bridgetown-core/component.rb +2 -6
- data/lib/bridgetown-core/concerns/liquid_renderable.rb +2 -2
- data/lib/bridgetown-core/concerns/site/configurable.rb +1 -6
- 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 -2
- data/lib/bridgetown-core/converter.rb +1 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +6 -4
- data/lib/bridgetown-core/converters/liquid_templates.rb +2 -0
- 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 +3 -3
- 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/boot.rb +8 -0
- 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/post_url.rb +6 -6
- data/lib/bridgetown-core/tags/render_content.rb +2 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +7 -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
- data/lib/site_template/src/_layouts/default.liquid +1 -1
- metadata +3 -3
- data/lib/bridgetown-core/tags/include.rb +0 -213
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1d25e217de2040b4951a2143b0968808ebcd755055351f1745579d362d57df
|
4
|
+
data.tar.gz: 61f132206080c941392bcd1f0bb995f349cadea050dba16b6c02753471e48706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff3379e1bf073afd9fd9d5d882cea276c3130fa527e64586faba1c91f8e4d5563b8b59f8d4d3f78abe9589f59511d2c68e824803ba314bbf50a1270df07dfd2
|
7
|
+
data.tar.gz: 7a2afb73e70f34cc0e1e68ee0304c2973b760530ae51f4a6700caad90a897e9c636be4216653b6c08d43accaf9c47380f0217805c7e25c5527ccfafb09510d80
|
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
|
@@ -40,6 +40,12 @@ module Bridgetown
|
|
40
40
|
# Load Bridgetown configuration into thread memory
|
41
41
|
bt_options = configuration_with_overrides(options)
|
42
42
|
|
43
|
+
if Bridgetown.env.development? && !options["url"]
|
44
|
+
scheme = bt_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
45
|
+
port = bt_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
46
|
+
bt_options.url = "#{scheme}://localhost:#{port}"
|
47
|
+
end
|
48
|
+
|
43
49
|
puma_pid =
|
44
50
|
Process.fork do
|
45
51
|
require "puma/cli"
|
@@ -83,12 +89,6 @@ module Bridgetown
|
|
83
89
|
Process.setproctitle("bridgetown #{Bridgetown::VERSION} [#{File.basename(Dir.pwd)}]")
|
84
90
|
|
85
91
|
build_args = ["-w"] + ARGV.reject { |arg| arg == "start" }
|
86
|
-
if Bridgetown.env.development? && !options["url"]
|
87
|
-
scheme = bt_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
88
|
-
port = bt_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
89
|
-
build_args << "--url"
|
90
|
-
build_args << "#{scheme}://localhost:#{port}"
|
91
|
-
end
|
92
92
|
Bridgetown::Commands::Build.start(build_args)
|
93
93
|
rescue StandardError => e
|
94
94
|
Process.kill "SIGINT", puma_pid
|
@@ -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
|
|
@@ -30,7 +30,7 @@ module Bridgetown
|
|
30
30
|
#
|
31
31
|
# @param ext [String] erb, slim, etc.
|
32
32
|
def renderer_for_ext(ext, &block)
|
33
|
-
@_tmpl ||= case ext
|
33
|
+
@_tmpl ||= case ext.to_s
|
34
34
|
when "erb"
|
35
35
|
include ERBCapture
|
36
36
|
Tilt::ErubiTemplate.new(component_template_path,
|
@@ -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
|
@@ -14,10 +14,10 @@ module Bridgetown
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def liquid_engine_configured?
|
17
|
-
data["template_engine"] == "liquid" ||
|
17
|
+
data["template_engine"].to_s == "liquid" ||
|
18
18
|
(
|
19
19
|
data["template_engine"].nil? && (
|
20
|
-
site.config[:template_engine].nil? || site.config[:template_engine] == "liquid"
|
20
|
+
site.config[:template_engine].nil? || site.config[:template_engine].to_s == "liquid"
|
21
21
|
)
|
22
22
|
)
|
23
23
|
end
|
@@ -21,7 +21,6 @@ class Bridgetown::Site
|
|
21
21
|
|
22
22
|
configure_cache
|
23
23
|
configure_component_paths
|
24
|
-
configure_include_paths
|
25
24
|
configure_file_read_opts
|
26
25
|
|
27
26
|
self.permalink_style = (config["permalink"] || "pretty").to_sym
|
@@ -165,7 +164,7 @@ class Bridgetown::Site
|
|
165
164
|
dir.is_a?(Array) ? dir : [dir]
|
166
165
|
end
|
167
166
|
local_components_load_paths.map! do |dir|
|
168
|
-
if !!(dir =~ %r
|
167
|
+
if !!(dir =~ %r!^\.\.?/!)
|
169
168
|
# allow ./dir or ../../dir type options
|
170
169
|
File.expand_path(dir.to_s, root_dir)
|
171
170
|
else
|
@@ -176,10 +175,6 @@ class Bridgetown::Site
|
|
176
175
|
@components_load_paths = plugin_components_load_paths + local_components_load_paths
|
177
176
|
end
|
178
177
|
|
179
|
-
def configure_include_paths
|
180
|
-
@includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s))
|
181
|
-
end
|
182
|
-
|
183
178
|
def configure_file_read_opts
|
184
179
|
self.file_read_opts = {}
|
185
180
|
file_read_opts[:encoding] = config["encoding"] if config["encoding"]
|
@@ -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
|
|