bridgetown-core 1.0.0.beta1 → 1.0.0.beta2

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: b6953f85017e90090c0078b710b3e447b69366bd9fed38bd5e307ee72ae3181c
4
- data.tar.gz: 863dcdcea016110ae4e05922f7357b866bd2a77998b5da78ffb92819238c59c4
3
+ metadata.gz: e6a9d2528b695e8e0cf1016e12d9ef4f83ea3983568db4b20e740f5256024990
4
+ data.tar.gz: 8cfdc7484ba7f011cac11708667eb93e3fa27400269b7a548fc1cbc80dee37c1
5
5
  SHA512:
6
- metadata.gz: eb6a1aa56f1544fcc37c4e204df417b5d7d37fa0e219e6a484872cdf4defee1c165fda09f4f30486d64635ef9ab6cf6db3edc8c63316dd3e61ab37be1394443c
7
- data.tar.gz: 81b03e750b6fe6b25c1fbb2e62350f2c2776bf4902c236c5299f90c653720037e74ae8500bf71d928825efd3d83c651ad1d80523cb1362a1db2100d8f88daef9
6
+ metadata.gz: 98523ff2520d3428505ba743408fd20f4672cdfdebdb50fe914b025b7e63e6d661f923cdd6ee0d27c9f8cd126fc08b8b522206461b5e5862b6ddc7b30fcfe02c
7
+ data.tar.gz: 795673a2a1e3b44aa0624fbf1c7bb0e9bac35d2f3882dd45d309f70346777896a9ed75c1993f186f2a3adfc94df0d5c69e0beb71a7fbeaea3aa7ac5bf774400f
@@ -91,6 +91,8 @@ class Bridgetown::Site
91
91
  # {Bridgetown.sanitized_path} method.
92
92
  # @return [Array<String>] Return an array of updated paths if multiple paths given.
93
93
  def in_source_dir(*paths)
94
+ # TODO: this operation is expensive across thousands of iterations. Look for ways
95
+ # to workaround use of this wherever possible...
94
96
  paths.reduce(source) do |base, path|
95
97
  Bridgetown.sanitized_path(base, path.to_s)
96
98
  end
@@ -41,6 +41,7 @@ class Bridgetown::Site
41
41
  @documents = nil
42
42
  @docs_to_write = nil
43
43
  @liquid_renderer.reset
44
+ tmp_cache.clear
44
45
 
45
46
  if soft
46
47
  refresh_layouts_and_data
@@ -34,9 +34,10 @@ append_to_file(File.join(javascript_dir, "index.js")) do
34
34
 
35
35
  import controllers from "./controllers/**/*.{js,js.rb}"
36
36
  Object.entries(controllers).forEach(([filename, controller]) => {
37
- if (filename.includes("_controller.")) {
37
+ if (filename.includes("_controller.") || filename.includes("-controller.")) {
38
38
  const identifier = filename.replace("./controllers/", "")
39
- .replace(/_controller\..*$/, "")
39
+ .replace(/[_\-]controller\..*$/, "")
40
+ .replace("_", "-")
40
41
  .replace("/", "--")
41
42
 
42
43
  Stimulus.register(identifier, controller.default)
@@ -0,0 +1,45 @@
1
+ {
2
+ "cleanUrls": true,
3
+ "trailingSlash": false,
4
+ "redirects": [],
5
+ "headers": [
6
+ {
7
+ "source": "/(.*)",
8
+ "headers": [
9
+ {
10
+ "key": "X-Content-Type-Options",
11
+ "value": "nosniff"
12
+ },
13
+ {
14
+ "key": "X-Frame-Options",
15
+ "value": "DENY"
16
+ },
17
+ {
18
+ "key": "X-XSS-Protection",
19
+ "value": "1; mode=block"
20
+ },
21
+ {
22
+ "key": "Referrer-Policy",
23
+ "value": "strict-origin"
24
+ },
25
+ {
26
+ "key": "Permissions-Policy",
27
+ "value": "geolocation=(self), microphone=()"
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ "source": "/feed.xml",
33
+ "headers": [
34
+ {
35
+ "key": "Content-Type",
36
+ "value": "application/rss+xml"
37
+ },
38
+ {
39
+ "key": "Cache-Control",
40
+ "value": "public, max-age=3600"
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Builders::VercelUrl < SiteBuilder
4
+ def build
5
+ hook :site, :pre_render do |site|
6
+ next unless ENV["VERCEL_URL"] && ENV["VERCEL_ENV"] != "production"
7
+
8
+ Bridgetown.logger.info("Subbing Vercel URL")
9
+ site.config.update(url: "https://#{ENV["VERCEL_URL"]}")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ copy_file in_templates_dir("vercel.json"), "vercel.json"
4
+ copy_file in_templates_dir("vercel_url.rb"), "plugins/builders/vercel_url.rb"
@@ -83,16 +83,14 @@ module Bridgetown
83
83
  options.merge!(options[:locals]) if options[:locals]
84
84
  options[:content] = yield if block_given?
85
85
 
86
- partial_segments = partial_name.split("/")
87
- partial_segments.last.sub!(%r!^!, "_")
88
- partial_name = partial_segments.join("/")
89
-
90
- Tilt::ErubiTemplate.new(
91
- site.in_source_dir(site.config[:partials_dir], "#{partial_name}.erb"),
86
+ partial_path = _partial_path(partial_name, "erb")
87
+ tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||= Tilt::ErubiTemplate.new(
88
+ partial_path,
92
89
  outvar: "@_erbout",
93
90
  bufval: "Bridgetown::OutputBuffer.new",
94
91
  engine_class: ERBEngine
95
- ).render(self, options)
92
+ )
93
+ tmpl.render(self, options)
96
94
  end
97
95
  end
98
96
 
@@ -11,13 +11,10 @@ module Bridgetown
11
11
  options.merge!(options[:locals]) if options[:locals]
12
12
  options[:content] = capture(&block) if block
13
13
 
14
- partial_segments = partial_name.split("/")
15
- partial_segments.last.sub!(%r!^!, "_")
16
- partial_name = partial_segments.join("/")
17
-
18
- Tilt::SerbeaTemplate.new(
19
- site.in_source_dir(site.config[:partials_dir], "#{partial_name}.serb")
20
- ).render(self, options)
14
+ partial_path = _partial_path(partial_name, "serb")
15
+ tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||=
16
+ Tilt::SerbeaTemplate.new(partial_path)
17
+ tmpl.render(self, options)
21
18
  end
22
19
  end
23
20
 
@@ -30,7 +30,7 @@ module Bridgetown
30
30
  def initialize(model:)
31
31
  @model = model
32
32
  @site = model.site
33
- @data = front_matter_defaults
33
+ @data = collection.data? ? HashWithDotAccess::Hash.new : front_matter_defaults
34
34
 
35
35
  trigger_hooks :post_init
36
36
  end
@@ -107,5 +107,12 @@ module Bridgetown
107
107
  strict_variables: site.config["liquid"]["strict_variables"],
108
108
  }
109
109
  end
110
+
111
+ def _partial_path(partial_name, ext)
112
+ partial_name = partial_name.split("/").tap { _1.last.prepend("_") }.join("/")
113
+
114
+ # TODO: see if there's a workaround for this to speed up performance
115
+ site.in_source_dir(site.config[:partials_dir], "#{partial_name}.#{ext}")
116
+ end
110
117
  end
111
118
  end
@@ -53,6 +53,7 @@ module Bridgetown
53
53
  @reader = Reader.new(self)
54
54
  @liquid_renderer = LiquidRenderer.new(self)
55
55
 
56
+ Bridgetown::Cache.base_cache["site_tmp"] = {}.with_dot_access
56
57
  ensure_not_in_dest
57
58
 
58
59
  Bridgetown::Current.site = self
@@ -74,6 +75,10 @@ module Bridgetown
74
75
  end
75
76
  end
76
77
 
78
+ def tmp_cache
79
+ Bridgetown::Cache.base_cache["site_tmp"]
80
+ end
81
+
77
82
  def inspect
78
83
  "#<Bridgetown::Site #{metadata.inspect.delete_prefix("{").delete_suffix("}")}>"
79
84
  end
@@ -33,6 +33,12 @@ module Bridgetown
33
33
  return
34
34
  end
35
35
 
36
+ if defined?(ActiveSupport::RubyFeatures) && ActiveSupport::RubyFeatures::CLASS_SUBCLASSES
37
+ ActiveSupport::DescendantsTracker.clear([value.superclass])
38
+ return
39
+ end
40
+
41
+ # TODO: this could probably be refactored to work like the above
36
42
  ActiveSupport::DescendantsTracker.class_variable_get(
37
43
  :@@direct_descendants
38
44
  )[value.superclass]&.reject! { _1 == value }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.0.0.beta1"
4
+ VERSION = "1.0.0.beta2"
5
5
  CODE_NAME = "Pearl"
6
6
  end
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.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -443,6 +443,9 @@ files:
443
443
  - lib/bridgetown-core/configurations/tailwindcss/postcss.config.js
444
444
  - lib/bridgetown-core/configurations/turbo.rb
445
445
  - lib/bridgetown-core/configurations/turbo/turbo_transitions.js
446
+ - lib/bridgetown-core/configurations/vercel.rb
447
+ - lib/bridgetown-core/configurations/vercel/vercel.json
448
+ - lib/bridgetown-core/configurations/vercel/vercel_url.rb
446
449
  - lib/bridgetown-core/converter.rb
447
450
  - lib/bridgetown-core/converters/erb_templates.rb
448
451
  - lib/bridgetown-core/converters/identity.rb