bridgetown-core 1.2.0.beta4 → 1.2.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bridgetown-core/collection.rb +1 -1
- data/lib/bridgetown-core/commands/concerns/actions.rb +5 -4
- data/lib/bridgetown-core/commands/start.rb +1 -0
- data/lib/bridgetown-core/concerns/localizable.rb +5 -1
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +1 -1
- data/lib/bridgetown-core/configuration.rb +6 -3
- data/lib/bridgetown-core/drops/static_file_drop.rb +1 -1
- data/lib/bridgetown-core/helpers.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +2 -1
- data/lib/bridgetown-core/rack/static_indexes.rb +4 -4
- data/lib/bridgetown-core/resource/base.rb +1 -1
- data/lib/bridgetown-core/static_file.rb +6 -4
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +2 -2
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core.rb +1 -0
- data/lib/site_template/config/puma.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db2117b99eb2b2943920e6cbfe4267b2a668842de44e360df645da6554ea877
|
4
|
+
data.tar.gz: b8e3652ab12db38512546612a74df6939bd841166d9cfae371aa75d6ae8d8265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 446f796d17a209b19afdb9d8f349d1e5197d7f5600598bc21be3c23c73df7d10c125379d739bd608322d404365ca37b4a37cbe9b38fa8bdd22a97c84c41bee7c
|
7
|
+
data.tar.gz: 89293450447e8acb5718cdcdc782124699faa138c559474c5df66609715163fca809d4ed477cf5ee75b905f62e0bcbd540f62a46841b8c58fede225670ae429b
|
@@ -27,7 +27,7 @@ module Bridgetown
|
|
27
27
|
|
28
28
|
def javascript_import(data = nil, filename: "index.js") # rubocop:todo Metrics/PerceivedComplexity
|
29
29
|
data ||= yield if block_given?
|
30
|
-
data += "\n" unless data
|
30
|
+
data += "\n" unless data[-1] == "\n"
|
31
31
|
|
32
32
|
say_status :javascript_import, filename
|
33
33
|
|
@@ -56,8 +56,9 @@ module Bridgetown
|
|
56
56
|
options = +""
|
57
57
|
options += " -v \"#{version}\"" if version
|
58
58
|
options += " -g #{group}" if group
|
59
|
+
# in_bundle? returns the path to the gemfile
|
59
60
|
run "bundle add #{gemname}#{options}",
|
60
|
-
env: { "BUNDLE_GEMFILE" =>
|
61
|
+
env: { "BUNDLE_GEMFILE" => Bundler::SharedHelpers.in_bundle? }
|
61
62
|
rescue SystemExit
|
62
63
|
say_status :run, "Gem not added due to bundler error", :red
|
63
64
|
end
|
@@ -68,7 +69,7 @@ module Bridgetown
|
|
68
69
|
data = yield if block_given?
|
69
70
|
data = data.indent(2).lstrip
|
70
71
|
data = " #{data}" unless data.start_with?(",")
|
71
|
-
data += "\n" unless data
|
72
|
+
data += "\n" unless data[-1] == "\n"
|
72
73
|
|
73
74
|
init_file = File.join("config", "initializers.rb")
|
74
75
|
unless File.exist?(init_file)
|
@@ -85,7 +86,7 @@ module Bridgetown
|
|
85
86
|
say_status :configure, name
|
86
87
|
data = yield if block_given?
|
87
88
|
data = data.indent(2)
|
88
|
-
data += "\n" unless data
|
89
|
+
data += "\n" unless data[-1] == "\n"
|
89
90
|
|
90
91
|
init_file = File.join("config", "initializers.rb")
|
91
92
|
unless File.exist?(init_file)
|
@@ -42,6 +42,7 @@ module Bridgetown
|
|
42
42
|
# Load Bridgetown configuration into thread memory
|
43
43
|
bt_options = configuration_with_overrides(options)
|
44
44
|
|
45
|
+
# Set a local site URL in the config if one is not available
|
45
46
|
if Bridgetown.env.development? && !options["url"]
|
46
47
|
scheme = bt_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
47
48
|
port = bt_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
@@ -12,7 +12,11 @@ module Bridgetown
|
|
12
12
|
[]
|
13
13
|
end
|
14
14
|
|
15
|
-
result_set.select
|
15
|
+
matching_resources = result_set.select do |item|
|
16
|
+
item.relative_path.parent == relative_path.parent && item.data.slug == data.slug
|
17
|
+
end
|
18
|
+
|
19
|
+
matching_resources.sort_by do |item|
|
16
20
|
site.config.available_locales.index item.data.locale
|
17
21
|
end
|
18
22
|
end
|
@@ -73,7 +73,7 @@ module Bridgetown
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
|
76
|
-
return get(key) if value.
|
76
|
+
return get(key) if value.empty? && block.nil?
|
77
77
|
|
78
78
|
set(key, value[0], &block)
|
79
79
|
end
|
@@ -130,7 +130,7 @@ module Bridgetown
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
def run_initializers!(context:)
|
133
|
+
def run_initializers!(context:) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
|
134
134
|
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
135
135
|
return unless File.file?(initializers_file)
|
136
136
|
|
@@ -144,9 +144,11 @@ module Bridgetown
|
|
144
144
|
Bridgetown.logger.debug "Initializing:", "Running initializers with `#{context}' context in:"
|
145
145
|
Bridgetown.logger.debug "", initializers_file
|
146
146
|
self.init_params = {}
|
147
|
+
cached_url = url&.include?("//localhost") ? url : nil
|
147
148
|
dsl = ConfigurationDSL.new(scope: self, data: self)
|
148
149
|
dsl.instance_variable_set(:@context, context)
|
149
150
|
dsl.instance_exec(dsl, &init_init.block)
|
151
|
+
self.url = cached_url if cached_url # restore local development URL if need be
|
150
152
|
|
151
153
|
setup_load_paths! appending: true
|
152
154
|
|
@@ -308,7 +310,8 @@ module Bridgetown
|
|
308
310
|
next_config
|
309
311
|
rescue SystemCallError
|
310
312
|
if @default_config_file ||= nil
|
311
|
-
|
313
|
+
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
314
|
+
Bridgetown.logger.warn "Configuration file:", "none" unless File.file?(initializers_file)
|
312
315
|
{}
|
313
316
|
else
|
314
317
|
Bridgetown.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
@@ -400,7 +403,7 @@ module Bridgetown
|
|
400
403
|
|
401
404
|
DEFAULT_EXCLUDES = %w(
|
402
405
|
.sass-cache .bridgetown-cache
|
403
|
-
gemfiles Gemfile Gemfile.lock
|
406
|
+
gemfiles Gemfile Gemfile.lock gems.rb gems.locked
|
404
407
|
node_modules
|
405
408
|
vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/
|
406
409
|
).freeze
|
@@ -4,7 +4,7 @@ module Bridgetown
|
|
4
4
|
module Drops
|
5
5
|
class StaticFileDrop < Drop
|
6
6
|
extend Forwardable
|
7
|
-
def_delegators :@obj, :name, :extname, :modified_time, :basename
|
7
|
+
def_delegators :@obj, :name, :extname, :date, :modified_time, :basename
|
8
8
|
def_delegator :@obj, :relative_path, :path
|
9
9
|
def_delegator :@obj, :type, :collection
|
10
10
|
|
@@ -59,7 +59,7 @@ module Bridgetown
|
|
59
59
|
# `url` or `relative_url`
|
60
60
|
# @return [String] the permalink URL for the file
|
61
61
|
def url_for(relative_path)
|
62
|
-
if relative_path.respond_to?(:relative_url)
|
62
|
+
if relative_path.respond_to?(:relative_url)
|
63
63
|
return safe(relative_path.relative_url) # new resource engine
|
64
64
|
elsif relative_path.respond_to?(:url)
|
65
65
|
return safe(relative_url(relative_path.url)) # old legacy engine
|
@@ -61,7 +61,8 @@ module Bridgetown
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.setup_bundler(skip_yarn: false)
|
64
|
-
if !ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] &&
|
64
|
+
if !ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] &&
|
65
|
+
(Bundler::SharedHelpers.in_bundle? || Bridgetown.env.test?)
|
65
66
|
require "bundler"
|
66
67
|
|
67
68
|
require_relative "utils/initializers"
|
@@ -14,10 +14,10 @@ Roda::RodaPlugins::Public::RequestMethods.module_eval do
|
|
14
14
|
seg == ".." ? segments.pop : segments << seg
|
15
15
|
end
|
16
16
|
|
17
|
-
path =
|
18
|
-
unless
|
19
|
-
path =
|
20
|
-
if
|
17
|
+
path = File.join(roda_class.opts[:public_root], *segments)
|
18
|
+
unless File.file?(path)
|
19
|
+
path = File.join(path, "index.html")
|
20
|
+
if File.file?(path)
|
21
21
|
segments << "index.html"
|
22
22
|
else
|
23
23
|
segments[segments.size - 1] = "#{segments.last}.html"
|
@@ -373,7 +373,7 @@ module Bridgetown
|
|
373
373
|
found_locale = data.language || data.lang || basename_without_ext.split(".")[1..].last
|
374
374
|
return unless found_locale && site.config.available_locales.include?(found_locale.to_sym)
|
375
375
|
|
376
|
-
found_locale
|
376
|
+
found_locale.to_sym
|
377
377
|
end
|
378
378
|
|
379
379
|
def format_url(url)
|
@@ -73,6 +73,8 @@ module Bridgetown
|
|
73
73
|
@modified_time ||= File.stat(path).mtime
|
74
74
|
end
|
75
75
|
|
76
|
+
alias_method :date, :modified_time
|
77
|
+
|
76
78
|
# Returns last modification time for this file.
|
77
79
|
def mtime
|
78
80
|
modified_time.to_i
|
@@ -119,12 +121,12 @@ module Bridgetown
|
|
119
121
|
@to_liquid ||= Drops::StaticFileDrop.new(self)
|
120
122
|
end
|
121
123
|
|
122
|
-
# Generate "basename without extension" and strip away any trailing periods.
|
123
|
-
# NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`)
|
124
124
|
def basename
|
125
|
-
@basename ||= File.basename(name,
|
125
|
+
@basename ||= File.basename(name, ".*")
|
126
126
|
end
|
127
127
|
|
128
|
+
alias_method :basename_without_ext, :basename
|
129
|
+
|
128
130
|
def relative_path_basename_without_prefix
|
129
131
|
return_path = Pathname.new("")
|
130
132
|
Pathname.new(cleaned_relative_path).each_filename do |filename|
|
@@ -185,7 +187,7 @@ module Bridgetown
|
|
185
187
|
|
186
188
|
# Returns the type of the collection if present, nil otherwise.
|
187
189
|
def type
|
188
|
-
@type ||= @collection
|
190
|
+
@type ||= @collection&.label&.to_sym
|
189
191
|
end
|
190
192
|
|
191
193
|
# Returns the front matter defaults defined for the file's URL and/or type
|
@@ -14,9 +14,9 @@ module Bridgetown
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def method_missing(key, *value, &block) # rubocop:disable Metrics/CyclomaticComplexity, Style/MissingRespondToMissing
|
17
|
-
return super if respond_to?(key) || (value.
|
17
|
+
return super if respond_to?(key) || (value.empty? && block.nil? && !@data.key?(key))
|
18
18
|
|
19
|
-
return get(key) if value.
|
19
|
+
return get(key) if value.empty? && block.nil? && @data.key?(key)
|
20
20
|
|
21
21
|
set(key, value[0], &block)
|
22
22
|
end
|
data/lib/bridgetown-core.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Puma is a fast, concurrent web server for Ruby & Rack
|
2
2
|
#
|
3
3
|
# Learn more at: https://puma.io
|
4
|
+
# Bridgetown configuration documentation:
|
5
|
+
# https://edge.bridgetownrb.com/docs/configuration/puma
|
6
|
+
|
7
|
+
# This port number can be overriden by a bind configuration option
|
4
8
|
#
|
5
9
|
port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
|
6
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|