bridgetown-core 1.3.0 → 1.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90337c7726115f901df3009e9e2d4b528e8439850ac995c38e2cfec4aca38109
4
- data.tar.gz: 7f32a5135963a21cd915e3a2dd37576daed3c1a9783feb3c236bc5c73b0b138a
3
+ metadata.gz: 97de36caa078103a75226bcc77072ba86c958e58f77a22fb7282fe4d1ef4ef22
4
+ data.tar.gz: e3fc1723d1c4acc2b3f715ba138de15c77ad0cabaeaca75bf8e5b9b359f61cdb
5
5
  SHA512:
6
- metadata.gz: 94c3185a2170a979aaa6434b5f36e45e9e73fc331aa42ede507ad559b2dc4abee70f7b8c77b8349a6a7449bd17e15f8ea1a47f6356a7a577829342623c09f84e
7
- data.tar.gz: 0d03a222870a2a66184498a04681e0b90252602d580e46b90208b10a76528543854ba4a5c6113fe623fead0dc95d49cf0e052cdc20466101ece87223c85e4134
6
+ metadata.gz: 8d19ca716967ef3aae5a991a965ecd89805eb05135ebf8a87c0e320421986b4a2275c63eedf7dcdb41dd35b77c497bb823501849cf824432010a6f9f63d8e315
7
+ data.tar.gz: 4b06864b42beb7693c50ee75853ad3c4237fc997d8570d5ea5eb8bc41b19af3d12740b58204d0320475b9b1cbf823847dc7449d54ea20819c3b2b954443a2516
@@ -5,5 +5,5 @@ copy_file "jsconfig.json"
5
5
  say "🎉 esbuild configuration updated successfully!"
6
6
  say "You may need to add `$styles/` to the front of your main CSS imports."
7
7
  say "See https://www.bridgetownrb.com/docs/frontend-assets#esbuild-setup for details."
8
- say "⚠️ Don't forget to update the esbuild version in your `package.json` file to \"^0.17.19\""
8
+ say "⚠️ Don't forget to update the esbuild version in your `package.json` file to \"^0.19.2\""
9
9
  say "and run `yarn install`!"
@@ -41,6 +41,7 @@ module Bridgetown
41
41
  category: { key: "categories", title: "Category" }, tag: { key: "tags", title: "Tag" },
42
42
  },
43
43
  "autoload_paths" => [],
44
+ "inflector" => nil,
44
45
  "eager_load_paths" => [],
45
46
  "autoloader_collapsed_paths" => [],
46
47
  "additional_watch_paths" => [],
@@ -202,7 +202,8 @@ module Bridgetown
202
202
  return self[key] if key?(key)
203
203
  raise KeyError, %(key not found: "#{key}") if default.nil? && block.nil?
204
204
  return yield(key) unless block.nil?
205
- return default unless default.nil?
205
+
206
+ default unless default.nil?
206
207
  end
207
208
 
208
209
  private
@@ -3,8 +3,34 @@
3
3
  module Bridgetown
4
4
  module Filters
5
5
  module LocalizationFilters
6
- def l(input)
7
- I18n.l(input.to_s)
6
+ def l(input, format = nil, locale = nil)
7
+ date = Liquid::Utils.to_date(input)
8
+ return input if date.nil?
9
+
10
+ format = maybe_symbolized(format, date)
11
+ locale ||= maybe_locale(format)
12
+ format = nil if locale == format
13
+
14
+ I18n.l(date, format: format, locale: locale)
15
+ end
16
+
17
+ private
18
+
19
+ def maybe_locale(format)
20
+ return if format.nil?
21
+
22
+ Bridgetown::Current.site.config.available_locales.include?(format.to_sym) ? format : nil
23
+ end
24
+
25
+ def maybe_symbolized(format, object)
26
+ return if format.nil?
27
+
28
+ type = type_of(object)
29
+ I18n.t("#{type}.formats").key?(format.to_sym) ? format.to_sym : format
30
+ end
31
+
32
+ def type_of(object)
33
+ object.respond_to?(:sec) ? "time" : "date"
8
34
  end
9
35
  end
10
36
  end
@@ -3,8 +3,21 @@
3
3
  module Bridgetown
4
4
  module Filters
5
5
  module TranslationFilters
6
- def t(input)
7
- I18n.t(input.to_s)
6
+ def t(input, options = "")
7
+ options = string_to_hash(options)
8
+ locale = options.delete(:locale)
9
+ count = options.delete(:count)
10
+ options[:count] = count.to_i unless count.nil?
11
+
12
+ I18n.t(input.to_s, locale: locale, **options)
13
+ rescue ArgumentError
14
+ input
15
+ end
16
+
17
+ private
18
+
19
+ def string_to_hash(options)
20
+ options.split(",").to_h { |e| e.split(":").map(&:strip) }.symbolize_keys
8
21
  end
9
22
  end
10
23
  end
@@ -7,6 +7,8 @@ module Bridgetown
7
7
  include URLFilters
8
8
  include GroupingFilters
9
9
  include DateFilters
10
+ include LocalizationFilters
11
+ include TranslationFilters
10
12
  include ConditionHelpers
11
13
 
12
14
  # Convert a Markdown string into HTML output.
@@ -102,7 +104,7 @@ module Bridgetown
102
104
  def obfuscate_link(input, prefix = "mailto")
103
105
  link = "<a href=\"#{prefix}:#{input}\">#{input}</a>"
104
106
  script = "<script type=\"text/javascript\">document.currentScript.insertAdjacentHTML('"
105
- script += "beforebegin', '#{rot47(link).gsub(%r!\\!, '\\\\\\')}'.replace(/[!-~]/g," # rubocop:disable Style/StringLiteralsInInterpolation, Style/RedundantRegexpArgument
107
+ script += "beforebegin', '#{rot47(link).gsub("\\", '\\\\\\')}'.replace(/[!-~]/g," # rubocop:disable Style/StringLiteralsInInterpolation
106
108
  script += "function(c){{var j=c.charCodeAt(0);if((j>=33)&&(j<=126)){"
107
109
  script += "return String.fromCharCode(33+((j+ 14)%94));}"
108
110
  script += "else{return String.fromCharCode(j);}}}));</script>"
@@ -433,6 +435,3 @@ end
433
435
  Liquid::Template.register_filter(
434
436
  Bridgetown::Filters
435
437
  )
436
- Liquid::Template.register_filter(
437
- Bridgetown::Filters::TranslationFilters
438
- )
@@ -144,9 +144,10 @@ module Bridgetown
144
144
  end
145
145
 
146
146
  def process_prototype_page_data(collection, search_term, term)
147
+ pagination_key = prototyped_page.data.key?("paginate") ? "paginate" : "pagination"
147
148
  # Fill in pagination details to be handled later by Bridgetown::Paginate
148
149
  data["pagination"] = Bridgetown::Utils.deep_merge_hashes(
149
- prototyped_page.data["pagination"].to_h, {
150
+ prototyped_page.data[pagination_key].to_h, {
150
151
  "enabled" => true,
151
152
  "collection" => collection,
152
153
  "where_query" => [search_term, term],
@@ -97,10 +97,11 @@ module Bridgetown
97
97
  # @param options [Hash] key-value pairs of HTML attributes to add to the tag
98
98
  # @return [String] the anchor tag HTML
99
99
  # @raise [ArgumentError] if the file cannot be found
100
- def link_to(text, relative_path = nil, options = {})
101
- if block_given?
100
+ def link_to(text, relative_path = nil, options = {}, &block)
101
+ if block.present?
102
+ options = relative_path || {}
102
103
  relative_path = text
103
- text = yield
104
+ text = view.respond_to?(:capture) ? view.capture(&block) : yield
104
105
  elsif relative_path.nil?
105
106
  raise ArgumentError, "You must provide a relative path"
106
107
  end
@@ -3,9 +3,11 @@
3
3
  module Bridgetown
4
4
  module Tags
5
5
  class LocalizationTag < Liquid::Tag
6
+ include Bridgetown::Filters::LocalizationFilters
7
+
6
8
  def render(_context)
7
- key = @markup.strip
8
- I18n.l(key)
9
+ input, format, locale = @markup.split.map(&:strip)
10
+ l(input, format, locale)
9
11
  end
10
12
  end
11
13
  end
@@ -3,9 +3,13 @@
3
3
  module Bridgetown
4
4
  module Tags
5
5
  class TranslationTag < Liquid::Tag
6
+ include Bridgetown::Filters::TranslationFilters
7
+
6
8
  def render(_context)
7
- key = @markup.strip
8
- I18n.t(key)
9
+ input, options = @markup.split.map(&:strip)
10
+ options ||= ""
11
+
12
+ t(input, options).to_s
9
13
  end
10
14
  end
11
15
  end
@@ -73,3 +73,14 @@ task :environment do # rubocop:todo Metrics/BlockLength
73
73
  end
74
74
  end
75
75
  end
76
+
77
+ # rubocop:disable Bridgetown/NoPutsAllowed
78
+ desc "Provides a time zone-aware date string you can use in front matter"
79
+ task date: :environment do
80
+ run_initializers
81
+
82
+ puts "🗓️ Today's date & time in your site's timezone (#{ENV.fetch("TZ", "NOT SET")}):"
83
+ puts
84
+ puts "➡️ #{Time.now.strftime("%a, %d %b %Y %T %z")}"
85
+ end
86
+ # rubocop:enable Bridgetown/NoPutsAllowed
@@ -47,7 +47,7 @@ module Bridgetown
47
47
  end
48
48
 
49
49
  def setup_loaders(autoload_paths = []) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
50
- (autoload_paths.presence || config.autoload_paths).each do |load_path|
50
+ (autoload_paths.presence || config.autoload_paths).each do |load_path| # rubocop:todo Metrics/BlockLength
51
51
  if @loaders.key?(load_path)
52
52
  raise "Zeitwerk loader already added for `#{load_path}'. Please check your config"
53
53
  end
@@ -55,6 +55,7 @@ module Bridgetown
55
55
  next unless Dir.exist? load_path
56
56
 
57
57
  loader = Zeitwerk::Loader.new
58
+ loader.inflector = config.inflector if config.inflector
58
59
  begin
59
60
  loader.push_dir(load_path)
60
61
  rescue Zeitwerk::Error
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  CODE_NAME = "Kelly Butte"
6
6
  end
@@ -77,7 +77,6 @@ module Bridgetown
77
77
  autoload :Cleaner, "bridgetown-core/cleaner"
78
78
  autoload :Collection, "bridgetown-core/collection"
79
79
  autoload :Component, "bridgetown-core/component"
80
- autoload :Configuration, "bridgetown-core/configuration"
81
80
  autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader"
82
81
  autoload :Deprecator, "bridgetown-core/deprecator"
83
82
  autoload :EntryFilter, "bridgetown-core/entry_filter"
@@ -119,6 +118,7 @@ module Bridgetown
119
118
  require "bridgetown-core/liquid_extensions"
120
119
  require "bridgetown-core/filters"
121
120
 
121
+ require "bridgetown-core/configuration"
122
122
  require "bridgetown-core/drops/drop"
123
123
  require "bridgetown-core/drops/resource_drop"
124
124
  require_all "bridgetown-core/converters"
@@ -10,6 +10,26 @@ Bridgetown.configure do |config|
10
10
  # config.autoload_paths << "models"
11
11
  #
12
12
 
13
+ # You can configure the inflector used by Zeitwerk. In v2.0,
14
+ # ActiveSupport::Inflector will become the default.
15
+ #
16
+ # config.inflector = ActiveSupport::Inflector
17
+ #
18
+ # Add new inflection rules using the following format. Inflections
19
+ # are locale specific, and you may define rules for as many different
20
+ # locales as you wish. All of these examples are active by default:
21
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
22
+ # inflect.plural /^(ox)$/i, "\\1en"
23
+ # inflect.singular /^(ox)en/i, "\\1"
24
+ # inflect.irregular "person", "people"
25
+ # inflect.uncountable %w( fish sheep )
26
+ # end
27
+ #
28
+ # These inflection rules are supported but not enabled by default:
29
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
30
+ # inflect.acronym "RESTful"
31
+ # end
32
+
13
33
  # You can use `init` to initialize various Bridgetown features or plugin gems.
14
34
  # For example, you can use the Dotenv gem to load environment variables from
15
35
  # `.env`. Just `bundle add dotenv` and then uncomment this:
@@ -13,17 +13,17 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  <%- if frontend_bundling_option == "webpack" -%>
16
- "css-loader": "^6.7.1",
16
+ "css-loader": "^6.8.1",
17
17
  <%- end -%>
18
- "esbuild": "^0.17.19",
18
+ "esbuild": "^0.19.2",
19
19
  <%- if frontend_bundling_option == "webpack" -%>
20
- "esbuild-loader": "^2.18.0",
21
- "mini-css-extract-plugin": "^2.6.0",
20
+ "esbuild-loader": "^4.0.2",
21
+ "mini-css-extract-plugin": "^2.7.6",
22
22
  <%- else -%>
23
- "glob": "^10.2.6",
23
+ "glob": "^10.3.3",
24
24
  <%- end -%>
25
25
  <%- unless disable_postcss? -%>
26
- "postcss": "^8.4.23",
26
+ "postcss": "^8.4.29",
27
27
  "postcss-flexbugs-fixes": "^5.0.2",
28
28
  <%- if frontend_bundling_option == "esbuild" -%>
29
29
  "postcss-import": "^15.1.0",
@@ -31,20 +31,20 @@
31
31
  <%- else -%>
32
32
  "postcss-loader": "^6.2.1",
33
33
  <%- end -%>
34
- "postcss-preset-env": "^8.4.1",
34
+ "postcss-preset-env": "^9.1.2",
35
35
  <%- if frontend_bundling_option == "esbuild" -%>
36
36
  "read-cache": "^1.0.0"<%= "," unless postcss_option %>
37
37
  <%- end -%>
38
38
  <%- end -%>
39
39
  <%- unless postcss_option -%>
40
- "sass": "^1.62.1",
41
- "sass-loader": "^12.6.0"<%= "," if frontend_bundling_option == "webpack" %>
40
+ "sass": "^1.66.1",
41
+ "sass-loader": "^13.3.2"<%= "," if frontend_bundling_option == "webpack" %>
42
42
  <%- end -%>
43
43
  <%- if frontend_bundling_option == "webpack" -%>
44
- "webpack": "^5.72.0",
45
- "webpack-cli": "^4.9.2",
44
+ "webpack": "^5.88.2",
45
+ "webpack-cli": "^5.1.4",
46
46
  "webpack-manifest-plugin": "^5.0.0",
47
- "webpack-merge": "^5.8.0"
47
+ "webpack-merge": "^5.9.0"
48
48
  <%- end -%>
49
49
  }
50
50
  }
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.0
4
+ version: 1.3.1
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-07-10 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel