bridgetown-core 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 556799feca958f64e151dff3c039cc98240bc611a60cf650e3658f50490dcf79
4
- data.tar.gz: 74bed3c07355d9b54107ce92334a0cf32a4d8909dd002efdeb4cbf6b0a729128
3
+ metadata.gz: d46961118b45c011dc48d776d5e3f451d761850930074608cfee29263b4e7a88
4
+ data.tar.gz: 2f5bea8f1c837c05c7376dce35951543510abcef5ccc82f7b37061e3b4bcade4
5
5
  SHA512:
6
- metadata.gz: 8617f84687052ac6ed4b2413bbb4418fc3a332395fd647902379e75e4d22857d43a49edb30b8dbbb8aad7fe067412ad6c397fe0a05fd73ab5b3d3ea6866a7c55
7
- data.tar.gz: 6c60464867cfb5fe8baf9e86d983a5392075a92f278f30499c68e1a1dec58b3be53991b7725b31de0c445f4afd448ca0056aa1841ecce79b2daa857c5cb43f6f
6
+ metadata.gz: e6e13e95c141d995d83dab36e5419e63b359c1065416920396c51235f3e728f0c8f6cb17d4088cd71649662d9b814e04ce70d56bd8416058ba31038865a0fee3
7
+ data.tar.gz: 0e64b349975e75e2d49af405288343ea54a39d9f894be7a4b51895becc72afd09ee138b69ca0f0ed3cf6d814842b60b2dbdf43f9fe6be20fe0f42364f21259da
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  s.add_runtime_dependency("listen", "~> 3.0")
49
49
  s.add_runtime_dependency("rake", ">= 13.0")
50
50
  s.add_runtime_dependency("roda", "~> 3.46")
51
- s.add_runtime_dependency("rouge", "~> 3.0")
51
+ s.add_runtime_dependency("rouge", [">= 3.0", "< 5.0"])
52
52
  s.add_runtime_dependency("serbea", "~> 1.0")
53
53
  s.add_runtime_dependency("thor", "~> 1.1")
54
54
  s.add_runtime_dependency("tilt", "~> 2.0")
@@ -2,17 +2,11 @@
2
2
 
3
3
  module Bridgetown
4
4
  module ConsoleMethods
5
- def site
6
- Bridgetown::Current.site
7
- end
8
-
9
- def collections
10
- site.collections
11
- end
12
-
13
5
  def reload!
14
6
  Bridgetown.logger.info "Reloading site..."
15
7
 
8
+ site = Bridgetown::Current.site
9
+
16
10
  I18n.reload! # make sure any locale files get read again
17
11
  Bridgetown::Hooks.trigger :site, :pre_reload, site
18
12
  Bridgetown::Hooks.clear_reloadable_hooks
@@ -99,6 +93,8 @@ module Bridgetown
99
93
  IRB::ExtendCommandBundle.include ConsoleMethods
100
94
  IRB.setup(nil)
101
95
  workspace = IRB::WorkSpace.new
96
+ workspace.main.define_singleton_method(:site) { Bridgetown::Current.site }
97
+ workspace.main.define_singleton_method(:collections) { site.collections }
102
98
  irb = IRB::Irb.new(workspace)
103
99
  IRB.conf[:IRB_RC]&.call(irb.context)
104
100
  IRB.conf[:MAIN_CONTEXT] = irb.context
@@ -6,5 +6,5 @@
6
6
  "$javascript/*": ["./frontend/javascript/*"],
7
7
  "$components/*": ["./src/_components/*"]
8
8
  }
9
- },
9
+ },
10
10
  }
@@ -1,5 +1,17 @@
1
+ [dev]
2
+ command = "bin/bridgetown dev"
3
+ targetPort = 4000
4
+ port = 8888
5
+ publish = "output"
6
+ autoLaunch = true
7
+ framework = "#custom"
8
+
9
+ [context.dev.build.environment]
10
+ NODE_ENV = "development"
11
+ BRIDGETOWN_ENV = "development"
12
+
1
13
  [build]
2
- command = "bin/bridgetown deploy && bin/netlify.sh"
14
+ command = "bin/bridgetown deploy"
3
15
  publish = "output"
4
16
 
5
17
  [build.environment]
@@ -19,14 +31,6 @@
19
31
  Referrer-Policy = "no-referrer-when-downgrade"
20
32
  Cache-Control = "public, max-age=604800, s-max-age=604800"
21
33
 
22
- [[headers]]
23
- for = "/"
24
- [headers.values]
25
- Link = [
26
- "<CSS_PATH>; rel=preload; as=style",
27
- "<JS_PATH>; rel=preload; as=script"
28
- ]
29
-
30
34
  [[headers]]
31
35
  for = "/*.(png|jpg|js|css|svg|woff|ttf|eot|ico|woff2)"
32
36
  [headers.values]
@@ -1,5 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  copy_file in_templates_dir("netlify.toml"), "netlify.toml"
4
- copy_file in_templates_dir("netlify.sh"), "bin/netlify.sh"
5
- `chmod a+x ./bin/netlify.sh`
@@ -37,8 +37,8 @@ append_to_file(File.join(javascript_dir, "index.js")) do
37
37
  if (filename.includes("_controller.") || filename.includes("-controller.")) {
38
38
  const identifier = filename.replace("./controllers/", "")
39
39
  .replace(/[_-]controller\\..*$/, "")
40
- .replace("_", "-")
41
- .replace("/", "--")
40
+ .replace(/_/g, "-")
41
+ .replace(/\\//g, "--")
42
42
 
43
43
  Stimulus.register(identifier, controller.default)
44
44
  }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/html_safe_translation"
4
+
3
5
  module Bridgetown
4
6
  class RubyTemplateView
5
7
  class Helpers
@@ -128,21 +130,49 @@ module Bridgetown
128
130
  safe(segments.join(" "))
129
131
  end
130
132
 
131
- # Forward all arguments to I18n.t method
133
+ # Delegates to <tt>I18n#translate</tt> but also performs two additional
134
+ # functions.
135
+ #
136
+ # First, if the key starts with a period <tt>translate</tt> will scope
137
+ # the key by the current view. Calling <tt>translate(".foo")</tt> from
138
+ # the <tt>people/index.html.erb</tt> template is equivalent to calling
139
+ # <tt>translate("people.index.foo")</tt>. This makes it less
140
+ # repetitive to translate many keys within the same view and provides
141
+ # a convention to scope keys consistently.
142
+ #
143
+ # Second, the translation will be marked as <tt>html_safe</tt> if the key
144
+ # has the suffix "_html" or the last element of the key is "html". Calling
145
+ # <tt>translate("footer_html")</tt> or <tt>translate("footer.html")</tt>
146
+ # will return an HTML safe string that won't be escaped by other HTML
147
+ # helper methods. This naming convention helps to identify translations
148
+ # that include HTML tags so that you know what kind of output to expect
149
+ # when you call translate in a template and translators know which keys
150
+ # they can provide HTML values for.
132
151
  #
133
152
  # @return [String] the translated string
134
153
  # @see I18n
135
- def t(*args, **kwargs)
136
- I18n.send :t, *args, **kwargs
154
+ def translate(key, **options) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
155
+ return key.map { |k| translate(k, **options) } if key.is_a?(Array)
156
+
157
+ key = key&.to_s
158
+
159
+ if key&.start_with?(".")
160
+ view_path = view&.page&.relative_path&.to_s&.split(".")&.first
161
+ key = "#{view_path.tr("/", ".")}#{key}" if view_path.present?
162
+ end
163
+
164
+ ActiveSupport::HtmlSafeTranslation.translate(key, **options)
137
165
  end
166
+ alias_method :t, :translate
138
167
 
139
- # Forward all arguments to I18n.l method
168
+ # Delegates to <tt>I18n.localize</tt> with no additional functionality.
140
169
  #
141
170
  # @return [String] the localized string
142
171
  # @see I18n
143
- def l(*args, **kwargs)
144
- I18n.send :l, *args, **kwargs
172
+ def localize(...)
173
+ I18n.localize(...)
145
174
  end
175
+ alias_method :l, :localize
146
176
 
147
177
  # For template contexts where ActiveSupport's output safety is loaded, we
148
178
  # can ensure a string has been marked safe
@@ -39,9 +39,11 @@ module Bridgetown
39
39
  end
40
40
 
41
41
  # TODO: this could probably be refactored to work like the above
42
- ActiveSupport::DescendantsTracker.class_variable_get(
43
- :@@direct_descendants
44
- )[value.superclass]&.reject! { _1 == value }
42
+ if ActiveSupport::DescendantsTracker.class_variables.include?(:@@direct_descendants)
43
+ ActiveSupport::DescendantsTracker.class_variable_get(
44
+ :@@direct_descendants
45
+ )[value.superclass]&.reject! { _1 == value }
46
+ end
45
47
  end
46
48
 
47
49
  def setup_loaders(autoload_paths = []) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  CODE_NAME = "Kelly Butte"
6
6
  end
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ module.exports = {
2
2
  plugins: {
3
3
  'postcss-flexbugs-fixes': {},
4
4
  'postcss-preset-env': {
@@ -8,4 +8,4 @@ module.exports = {
8
8
  stage: 3
9
9
  }
10
10
  }
11
- }
11
+ }
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.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-02 00:00:00.000000000 Z
11
+ date: 2024-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -264,16 +264,22 @@ dependencies:
264
264
  name: rouge
265
265
  requirement: !ruby/object:Gem::Requirement
266
266
  requirements:
267
- - - "~>"
267
+ - - ">="
268
268
  - !ruby/object:Gem::Version
269
269
  version: '3.0'
270
+ - - "<"
271
+ - !ruby/object:Gem::Version
272
+ version: '5.0'
270
273
  type: :runtime
271
274
  prerelease: false
272
275
  version_requirements: !ruby/object:Gem::Requirement
273
276
  requirements:
274
- - - "~>"
277
+ - - ">="
275
278
  - !ruby/object:Gem::Version
276
279
  version: '3.0'
280
+ - - "<"
281
+ - !ruby/object:Gem::Version
282
+ version: '5.0'
277
283
  - !ruby/object:Gem::Dependency
278
284
  name: serbea
279
285
  requirement: !ruby/object:Gem::Requirement
@@ -415,7 +421,6 @@ files:
415
421
  - lib/bridgetown-core/configurations/lit/lit-ssr.config.js
416
422
  - lib/bridgetown-core/configurations/minitesting.rb
417
423
  - lib/bridgetown-core/configurations/netlify.rb
418
- - lib/bridgetown-core/configurations/netlify/netlify.sh
419
424
  - lib/bridgetown-core/configurations/netlify/netlify.toml
420
425
  - lib/bridgetown-core/configurations/open-props.rb
421
426
  - lib/bridgetown-core/configurations/open-props/variables.css.erb
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Taken from https://docs.netlify.com/configure-builds/file-based-configuration/#inject-environment-variable-values
3
-
4
- echo "Updating netlify.toml with references to our built files"
5
-
6
- CSS_PATH=`find output/_bridgetown/static/*.css -type f | sed -e 's,output\/,/,g'`
7
- JS_PATH=`find output/_bridgetown/static/*.js -type f | sed -e 's,output\/,/,g'`
8
-
9
- echo "CSS Path: ${CSS_PATH}"
10
- echo "JS Path: ${JS_PATH}"
11
-
12
- sed -i s,CSS_PATH,${CSS_PATH},g netlify.toml
13
- sed -i s,JS_PATH,${JS_PATH},g netlify.toml