bridgetown-core 1.2.0.beta5 → 1.2.0
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/bridgetown-core.gemspec +0 -1
- data/lib/bridgetown-core/commands/plugins.rb +19 -13
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +2 -2
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +5 -1
- data/lib/bridgetown-core/configuration.rb +1 -1
- data/lib/bridgetown-core/liquid_renderer/table.rb +3 -1
- data/lib/bridgetown-core/model/repo_origin.rb +2 -2
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core.rb +42 -0
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599f0ff57d4bac2146e5cacb12ccb8f2e7e02026815447c2db9cbf914ed9d3a2
|
4
|
+
data.tar.gz: be29cede2daa248b4db41bb6a7eaeebb7d3533b54a5cf891922b0762a6ca47e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 739ed852e60fabf0b6b2d352c8ce8993d4751a1f6cfec67c0bb7ed4cc5f0af41bb82fb8dc3eb34f5806a421bcec38e9050cd0fbcb50249a0482f5804e19a1d27
|
7
|
+
data.tar.gz: 97eea9cb28095624a8d47821f754df39790d8db46e62d79774371113c875fd914a796f3e445ad982e6f8de8e94d5babf7b8be1736c4bc93f3a9fe0a0f6862433
|
data/bridgetown-core.gemspec
CHANGED
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.add_runtime_dependency("roda", "~> 3.46")
|
50
50
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
51
51
|
s.add_runtime_dependency("serbea", "~> 1.0")
|
52
|
-
s.add_runtime_dependency("terminal-table", "~> 1.8")
|
53
52
|
s.add_runtime_dependency("thor", "~> 1.1")
|
54
53
|
s.add_runtime_dependency("tilt", "~> 2.0")
|
55
54
|
s.add_runtime_dependency("webrick", "~> 1.7")
|
@@ -126,7 +126,7 @@ module Bridgetown
|
|
126
126
|
Layouts, you'd run:\n
|
127
127
|
bridgetown plugins cd SamplePlugin/Layouts
|
128
128
|
DOC
|
129
|
-
desc "cd <origin/dir>", "Open
|
129
|
+
desc "cd <origin/dir>", "Open content folder within the plugin origin"
|
130
130
|
|
131
131
|
# This is super useful if you want to copy files out of plugins to override.
|
132
132
|
#
|
@@ -177,38 +177,43 @@ module Bridgetown
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
desc "new NAME", "Create a new plugin NAME
|
180
|
+
desc "new NAME", "Create a new plugin NAME (snake_case_name_preferred)"
|
181
181
|
def new(name)
|
182
182
|
folder_name = name.underscore
|
183
183
|
module_name = folder_name.camelize
|
184
184
|
|
185
|
-
run "git clone
|
186
|
-
new_gemspec = "#{
|
185
|
+
run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
186
|
+
new_gemspec = "#{folder_name}.gemspec"
|
187
187
|
|
188
188
|
inside name do # rubocop:todo Metrics/BlockLength
|
189
189
|
destroy_existing_repo
|
190
190
|
initialize_new_repo
|
191
191
|
|
192
|
-
FileUtils.mv "
|
192
|
+
FileUtils.mv "sample_plugin.gemspec", new_gemspec
|
193
193
|
gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
194
194
|
gsub_file new_gemspec, "bridgetown-sample-plugin", name
|
195
|
-
gsub_file new_gemspec, "
|
195
|
+
gsub_file new_gemspec, "sample_plugin", folder_name
|
196
196
|
gsub_file new_gemspec, "SamplePlugin", module_name
|
197
197
|
|
198
198
|
gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
199
199
|
gsub_file "package.json", "bridgetown-sample-plugin", name
|
200
|
+
gsub_file "package.json", "sample_plugin", folder_name
|
200
201
|
|
201
202
|
FileUtils.mv "lib/sample_plugin.rb", "lib/#{folder_name}.rb"
|
202
|
-
gsub_file "lib/#{
|
203
|
-
gsub_file "lib/#{
|
203
|
+
gsub_file "lib/#{folder_name}.rb", "sample_plugin", folder_name
|
204
|
+
gsub_file "lib/#{folder_name}.rb", "SamplePlugin", module_name
|
204
205
|
|
205
206
|
FileUtils.mv "lib/sample_plugin", "lib/#{folder_name}"
|
206
|
-
gsub_file "lib/#{
|
207
|
-
gsub_file "lib/#{
|
207
|
+
gsub_file "lib/#{folder_name}/builder.rb", "SamplePlugin", module_name
|
208
|
+
gsub_file "lib/#{folder_name}/builder.rb", "sample_plugin", folder_name
|
209
|
+
gsub_file "lib/#{folder_name}/version.rb", "SamplePlugin", module_name
|
208
210
|
|
209
211
|
FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb"
|
210
212
|
gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name
|
211
|
-
gsub_file "test/
|
213
|
+
gsub_file "test/test_#{folder_name}.rb", "sample plugin", module_name
|
214
|
+
gsub_file "test/helper.rb", "sample_plugin", folder_name
|
215
|
+
gsub_file "test/fixtures/src/index.html", "sample_plugin", folder_name
|
216
|
+
gsub_file "test/fixtures/config/initializers.rb", "sample_plugin", folder_name
|
212
217
|
|
213
218
|
FileUtils.mv "components/sample_plugin", "components/#{folder_name}"
|
214
219
|
FileUtils.mv "content/sample_plugin", "content/#{folder_name}"
|
@@ -220,14 +225,15 @@ module Bridgetown
|
|
220
225
|
|
221
226
|
gsub_file "components/#{folder_name}/plugin_component.rb", "SamplePlugin", module_name
|
222
227
|
|
223
|
-
gsub_file "frontend/javascript/index.js", "
|
228
|
+
gsub_file "frontend/javascript/index.js", "sample_plugin", folder_name
|
224
229
|
gsub_file "frontend/javascript/index.js", "SamplePlugin", module_name
|
230
|
+
gsub_file "frontend/styles/index.css", "sample_plugin", folder_name
|
225
231
|
end
|
226
232
|
say ""
|
227
233
|
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
228
234
|
say_status "Remember:", "Don't forget to rename the SamplePlugin" \
|
229
235
|
" code identifiers and paths to your own" \
|
230
|
-
"
|
236
|
+
" identifier, as well as update your README" \
|
231
237
|
" and CHANGELOG files as necessary."
|
232
238
|
end
|
233
239
|
|
@@ -9,9 +9,9 @@ module Bridgetown
|
|
9
9
|
|
10
10
|
YAML_HEADER = %r!\A---\s*\n!.freeze
|
11
11
|
YAML_BLOCK = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze
|
12
|
-
RUBY_HEADER = %r!\A[
|
12
|
+
RUBY_HEADER = %r!\A[~`#-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
|
13
13
|
RUBY_BLOCK =
|
14
|
-
%r!#{RUBY_HEADER.source}(.*?\n?)^((?:%>|%})?[
|
14
|
+
%r!#{RUBY_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#-]{3,}\s*$\n?)!m.freeze
|
15
15
|
|
16
16
|
def read_front_matter(file_path) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
17
17
|
file_contents = File.read(
|
@@ -72,6 +72,10 @@ module Bridgetown
|
|
72
72
|
@scope.roda_initializers << block
|
73
73
|
end
|
74
74
|
|
75
|
+
def timezone(tz) # rubocop:disable Naming/MethodParameterName
|
76
|
+
Bridgetown.set_timezone(tz)
|
77
|
+
end
|
78
|
+
|
75
79
|
def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
|
76
80
|
return get(key) if value.empty? && block.nil?
|
77
81
|
|
@@ -132,7 +136,7 @@ module Bridgetown
|
|
132
136
|
|
133
137
|
if require_initializer
|
134
138
|
init_file_name = File.join(@scope.root_dir, "config", "#{name}.rb")
|
135
|
-
|
139
|
+
load(init_file_name) if File.exist?(init_file_name)
|
136
140
|
end
|
137
141
|
|
138
142
|
@scope.initializers[name.to_sym]
|
@@ -134,7 +134,7 @@ module Bridgetown
|
|
134
134
|
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
135
135
|
return unless File.file?(initializers_file)
|
136
136
|
|
137
|
-
|
137
|
+
load initializers_file
|
138
138
|
|
139
139
|
return unless initializers # no initializers have been set up
|
140
140
|
|
@@ -7,9 +7,9 @@ module Bridgetown
|
|
7
7
|
include Bridgetown::Utils::RubyFrontMatterDSL
|
8
8
|
|
9
9
|
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m.freeze
|
10
|
-
RUBY_FRONT_MATTER_HEADER = %r!\A[
|
10
|
+
RUBY_FRONT_MATTER_HEADER = %r!\A[~`#-]{3,}(?:ruby|<%|{%)\s*\n!.freeze
|
11
11
|
RUBY_FRONT_MATTER_REGEXP =
|
12
|
-
%r!#{RUBY_FRONT_MATTER_HEADER.source}(.*?\n?)^((?:%>|%})?[
|
12
|
+
%r!#{RUBY_FRONT_MATTER_HEADER.source}(.*?\n?)^((?:%>|%})?[~`#-]{3,}\s*$\n?)!m.freeze
|
13
13
|
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :content
|
data/lib/bridgetown-core.rb
CHANGED
@@ -136,6 +136,8 @@ module Bridgetown
|
|
136
136
|
end
|
137
137
|
alias_method :env, :environment
|
138
138
|
|
139
|
+
# Set up the Bridgetown execution environment before attempting to load any
|
140
|
+
# plugins or gems prior to a site build
|
139
141
|
def begin!
|
140
142
|
ENV["RACK_ENV"] ||= environment
|
141
143
|
|
@@ -178,6 +180,38 @@ module Bridgetown
|
|
178
180
|
end
|
179
181
|
end
|
180
182
|
|
183
|
+
# Initialize a preflight configuration object, copying initializers and
|
184
|
+
# source manifests from a previous standard configuration if necessary.
|
185
|
+
# Typically only needed in test suites to reset before a new test.
|
186
|
+
#
|
187
|
+
# @return [Bridgetown::Configuration::Preflight]
|
188
|
+
def reset_configuration! # rubocop:disable Metrics/AbcSize
|
189
|
+
if Bridgetown::Current.preloaded_configuration.nil?
|
190
|
+
return Bridgetown::Current.preloaded_configuration =
|
191
|
+
Bridgetown::Configuration::Preflight.new
|
192
|
+
end
|
193
|
+
|
194
|
+
return unless Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration)
|
195
|
+
|
196
|
+
previous_config = Bridgetown::Current.preloaded_configuration
|
197
|
+
new_config = Bridgetown::Configuration::Preflight.new
|
198
|
+
new_config.initializers = previous_config.initializers
|
199
|
+
new_config.source_manifests = previous_config.source_manifests
|
200
|
+
if new_config.initializers
|
201
|
+
new_config.initializers.delete(:init)
|
202
|
+
new_config.initializers.select! do |_k, initializer|
|
203
|
+
next false if initializer.block.source_location[0].start_with?(
|
204
|
+
File.join(previous_config.root_dir, "config")
|
205
|
+
)
|
206
|
+
|
207
|
+
initializer.completed = false
|
208
|
+
true
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
Bridgetown::Current.preloaded_configuration = new_config
|
213
|
+
end
|
214
|
+
|
181
215
|
def initializer(name, prepend: false, replace: false, &block) # rubocop:todo Metrics
|
182
216
|
unless Bridgetown::Current.preloaded_configuration
|
183
217
|
raise "The `#{name}' initializer in #{block.source_location[0]} was called " \
|
@@ -276,6 +310,14 @@ module Bridgetown
|
|
276
310
|
def set_timezone(timezone)
|
277
311
|
ENV["TZ"] = timezone
|
278
312
|
end
|
313
|
+
|
314
|
+
# Get the current TZ environment variable
|
315
|
+
#
|
316
|
+
# @return [String]
|
317
|
+
def timezone
|
318
|
+
ENV["TZ"]
|
319
|
+
end
|
320
|
+
|
279
321
|
# rubocop:enable Naming/AccessorMethodName
|
280
322
|
|
281
323
|
# Fetch the logger instance for this Bridgetown process.
|
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
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -274,20 +274,6 @@ dependencies:
|
|
274
274
|
- - "~>"
|
275
275
|
- !ruby/object:Gem::Version
|
276
276
|
version: '1.0'
|
277
|
-
- !ruby/object:Gem::Dependency
|
278
|
-
name: terminal-table
|
279
|
-
requirement: !ruby/object:Gem::Requirement
|
280
|
-
requirements:
|
281
|
-
- - "~>"
|
282
|
-
- !ruby/object:Gem::Version
|
283
|
-
version: '1.8'
|
284
|
-
type: :runtime
|
285
|
-
prerelease: false
|
286
|
-
version_requirements: !ruby/object:Gem::Requirement
|
287
|
-
requirements:
|
288
|
-
- - "~>"
|
289
|
-
- !ruby/object:Gem::Version
|
290
|
-
version: '1.8'
|
291
277
|
- !ruby/object:Gem::Dependency
|
292
278
|
name: thor
|
293
279
|
requirement: !ruby/object:Gem::Requirement
|
@@ -615,9 +601,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
615
601
|
version: 2.7.0
|
616
602
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
617
603
|
requirements:
|
618
|
-
- - "
|
604
|
+
- - ">="
|
619
605
|
- !ruby/object:Gem::Version
|
620
|
-
version:
|
606
|
+
version: '0'
|
621
607
|
requirements: []
|
622
608
|
rubygems_version: 3.1.4
|
623
609
|
signing_key:
|