bridgetown-core 2.0.0.beta6 → 2.0.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 +4 -4
- data/lib/bridgetown-core/commands/build.rb +1 -1
- data/lib/bridgetown-core/commands/new.rb +8 -3
- data/lib/bridgetown-core/commands/start.rb +18 -3
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +2 -0
- data/lib/bridgetown-core/configurations/feed.rb +33 -0
- data/lib/bridgetown-core/configurations/lit/esbuild-plugins.js +15 -16
- data/lib/bridgetown-core/configurations/lit/lit-ssr.config.js +2 -2
- data/lib/bridgetown-core/configurations/lit.rb +4 -4
- data/lib/bridgetown-core/configurations/render/render.yaml.erb +40 -4
- data/lib/bridgetown-core/configurations/render.rb +8 -1
- data/lib/bridgetown-core/configurations/seo.rb +33 -0
- data/lib/bridgetown-core/configurations/shoelace.rb +3 -57
- data/lib/bridgetown-core/configurations/webawesome.rb +38 -0
- data/lib/bridgetown-core/converter.rb +13 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +1 -0
- data/lib/bridgetown-core/converters/liquid_templates.rb +1 -0
- data/lib/bridgetown-core/converters/serbea_templates.rb +1 -0
- data/lib/bridgetown-core/helpers.rb +16 -11
- data/lib/bridgetown-core/plugin_manager.rb +2 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
- data/lib/bridgetown-core/utils.rb +22 -1
- data/lib/roda/plugins/bridgetown_server.rb +9 -1
- data/lib/site_template/config/puma.rb +3 -2
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89df4836f5a8105ce2872c48db38dcf7f710f190e760cb7d083c4610653a6952
|
4
|
+
data.tar.gz: 54b22de4c1cf9e952c680d74fbef3f042c217bfa822a359bd8f5830e096ab8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e795be0418ead09205b2d46ab7501ba25d5df443973f4f49eaa599b2c91caad5218a279cb50385cf5dfc86146671d7a52e7bcd90631a27be9d547c5e14169e
|
7
|
+
data.tar.gz: 4045cde9174adb8d58208e7032bbac1446ba31983d9aa7853af5ec5f9194789e706ebb01a06171d0282cd0faf87827b0f222f75168cf312bc51dc23324e99256
|
@@ -97,7 +97,7 @@ module Bridgetown
|
|
97
97
|
ai.ipv4? && !ai.ipv4_loopback?
|
98
98
|
end&.ip_address
|
99
99
|
scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
100
|
-
port =
|
100
|
+
port = config_options.port
|
101
101
|
Bridgetown.logger.info ""
|
102
102
|
Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
|
103
103
|
Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
|
@@ -16,6 +16,11 @@ module Bridgetown
|
|
16
16
|
end
|
17
17
|
summary "Creates a new Bridgetown site scaffold in PATH"
|
18
18
|
|
19
|
+
argument :path,
|
20
|
+
type: :string,
|
21
|
+
required: false, # we're changing for path in new_site method
|
22
|
+
desc: "PATH where new Bridgetown site will be created"
|
23
|
+
|
19
24
|
class_option :apply,
|
20
25
|
aliases: "-a",
|
21
26
|
banner: "PATH|URL",
|
@@ -60,9 +65,9 @@ module Bridgetown
|
|
60
65
|
end
|
61
66
|
|
62
67
|
def new_site
|
63
|
-
raise ArgumentError, "You must specify a path." if
|
68
|
+
raise ArgumentError, "You must specify a path." if path.nil? || path.empty?
|
64
69
|
|
65
|
-
new_site_path = File.expand_path(
|
70
|
+
new_site_path = File.expand_path(path, Dir.pwd)
|
66
71
|
@site_name = new_site_path.split(File::SEPARATOR).last
|
67
72
|
|
68
73
|
if preserve_source_location?(new_site_path, options)
|
@@ -77,7 +82,7 @@ module Bridgetown
|
|
77
82
|
|
78
83
|
say_status :create, new_site_path
|
79
84
|
create_site new_site_path
|
80
|
-
after_install new_site_path,
|
85
|
+
after_install new_site_path, path, options
|
81
86
|
rescue ArgumentError => e
|
82
87
|
say_status :alert, e.message, :red
|
83
88
|
ensure
|
@@ -42,7 +42,6 @@ module Bridgetown
|
|
42
42
|
class_option :port,
|
43
43
|
aliases: "-P",
|
44
44
|
type: :numeric,
|
45
|
-
default: 4000,
|
46
45
|
desc: "Serve your site on the specified port. Defaults to 4000."
|
47
46
|
class_option :bind,
|
48
47
|
aliases: "-B",
|
@@ -72,7 +71,7 @@ module Bridgetown
|
|
72
71
|
|
73
72
|
# Load Bridgetown configuration into thread memory
|
74
73
|
bt_options = configuration_with_overrides(options)
|
75
|
-
port =
|
74
|
+
bt_options.port = port = load_env_and_determine_port(bt_options, options)
|
76
75
|
# TODO: support Puma serving HTTPS directly?
|
77
76
|
bt_bound_url = "http://#{bt_options.bind}:#{port}"
|
78
77
|
|
@@ -89,7 +88,7 @@ module Bridgetown
|
|
89
88
|
if server.serveable?
|
90
89
|
pid_tracker.create_pid_dir
|
91
90
|
|
92
|
-
bt_options.skip_live_reload
|
91
|
+
bt_options.skip_live_reload ||= !server.using_puma?
|
93
92
|
|
94
93
|
build_args = ["-w"] + ARGV.reject { |arg| arg == "start" }
|
95
94
|
build_pid = Process.fork { Bridgetown::Commands::Build.start(build_args) }
|
@@ -125,6 +124,22 @@ module Bridgetown
|
|
125
124
|
"config.ru" :
|
126
125
|
File.expand_path("../rack/default_config.ru", __dir__)
|
127
126
|
end
|
127
|
+
|
128
|
+
def load_env_and_determine_port(config, options)
|
129
|
+
initializer_file = File.join(config.root_dir, "config", "initializers.rb")
|
130
|
+
if File.exist?(initializer_file) &&
|
131
|
+
File.read(initializer_file) =~ (%r!^[\s]*init[\s]*:dotenv!)
|
132
|
+
require "dotenv"
|
133
|
+
Bridgetown.load_dotenv(root: config.root_dir)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Options ordering for "who wins" is:
|
137
|
+
# 1. CLI
|
138
|
+
# 2. BRIDGETOWN_PORT env var
|
139
|
+
# 3. YAML config (if present)
|
140
|
+
# 4. 4000
|
141
|
+
options[:port] || ENV.fetch("BRIDGETOWN_PORT", config.port || 4000)
|
142
|
+
end
|
128
143
|
end
|
129
144
|
end
|
130
145
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
say_status :feed, "Adding bridgetown-feed gem..."
|
4
|
+
|
5
|
+
add_gem "bridgetown-feed"
|
6
|
+
add_initializer :"bridgetown-feed"
|
7
|
+
|
8
|
+
head_file = Dir.glob("src/**/{head.liquid,_head.erb,_head.serb}").first
|
9
|
+
|
10
|
+
unless head_file
|
11
|
+
say_status :feed, "Feed tags could not be automatically inserted"
|
12
|
+
say_status :feed, "To enable, output `feed` in the application <head> element" \
|
13
|
+
"using the relevant template language tags"
|
14
|
+
say "For further reading, check out " \
|
15
|
+
'"https://github.com/bridgetownrb/bridgetown-feed#readme"', :blue
|
16
|
+
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
say_status :feed, "Adding feed tags to #{head_file}..."
|
21
|
+
|
22
|
+
feed_tag = Bridgetown::Utils.helper_code_for_template_extname(
|
23
|
+
File.extname(head_file),
|
24
|
+
"feed_meta"
|
25
|
+
)
|
26
|
+
|
27
|
+
File.open(head_file, "a+") do |file|
|
28
|
+
file.write("#{feed_tag}\n") unless file.grep(%r{#{feed_tag}}).any?
|
29
|
+
end
|
30
|
+
|
31
|
+
say_status :feed, "bridgetown-feed is now configured!"
|
32
|
+
say "For further reading, check out " \
|
33
|
+
'"https://github.com/bridgetownrb/bridgetown-feed#readme"', :blue
|
@@ -4,21 +4,20 @@
|
|
4
4
|
|
5
5
|
// This plugin will let you import `.lit.css` files as sidecar stylesheets.
|
6
6
|
// Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
|
7
|
-
|
8
|
-
|
9
|
-
const postcss = require("postcss")
|
7
|
+
import { litCssPlugin } from "esbuild-plugin-lit-css"
|
8
|
+
import postcss from "postcss"
|
10
9
|
|
11
|
-
|
12
|
-
plugins: [
|
13
|
-
litCssPlugin({
|
14
|
-
filter: /\.lit\.css$/,
|
15
|
-
transform: async (css, { filePath }) => {
|
16
|
-
const postCssConfig = await postcssrc()
|
17
|
-
const postCssProcessor = postcss([...postCssConfig.plugins])
|
10
|
+
const postcssrc = (await import("postcss-load-config")).default
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
})
|
23
|
-
|
24
|
-
|
12
|
+
export const plugins = [
|
13
|
+
litCssPlugin({
|
14
|
+
filter: /\.lit\.css$/,
|
15
|
+
transform: async (css, { filePath }) => {
|
16
|
+
const postCssConfig = await postcssrc()
|
17
|
+
const postCssProcessor = postcss([...postCssConfig.plugins])
|
18
|
+
|
19
|
+
const results = await postCssProcessor.process(css, { ...postCssConfig.options, from: filePath })
|
20
|
+
return results.css
|
21
|
+
}
|
22
|
+
}),
|
23
|
+
]
|
@@ -11,19 +11,19 @@ end
|
|
11
11
|
|
12
12
|
say_status :lit, "Installing Lit + SSR Plugin..."
|
13
13
|
|
14
|
-
add_gem "bridgetown-lit-renderer", version: "
|
14
|
+
add_gem "bridgetown-lit-renderer", version: "3.0.0"
|
15
15
|
|
16
|
-
add_npm_package "lit esbuild-plugin-lit-css bridgetown-lit-renderer@
|
16
|
+
add_npm_package "lit esbuild-plugin-lit-css bridgetown-lit-renderer@3.0.0"
|
17
17
|
|
18
18
|
copy_file in_templates_dir("lit-ssr.config.js"), "config/lit-ssr.config.js"
|
19
19
|
copy_file in_templates_dir("lit-components-entry.js"), "config/lit-components-entry.js"
|
20
20
|
copy_file in_templates_dir("esbuild-plugins.js"), "config/esbuild-plugins.js"
|
21
21
|
|
22
22
|
insert_into_file "esbuild.config.js",
|
23
|
-
after: '
|
23
|
+
after: 'import build from "./config/esbuild.defaults.js"' do
|
24
24
|
<<~JS
|
25
25
|
|
26
|
-
|
26
|
+
import { plugins } from "./config/esbuild-plugins.js"
|
27
27
|
JS
|
28
28
|
end
|
29
29
|
|
@@ -1,13 +1,10 @@
|
|
1
1
|
services:
|
2
2
|
- type: web
|
3
3
|
name: <%= @render_service_name %>
|
4
|
-
|
4
|
+
runtime: static
|
5
5
|
buildCommand: bin/bridgetown deploy
|
6
6
|
staticPublishPath: ./output
|
7
7
|
pullRequestPreviewsEnabled: true
|
8
|
-
envVars:
|
9
|
-
- key: BRIDGETOWN_ENV
|
10
|
-
value: production
|
11
8
|
headers:
|
12
9
|
- path: /*
|
13
10
|
name: X-Frame-Options
|
@@ -27,3 +24,42 @@ services:
|
|
27
24
|
- path: /*
|
28
25
|
name: Cache-Control
|
29
26
|
value: "public, max-age=86400, s-max-age=86400"
|
27
|
+
envVars:
|
28
|
+
- key: BRIDGETOWN_ENV
|
29
|
+
value: production
|
30
|
+
###########
|
31
|
+
# Uncomment and modify the following for hybrid deployments, database support, etc.
|
32
|
+
# Use the `routes` rewrite feature to "poke holes" through your static CDN to specific
|
33
|
+
# route handlers in your Roda server application.
|
34
|
+
###########
|
35
|
+
#
|
36
|
+
# - key: DATABASE_URL
|
37
|
+
# fromDatabase:
|
38
|
+
# name: <%= @render_service_name %>_proddb
|
39
|
+
# property: connectionString
|
40
|
+
# - fromGroup: <%= @render_service_name %>-prod-envs
|
41
|
+
# routes:
|
42
|
+
# - type: rewrite
|
43
|
+
# source: /account/*
|
44
|
+
# destination: https://<%= @render_service_name %>-api.onrender.com/account/*
|
45
|
+
# - type: rewrite
|
46
|
+
# source: /auth/*
|
47
|
+
# destination: https://<%= @render_service_name %>-api.onrender.com/auth/*
|
48
|
+
# - type: web
|
49
|
+
# name: <%= @render_service_name %>-api
|
50
|
+
# plan: standard
|
51
|
+
# runtime: ruby
|
52
|
+
# buildCommand: bundle install && npm install && bin/bridgetown frontend:build
|
53
|
+
# startCommand: bin/bridgetown start
|
54
|
+
# envVars:
|
55
|
+
# - key: BRIDGETOWN_ENV
|
56
|
+
# value: production
|
57
|
+
# - key: DATABASE_URL
|
58
|
+
# fromDatabase:
|
59
|
+
# name: <%= @render_service_name %>_proddb
|
60
|
+
# property: connectionString
|
61
|
+
# - fromGroup: <%= @render_service_name %>-prod-envs
|
62
|
+
# databases:
|
63
|
+
# - name: <%= @render_service_name %>_proddb
|
64
|
+
# plan: starter
|
65
|
+
# databaseName: <%= @render_service_name %>_production
|
@@ -3,4 +3,11 @@
|
|
3
3
|
@render_service_name = ask "What would like to call your Render service?"
|
4
4
|
template in_templates_dir("render.yaml.erb"), "render.yaml"
|
5
5
|
|
6
|
-
|
6
|
+
say_status :render, "Your render.yaml file is now configured!"
|
7
|
+
say ""
|
8
|
+
say "Verify its contents and once ready, create a new blueprint from the Render dashboard"
|
9
|
+
say "and connect your repo."
|
10
|
+
say ""
|
11
|
+
say "Optionally, if you're setting up a backend API and database, create a environment group"
|
12
|
+
say "on Render called [yourservicehere]-prod-envs for sharing environment variables between"
|
13
|
+
say "multiple servers."
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
say_status :seo, "Adding bridgetown-seo-tag gem..."
|
4
|
+
|
5
|
+
add_gem "bridgetown-seo-tag"
|
6
|
+
add_initializer :"bridgetown-seo-tag"
|
7
|
+
|
8
|
+
head_file = Dir.glob("src/**/{head.liquid,_head.erb,_head.serb}").first
|
9
|
+
|
10
|
+
unless head_file
|
11
|
+
say_status :seo, "SEO tags could not be automatically inserted"
|
12
|
+
say_status :seo, "To enable SEO, output `seo` in the application <head> element" \
|
13
|
+
"using the relevant template language tags"
|
14
|
+
say "For further reading, check out " \
|
15
|
+
'"https://github.com/bridgetownrb/bridgetown-seo-tag#readme"', :blue
|
16
|
+
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
say_status :seo, "Adding SEO tags to #{head_file}..."
|
21
|
+
|
22
|
+
seo_tag = Bridgetown::Utils.helper_code_for_template_extname(
|
23
|
+
File.extname(head_file),
|
24
|
+
"seo"
|
25
|
+
)
|
26
|
+
|
27
|
+
File.open(head_file, "a+") do |file|
|
28
|
+
file.write("#{seo_tag}\n") unless file.grep(%r{#{seo_tag}}).any?
|
29
|
+
end
|
30
|
+
|
31
|
+
say_status :seo, "bridgetown-seo-tag is now configured!"
|
32
|
+
say "For further reading, check out " \
|
33
|
+
'"https://github.com/bridgetownrb/bridgetown-seo-tag#readme"', :blue
|
@@ -1,60 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
say "Shoelace is now Web Awesome!"
|
4
|
+
say ""
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
stylesheet_import = <<~CSS
|
8
|
-
/* Import the base Shoelace stylesheet: */
|
9
|
-
@import "@shoelace-style/shoelace/dist/themes/light.css";
|
10
|
-
|
11
|
-
CSS
|
12
|
-
|
13
|
-
if File.exist?("frontend/styles/index.css")
|
14
|
-
prepend_to_file "frontend/styles/index.css", stylesheet_import
|
15
|
-
elsif File.exist?("frontend/styles/index.scss")
|
16
|
-
prepend_to_file "frontend/styles/index.scss", stylesheet_import
|
17
|
-
else
|
18
|
-
say "\nPlease add the following lines to your CSS index file:"
|
19
|
-
say stylesheet_import
|
20
|
-
end
|
21
|
-
|
22
|
-
say 'Adding Shoelace to "frontend/javascript/index.js"...', :magenta
|
23
|
-
|
24
|
-
javascript_import do
|
25
|
-
<<~JS
|
26
|
-
|
27
|
-
// Example Shoelace components. Mix 'n' match however you like!
|
28
|
-
import "@shoelace-style/shoelace/dist/components/button/button.js"
|
29
|
-
import "@shoelace-style/shoelace/dist/components/icon/icon.js"
|
30
|
-
import "@shoelace-style/shoelace/dist/components/spinner/spinner.js"
|
31
|
-
|
32
|
-
// Use the public icons folder:
|
33
|
-
import { setBasePath } from "@shoelace-style/shoelace/dist/utilities/base-path.js"
|
34
|
-
setBasePath("/shoelace-assets")
|
35
|
-
JS
|
36
|
-
end
|
37
|
-
|
38
|
-
say "Updating frontend build commands...", :magenta
|
39
|
-
|
40
|
-
insert_into_file "package.json", before: ' "esbuild": "node' do
|
41
|
-
<<-JS
|
42
|
-
"shoelace:copy-assets": "mkdir -p src/shoelace-assets && cp -r node_modules/@shoelace-style/shoelace/dist/assets src/shoelace-assets",
|
43
|
-
JS
|
44
|
-
end
|
45
|
-
gsub_file "package.json", %r{"esbuild": "node}, '"esbuild": "npm run shoelace:copy-assets && node'
|
46
|
-
gsub_file "package.json", %r{"esbuild-dev": "node},
|
47
|
-
'"esbuild-dev": "npm run shoelace:copy-assets && node'
|
48
|
-
|
49
|
-
if File.exist?(".gitignore")
|
50
|
-
append_to_file ".gitignore" do
|
51
|
-
<<~FILES
|
52
|
-
|
53
|
-
src/shoelace-assets
|
54
|
-
FILES
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
say_status :shoelace, "Shoelace is now configured!"
|
59
|
-
|
60
|
-
say 'For further reading, check out "https://shoelace.style"', :blue
|
6
|
+
Bridgetown::Commands::Configure.start(["webawesome"])
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
say_status :webawesome, "Installing Web Awesome..."
|
4
|
+
|
5
|
+
add_npm_package "@awesome.me/webawesome"
|
6
|
+
|
7
|
+
stylesheet_import = <<~CSS
|
8
|
+
/* Import the base Web Awesome stylesheet: */
|
9
|
+
@import "@awesome.me/webawesome/dist/styles/webawesome.css";
|
10
|
+
|
11
|
+
CSS
|
12
|
+
|
13
|
+
if File.exist?("frontend/styles/index.css")
|
14
|
+
say 'Adding Web Awesome stylesheet import to "frontend/styles/index.css"...', :magenta
|
15
|
+
prepend_to_file "frontend/styles/index.css", stylesheet_import
|
16
|
+
elsif File.exist?("frontend/styles/index.scss")
|
17
|
+
say 'Adding Web Awesome stylesheet import to "frontend/styles/index.scss"...', :magenta
|
18
|
+
prepend_to_file "frontend/styles/index.scss", stylesheet_import
|
19
|
+
else
|
20
|
+
say "\nPlease add the following lines to your CSS index file:"
|
21
|
+
say stylesheet_import
|
22
|
+
end
|
23
|
+
|
24
|
+
say 'Adding Web Awesome component imports to "frontend/javascript/index.js"...', :magenta
|
25
|
+
|
26
|
+
javascript_import do
|
27
|
+
<<~JS
|
28
|
+
|
29
|
+
// Example Web Awesome components. Mix 'n' match however you like!
|
30
|
+
import "@awesome.me/webawesome/dist/components/button/button.js"
|
31
|
+
import "@awesome.me/webawesome/dist/components/icon/icon.js"
|
32
|
+
import "@awesome.me/webawesome/dist/components/spinner/spinner.js"
|
33
|
+
JS
|
34
|
+
end
|
35
|
+
|
36
|
+
say_status :webawesome, "Web Awesome is now configured!"
|
37
|
+
|
38
|
+
say 'For further reading, check out "https://webawesome.com"', :blue
|
@@ -9,12 +9,25 @@ module Bridgetown
|
|
9
9
|
#
|
10
10
|
# * `input :erb`
|
11
11
|
# * `input %i(xls xlsx)`
|
12
|
+
#
|
13
|
+
# @param extnames [Array<Symbol>] extensions
|
12
14
|
def input(extnames)
|
13
15
|
extnames = Array(extnames)
|
14
16
|
self.extname_list ||= []
|
15
17
|
self.extname_list += extnames.map { |e| ".#{e.to_s.downcase}" }
|
16
18
|
end
|
17
19
|
|
20
|
+
# Set or return the delimiters used for helper calls in template code
|
21
|
+
# (e.g. `["<%=", "%>"]` for ERB). This is purely informational for the framework's benefit,
|
22
|
+
# not used within a rendering pipeline.
|
23
|
+
#
|
24
|
+
# @param delimiters [Array<String>] delimiters
|
25
|
+
def helper_delimiters(delimiters = nil)
|
26
|
+
return @helper_delimiters if delimiters.nil?
|
27
|
+
|
28
|
+
@helper_delimiters = delimiters
|
29
|
+
end
|
30
|
+
|
18
31
|
def supports_slots? = @support_slots
|
19
32
|
|
20
33
|
def support_slots(bool = true) # rubocop:disable Style/OptionalBooleanParameter
|
@@ -6,6 +6,7 @@ module Bridgetown
|
|
6
6
|
class RubyTemplateView
|
7
7
|
class Helpers
|
8
8
|
using Bridgetown::Refinements
|
9
|
+
include Bridgetown::Refinements::Helper
|
9
10
|
include Bridgetown::Filters
|
10
11
|
include Bridgetown::Filters::FromLiquid
|
11
12
|
include ::Streamlined::Helpers
|
@@ -127,12 +128,10 @@ module Bridgetown
|
|
127
128
|
# Provide backwards compatibility via Streamlined helper
|
128
129
|
alias_method :attributes_from_options, :html_attributes
|
129
130
|
|
130
|
-
# Delegates to
|
131
|
-
# functions.
|
131
|
+
# Delegates to `I18n#translate` but with some additional smarts.
|
132
132
|
#
|
133
|
-
#
|
134
|
-
# the
|
135
|
-
# the <tt>people/index.html.erb</tt> template is equivalent to calling
|
133
|
+
# You can scope to the current view. Calling <tt>translate(".foo")</tt> from
|
134
|
+
# the <tt>people/index.erb</tt> template is equivalent to calling
|
136
135
|
# <tt>translate("people.index.foo")</tt>. This makes it less
|
137
136
|
# repetitive to translate many keys within the same view and provides
|
138
137
|
# a convention to scope keys consistently.
|
@@ -148,14 +147,14 @@ module Bridgetown
|
|
148
147
|
#
|
149
148
|
# @return [String] the translated string
|
150
149
|
# @see I18n
|
151
|
-
def translate(key, **options)
|
150
|
+
def translate(key, **options)
|
152
151
|
return key.map { |k| translate(k, **options) } if key.is_a?(Array)
|
153
152
|
|
154
153
|
key = key&.to_s
|
155
154
|
|
156
155
|
if key&.start_with?(".")
|
157
|
-
view_path = view
|
158
|
-
key = "#{view_path.tr("/", ".")}#{key}"
|
156
|
+
view_path = Bridgetown::Filters::URLFilters.strip_extname(view.resource.relative_path)
|
157
|
+
key = "#{view_path.tr("_/", " .").lstrip}#{key}"
|
159
158
|
end
|
160
159
|
|
161
160
|
return I18n.translate(key, **options) unless %r{(?:_|\b)html\z}.match?(key)
|
@@ -264,14 +263,19 @@ module Bridgetown
|
|
264
263
|
end
|
265
264
|
end
|
266
265
|
|
267
|
-
#
|
266
|
+
# Output a declarative shadow DOM tag to wrap the input argument or block
|
267
|
+
#
|
268
|
+
# @param input [String] content to wrap if block isn't provided
|
269
|
+
# @return [String]
|
268
270
|
def dsd(input = nil, &block)
|
269
271
|
tmpl_content = block.nil? ? input.to_s : view.capture(&block)
|
270
272
|
|
271
273
|
Bridgetown::Utils.dsd_tag(tmpl_content)
|
272
274
|
end
|
273
275
|
|
274
|
-
#
|
276
|
+
# Load a sidecar CSS file with a .dsd.css extension and output a style tag
|
277
|
+
#
|
278
|
+
# @return [String]
|
275
279
|
def dsd_style
|
276
280
|
tmpl_path = caller_locations(1, 2).find do |loc|
|
277
281
|
loc.label.include?("method_missing").!
|
@@ -292,7 +296,8 @@ module Bridgetown
|
|
292
296
|
style_tag.html_safe
|
293
297
|
end
|
294
298
|
|
295
|
-
#
|
299
|
+
# If you need to access signals without creating a tracking dependency, wrap a
|
300
|
+
# block of code in this helper
|
296
301
|
def bypass_tracking(...) = Signalize.untracked(...)
|
297
302
|
end
|
298
303
|
end
|
@@ -102,7 +102,7 @@ module Bridgetown
|
|
102
102
|
|
103
103
|
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
104
104
|
|
105
|
-
# Iterates through loaded gems and finds
|
105
|
+
# Iterates through loaded gems and finds npm_add gemspec metadata.
|
106
106
|
# If that exact package hasn't been installed, execute npm i
|
107
107
|
#
|
108
108
|
# @return [Bundler::SpecSet]
|
@@ -134,7 +134,7 @@ module Bridgetown
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def self.find_npm_dependency(loaded_gem)
|
137
|
-
npm_metadata = loaded_gem.to_spec&.metadata&.dig("
|
137
|
+
npm_metadata = loaded_gem.to_spec&.metadata&.dig("npm_add") ||
|
138
138
|
loaded_gem.to_spec&.metadata&.dig("yarn-add")
|
139
139
|
npm_dependency = npm_metadata&.match(NPM_DEPENDENCY_REGEXP)
|
140
140
|
return nil if npm_dependency&.length != 3 || npm_dependency[2] == ""
|
@@ -11,7 +11,7 @@ namespace :frontend do
|
|
11
11
|
task :watcher, :sidecar do |_task, args|
|
12
12
|
# sidecar is when the task is running alongside the start command
|
13
13
|
sidecar = args[:sidecar] == true
|
14
|
-
Bridgetown::Utils::Aux.run_process "Frontend", :
|
14
|
+
Bridgetown::Utils::Aux.run_process "Frontend", :blue, "bridgetown frontend:dev"
|
15
15
|
|
16
16
|
if sidecar
|
17
17
|
# give FE bundler time to boot before returning control to the start command
|
@@ -116,7 +116,7 @@ module Bridgetown
|
|
116
116
|
raise Errors::InvalidDateError, "Invalid date '#{input}': #{msg}"
|
117
117
|
end
|
118
118
|
|
119
|
-
# Determines whether a given file has
|
119
|
+
# Determines whether a given file has YAML front matter
|
120
120
|
#
|
121
121
|
# @return [Boolean] if the YAML front matter is present.
|
122
122
|
def has_yaml_header?(file) # rubocop: disable Naming/PredicateName
|
@@ -485,6 +485,27 @@ module Bridgetown
|
|
485
485
|
%(<template shadowrootmode="#{shadow_root_mode}">#{input}</template>).html_safe
|
486
486
|
end
|
487
487
|
|
488
|
+
def helper_code_for_template_extname(extname, content)
|
489
|
+
template_engines_providing_delimiters =
|
490
|
+
Bridgetown::Converter.subclasses
|
491
|
+
.filter_map do |converter|
|
492
|
+
[converter, converter.extname_list] if converter.helper_delimiters
|
493
|
+
end.to_h
|
494
|
+
found_template_engine =
|
495
|
+
template_engines_providing_delimiters.find do |_, extnames|
|
496
|
+
extnames.include?(extname)
|
497
|
+
end&.first
|
498
|
+
|
499
|
+
unless found_template_engine
|
500
|
+
raise "No template engine using file extension #{extname}" \
|
501
|
+
"is currently supported for code generation"
|
502
|
+
end
|
503
|
+
|
504
|
+
start_tag, end_tag = found_template_engine.helper_delimiters
|
505
|
+
|
506
|
+
[start_tag, content, end_tag].join(" ")
|
507
|
+
end
|
508
|
+
|
488
509
|
private
|
489
510
|
|
490
511
|
def merge_values(target, overwrite)
|
@@ -102,6 +102,8 @@ class Roda
|
|
102
102
|
end
|
103
103
|
|
104
104
|
module InstanceMethods
|
105
|
+
include Bridgetown::Refinements::Helper
|
106
|
+
|
105
107
|
def initialize_bridgetown_context
|
106
108
|
if self.class.opts[:bridgetown_site]
|
107
109
|
# The site had previously been initialized via the bridgetown_ssr plugin
|
@@ -157,9 +159,15 @@ class Roda
|
|
157
159
|
scope.initialize_bridgetown_root
|
158
160
|
|
159
161
|
base_path = Bridgetown::Current.preloaded_configuration.base_path.delete_prefix("/")
|
160
|
-
|
162
|
+
|
163
|
+
if base_path.empty?
|
161
164
|
ssg # static file server
|
162
165
|
Bridgetown::Rack::Routes.load_all scope
|
166
|
+
else
|
167
|
+
on(base_path) do
|
168
|
+
ssg # static file server
|
169
|
+
Bridgetown::Rack::Routes.load_all scope
|
170
|
+
end
|
163
171
|
end
|
164
172
|
end
|
165
173
|
end
|
@@ -2,9 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# Learn more at: https://puma.io
|
4
4
|
# Bridgetown configuration documentation:
|
5
|
-
# https://
|
5
|
+
# https://www.bridgetownrb.com/docs/configuration/puma
|
6
6
|
|
7
|
-
# This port number
|
7
|
+
# This port number typically gets overridden by Bridgetown's boot & config loader
|
8
|
+
# so you probably don't want to touch the number here
|
8
9
|
#
|
9
10
|
port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
|
10
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: 2.0.
|
4
|
+
version: 2.0.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: 2025-
|
11
|
+
date: 2025-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - '='
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 2.0.
|
67
|
+
version: 2.0.1
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - '='
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 2.0.
|
74
|
+
version: 2.0.1
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: csv
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -463,6 +463,7 @@ files:
|
|
463
463
|
- lib/bridgetown-core/configurations/cypress/cypress_dir/support/commands.js
|
464
464
|
- lib/bridgetown-core/configurations/cypress/cypress_dir/support/index.js
|
465
465
|
- lib/bridgetown-core/configurations/cypress/cypress_tasks
|
466
|
+
- lib/bridgetown-core/configurations/feed.rb
|
466
467
|
- lib/bridgetown-core/configurations/gh-pages.rb
|
467
468
|
- lib/bridgetown-core/configurations/gh-pages/gh-pages.yml
|
468
469
|
- lib/bridgetown-core/configurations/is-land.rb
|
@@ -482,6 +483,7 @@ files:
|
|
482
483
|
- lib/bridgetown-core/configurations/ruby2js.rb
|
483
484
|
- lib/bridgetown-core/configurations/ruby2js/hello_world.js.rb
|
484
485
|
- lib/bridgetown-core/configurations/ruby2js/ruby2js.rb
|
486
|
+
- lib/bridgetown-core/configurations/seo.rb
|
485
487
|
- lib/bridgetown-core/configurations/shoelace.rb
|
486
488
|
- lib/bridgetown-core/configurations/stimulus.rb
|
487
489
|
- lib/bridgetown-core/configurations/tailwindcss.rb
|
@@ -490,6 +492,7 @@ files:
|
|
490
492
|
- lib/bridgetown-core/configurations/vercel.rb
|
491
493
|
- lib/bridgetown-core/configurations/vercel/vercel.json
|
492
494
|
- lib/bridgetown-core/configurations/vercel/vercel_url.rb
|
495
|
+
- lib/bridgetown-core/configurations/webawesome.rb
|
493
496
|
- lib/bridgetown-core/converter.rb
|
494
497
|
- lib/bridgetown-core/converters/erb_templates.rb
|
495
498
|
- lib/bridgetown-core/converters/identity.rb
|
@@ -668,9 +671,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
668
671
|
version: 3.1.0
|
669
672
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
670
673
|
requirements:
|
671
|
-
- - "
|
674
|
+
- - ">="
|
672
675
|
- !ruby/object:Gem::Version
|
673
|
-
version:
|
676
|
+
version: '0'
|
674
677
|
requirements: []
|
675
678
|
rubygems_version: 3.3.26
|
676
679
|
signing_key:
|