bridgetown-core 1.0.0.beta1 → 1.0.0.beta2
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/lib/bridgetown-core/concerns/site/configurable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/configurations/stimulus.rb +3 -2
- data/lib/bridgetown-core/configurations/vercel/vercel.json +45 -0
- data/lib/bridgetown-core/configurations/vercel/vercel_url.rb +12 -0
- data/lib/bridgetown-core/configurations/vercel.rb +4 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +5 -7
- data/lib/bridgetown-core/converters/serbea_templates.rb +4 -7
- data/lib/bridgetown-core/resource/base.rb +1 -1
- data/lib/bridgetown-core/ruby_template_view.rb +7 -0
- data/lib/bridgetown-core/site.rb +5 -0
- data/lib/bridgetown-core/utils/loaders_manager.rb +6 -0
- data/lib/bridgetown-core/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a9d2528b695e8e0cf1016e12d9ef4f83ea3983568db4b20e740f5256024990
|
4
|
+
data.tar.gz: 8cfdc7484ba7f011cac11708667eb93e3fa27400269b7a548fc1cbc80dee37c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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(/
|
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
|
@@ -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
|
-
|
87
|
-
|
88
|
-
|
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
|
-
)
|
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
|
-
|
15
|
-
|
16
|
-
|
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
|
|
@@ -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
|
data/lib/bridgetown-core/site.rb
CHANGED
@@ -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 }
|
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.
|
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-
|
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
|