bridgetown-core 1.3.0.beta3 → 1.3.1

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: ec81158ce54460fb44c4296bae6c3eb75c95c627492c6fe5891cbd853089a13c
4
- data.tar.gz: e22e4e4cfd9b4c27a5eefefd1670e43c99badb7eb9c8be96105b47e024324543
3
+ metadata.gz: 97de36caa078103a75226bcc77072ba86c958e58f77a22fb7282fe4d1ef4ef22
4
+ data.tar.gz: e3fc1723d1c4acc2b3f715ba138de15c77ad0cabaeaca75bf8e5b9b359f61cdb
5
5
  SHA512:
6
- metadata.gz: 6130dec47320b9b66406afbb6e98e5851ceba1664292c37be8d02a800c9e95a6c9678ccbc5c822dc2f64497e0b9b0826c0956dd72ab81c2526b9fb499b3d13a5
7
- data.tar.gz: ac1d0032d102186ae07d41997bd29541bf96eb3e7aee7aa6ca25df8da5b3cebef18ebb7cb3d51c1ef58270df68c65d126271b55bb822f8fdd046927ccfee68b5
6
+ metadata.gz: 8d19ca716967ef3aae5a991a965ecd89805eb05135ebf8a87c0e320421986b4a2275c63eedf7dcdb41dd35b77c497bb823501849cf824432010a6f9f63d8e315
7
+ data.tar.gz: 4b06864b42beb7693c50ee75853ad3c4237fc997d8570d5ea5eb8bc41b19af3d12740b58204d0320475b9b1cbf823847dc7449d54ea20819c3b2b954443a2516
@@ -103,6 +103,8 @@ const importPostCssPlugin = (options, configuration) => ({
103
103
  async setup(build) {
104
104
  // Process .css files with PostCSS
105
105
  build.onLoad({ filter: (configuration.filter || /\.css$/) }, async (args) => {
106
+ if (args.path.endsWith(".lit.css")) return;
107
+
106
108
  const additionalFilePaths = []
107
109
  const css = await fs.readFile(args.path, "utf8")
108
110
 
@@ -307,6 +309,9 @@ module.exports = async (esbuildOptions, ...args) => {
307
309
  if (esbuildOptions.bridgetownConfig) delete esbuildOptions.bridgetownConfig
308
310
 
309
311
  const esbuild = require("esbuild")
312
+ const entryPoints = esbuildOptions.entryPoints || ["./frontend/javascript/index.js"]
313
+ if (esbuildOptions.entryPoints) delete esbuildOptions.entryPoints
314
+
310
315
  const islands = glob.sync(`./${bridgetownConfig.source}/${bridgetownConfig.islandsDir}/*.{js,js.rb}`).map(item => `./${item}`)
311
316
 
312
317
  esbuild.context({
@@ -325,7 +330,7 @@ module.exports = async (esbuildOptions, ...args) => {
325
330
  minify: process.argv.includes("--minify"),
326
331
  sourcemap: true,
327
332
  target: "es2020",
328
- entryPoints: ["./frontend/javascript/index.js", ...islands],
333
+ entryPoints: [...entryPoints, ...islands],
329
334
  entryNames: "[dir]/[name].[hash]",
330
335
  outdir: path.join(process.cwd(), `${bridgetownConfig.destination}/_bridgetown/static`),
331
336
  publicPath: "/_bridgetown/static",
@@ -5,3 +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.19.2\""
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" => [],
@@ -28,7 +28,7 @@ insert_into_file "esbuild.config.js",
28
28
  end
29
29
 
30
30
  insert_into_file "esbuild.config.js",
31
- after: " plugins: [" do
31
+ after: "\n plugins: [\n" do
32
32
  <<-JS
33
33
  ...plugins,
34
34
  JS
@@ -23,7 +23,7 @@ insert_into_file "esbuild.config.js",
23
23
  end
24
24
 
25
25
  insert_into_file "esbuild.config.js",
26
- after: " plugins: [" do
26
+ after: "\n plugins: [\n" do
27
27
  <<-JS
28
28
  ruby2js(),
29
29
  JS
@@ -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
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
@@ -221,7 +222,7 @@ module Bridgetown
221
222
  view.view_context.resource
222
223
  end
223
224
 
224
- return unless resource
225
+ return false unless resource
225
226
 
226
227
  name = name.to_s
227
228
  resource.slots.any? do |slot|
@@ -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.beta3"
4
+ VERSION = "1.3.1"
5
5
  CODE_NAME = "Kelly Butte"
6
6
  end
@@ -133,6 +133,7 @@ module Bridgetown
133
133
 
134
134
  # rubocop:disable Layout/LineLength
135
135
  def component_frontend_matcher(options)
136
+ # TODO: maybe a negative lookbehind would make this regex cleaner?
136
137
  @fematcher ||=
137
138
  %r{(#{options[:components_dir]}|#{options[:islands_dir]})/(?:[^.]+|\.(?!dsd))+(\.js|\.jsx|\.js\.rb|\.css)$}
138
139
  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.beta3
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-06-18 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
@@ -590,9 +590,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
590
590
  version: 2.7.0
591
591
  required_rubygems_version: !ruby/object:Gem::Requirement
592
592
  requirements:
593
- - - ">"
593
+ - - ">="
594
594
  - !ruby/object:Gem::Version
595
- version: 1.3.1
595
+ version: '0'
596
596
  requirements: []
597
597
  rubygems_version: 3.1.4
598
598
  signing_key: