bridgetown-core 0.19.1 → 0.19.2
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/bridgetown-core.gemspec +2 -3
- data/lib/bridgetown-core.rb +1 -1
- data/lib/bridgetown-core/commands/apply.rb +4 -3
- data/lib/bridgetown-core/commands/configure.rb +62 -0
- data/lib/bridgetown-core/commands/new.rb +8 -0
- data/lib/bridgetown-core/commands/plugins.rb +1 -0
- data/lib/bridgetown-core/configurations/.keep +0 -0
- data/lib/bridgetown-core/configurations/bt-postcss.rb +26 -0
- data/lib/bridgetown-core/configurations/bt-postcss/postcss.config.js +21 -0
- data/lib/bridgetown-core/configurations/minitesting.rb +95 -0
- data/lib/bridgetown-core/configurations/netlify.rb +6 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.sh +14 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.toml +44 -0
- data/lib/bridgetown-core/configurations/purgecss.rb +49 -0
- data/lib/bridgetown-core/configurations/stimulus.rb +49 -0
- data/lib/bridgetown-core/configurations/swup.rb +37 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +29 -0
- data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +4 -0
- data/lib/bridgetown-core/configurations/tailwindcss/postcss.config.js +12 -0
- data/lib/bridgetown-core/configurations/turbo.rb +16 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +6 -13
- data/lib/bridgetown-core/filters.rb +1 -1
- data/lib/bridgetown-core/generator.rb +2 -1
- data/lib/bridgetown-core/plugin.rb +2 -26
- data/lib/bridgetown-core/ruby_template_view.rb +9 -1
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/site_template/README.md +70 -0
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82771f9cc6fa2993f61010025de7fab09c2be37d9dfb3f365d728a6dd3ed5b3a
|
4
|
+
data.tar.gz: ab1cfb7e45eac85bb80852b33ab4ca1f5cc69b52f6a1bde70ea1c70c39859005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67ea143f786bf6825f6db8ffa4ba1ce336e5d20e6746bbb24a754df40e0ba5084c3a5a04b0965f7ee080de67f2312b79d0251f34d76174fd55ca3ba379667928
|
7
|
+
data.tar.gz: 2ad31567525e3b3633c4620088df104d2fe5ae65010ffadab04baa33982c960640430f16f13eeab6718c27ec2e66574e5aeeb30be90086ab2707a9f465e9d9c5
|
data/bridgetown-core.gemspec
CHANGED
@@ -42,15 +42,14 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_runtime_dependency("i18n", "~> 1.0")
|
43
43
|
s.add_runtime_dependency("kramdown", "~> 2.1")
|
44
44
|
s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
|
45
|
-
s.add_runtime_dependency("liquid", "~>
|
45
|
+
s.add_runtime_dependency("liquid", "~> 5.0")
|
46
46
|
s.add_runtime_dependency("liquid-component", ">= 0.1")
|
47
|
-
s.add_runtime_dependency("liquid-render-tag", "~> 0.2")
|
48
47
|
s.add_runtime_dependency("listen", "~> 3.0")
|
49
48
|
s.add_runtime_dependency("pathutil", "~> 0.9")
|
50
49
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
51
50
|
s.add_runtime_dependency("safe_yaml", "~> 1.0")
|
52
51
|
s.add_runtime_dependency("terminal-table", "~> 1.8")
|
53
|
-
s.add_runtime_dependency("thor", "~> 1.
|
52
|
+
s.add_runtime_dependency("thor", "~> 1.1")
|
54
53
|
s.add_runtime_dependency("tilt", "~> 2.0")
|
55
54
|
s.add_runtime_dependency("webrick", "~> 1.7")
|
56
55
|
end
|
data/lib/bridgetown-core.rb
CHANGED
@@ -35,12 +35,12 @@ require "active_support/core_ext/object/blank"
|
|
35
35
|
require "active_support/core_ext/string/inflections"
|
36
36
|
require "active_support/core_ext/string/inquiry"
|
37
37
|
require "active_support/core_ext/string/starts_ends_with"
|
38
|
+
require "active_support/descendants_tracker"
|
38
39
|
require "hash_with_dot_access"
|
39
40
|
require "pathutil"
|
40
41
|
require "addressable/uri"
|
41
42
|
require "safe_yaml/load"
|
42
43
|
require "liquid"
|
43
|
-
require "liquid-render-tag"
|
44
44
|
require "liquid-component"
|
45
45
|
require "kramdown"
|
46
46
|
require "colorator"
|
@@ -26,6 +26,7 @@ module Bridgetown
|
|
26
26
|
|
27
27
|
def apply_automation
|
28
28
|
@source_paths = [Dir.pwd]
|
29
|
+
@logger = Bridgetown.logger
|
29
30
|
|
30
31
|
if options[:apply]
|
31
32
|
apply_after_new_command
|
@@ -33,9 +34,9 @@ module Bridgetown
|
|
33
34
|
apply_in_pwd
|
34
35
|
end
|
35
36
|
rescue SystemExit => e
|
36
|
-
|
37
|
+
@logger.error "Problem occurred while running automation:"
|
37
38
|
e.backtrace[0..3].each do |backtrace_line|
|
38
|
-
|
39
|
+
@logger.info backtrace_line if backtrace_line.include?(":in `apply'")
|
39
40
|
end
|
40
41
|
raise e
|
41
42
|
end
|
@@ -66,7 +67,7 @@ module Bridgetown
|
|
66
67
|
apply_from_url automation_command
|
67
68
|
end
|
68
69
|
rescue ArgumentError => e
|
69
|
-
|
70
|
+
@logger.warn "Oops!", e.message
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
class Configure < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
extend Summarizable
|
8
|
+
|
9
|
+
Registrations.register do
|
10
|
+
register(Configure, "configure", "configure CONFIGURATION", Configure.summary)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"bridgetown configure CONFIGURATION(S)"
|
15
|
+
end
|
16
|
+
summary "Set up bundled Bridgetown configurations"
|
17
|
+
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def perform_configurations
|
23
|
+
logger = Bridgetown.logger
|
24
|
+
list_configurations if args.empty?
|
25
|
+
|
26
|
+
args.each do |configuration|
|
27
|
+
configure configuration
|
28
|
+
rescue Thor::Error
|
29
|
+
logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.source_root
|
34
|
+
File.expand_path("../configurations", __dir__)
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def configure(configuration)
|
40
|
+
configuration_file = find_in_source_paths("#{configuration}.rb")
|
41
|
+
|
42
|
+
inside(New.created_site_dir || Dir.pwd) do
|
43
|
+
Apply.new.invoke(:apply_automation, [configuration_file])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def list_configurations
|
48
|
+
say "Please specify a valid packaged configuration from the below list:\n\n"
|
49
|
+
configurations.each do |configuration|
|
50
|
+
configuration = set_color configuration, :blue, :bold
|
51
|
+
say configuration
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def configurations
|
56
|
+
inside self.class.source_root do
|
57
|
+
return Dir.glob("*.rb").map { |file| file.sub(".rb", "") }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -19,6 +19,10 @@ module Bridgetown
|
|
19
19
|
aliases: "-a",
|
20
20
|
banner: "PATH|URL",
|
21
21
|
desc: "Apply an automation after creating the site scaffold"
|
22
|
+
class_option :configure,
|
23
|
+
aliases: "-c",
|
24
|
+
banner: "CONFIGURATION(S)",
|
25
|
+
desc: "Comma separated list of bundled configurations to perform"
|
22
26
|
class_option :force,
|
23
27
|
type: :boolean,
|
24
28
|
desc: "Force creation even if PATH already exists"
|
@@ -100,6 +104,7 @@ module Bridgetown
|
|
100
104
|
# then automatically execute bundle install from within the new site dir
|
101
105
|
# unless the user opts to skip 'bundle install'.
|
102
106
|
# rubocop:todo Metrics/CyclomaticComplexity
|
107
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
103
108
|
def after_install(path, cli_path, options = {})
|
104
109
|
git_init path
|
105
110
|
|
@@ -110,6 +115,7 @@ module Bridgetown
|
|
110
115
|
yarn_install path unless options["skip-yarn"]
|
111
116
|
|
112
117
|
invoke(Apply, [], options) if options[:apply]
|
118
|
+
invoke(Configure, options[:configure].split(","), {}) if options[:configure]
|
113
119
|
|
114
120
|
logger = Bridgetown.logger
|
115
121
|
yarn_start = "yarn start"
|
@@ -130,6 +136,7 @@ module Bridgetown
|
|
130
136
|
logger.info "Yarn install skipped.".yellow if @skipped_yarn
|
131
137
|
end
|
132
138
|
# rubocop:enable Metrics/CyclomaticComplexity
|
139
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
133
140
|
|
134
141
|
def bundle_install(path)
|
135
142
|
unless Bridgetown.environment == "test"
|
@@ -151,6 +158,7 @@ module Bridgetown
|
|
151
158
|
unless Bridgetown.environment == "test"
|
152
159
|
inside(path) do
|
153
160
|
run "git init", abort_on_failure: true
|
161
|
+
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
154
162
|
end
|
155
163
|
end
|
156
164
|
rescue SystemExit
|
@@ -150,6 +150,7 @@ module Bridgetown
|
|
150
150
|
inside name do # rubocop:todo Metrics/BlockLength
|
151
151
|
run "rm -rf .git"
|
152
152
|
run "git init"
|
153
|
+
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
153
154
|
|
154
155
|
run "mv bridgetown-sample-plugin.gemspec #{new_gemspec}"
|
155
156
|
gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
TEMPLATE_PATH = File.expand_path("./bt-postcss", __dir__)
|
6
|
+
|
7
|
+
begin
|
8
|
+
find_in_source_paths("postcss.config.js")
|
9
|
+
rescue Thor::Error
|
10
|
+
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
11
|
+
|
12
|
+
@logger.error "\nError:".red, "🚨 #{error_message}"
|
13
|
+
@logger.info "\nFor new projects, you can use #{"bridgetown new my_project --use-postcss".bold.blue}\n"
|
14
|
+
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
plugins = %w(postcss-easy-import postcss-mixins postcss-color-function cssnano)
|
19
|
+
|
20
|
+
say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
|
21
|
+
run "yarn add -D #{plugins.join(' ')}"
|
22
|
+
|
23
|
+
remove_file "postcss.config.js"
|
24
|
+
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
|
25
|
+
|
26
|
+
# rubocop:enable all
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module.exports = {
|
2
|
+
plugins: {
|
3
|
+
'postcss-easy-import': {},
|
4
|
+
'postcss-mixins': {},
|
5
|
+
'postcss-color-function': {},
|
6
|
+
'postcss-flexbugs-fixes': {},
|
7
|
+
'postcss-preset-env': {
|
8
|
+
autoprefixer: {
|
9
|
+
flexbox: 'no-2009'
|
10
|
+
},
|
11
|
+
stage: 2,
|
12
|
+
features: {
|
13
|
+
'nesting-rules': true,
|
14
|
+
'custom-media-queries': true
|
15
|
+
},
|
16
|
+
},
|
17
|
+
'cssnano' : {
|
18
|
+
preset: 'default'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
say_status :minitesting, "Adding test gems, package.json scripts, and examples"
|
6
|
+
|
7
|
+
append_to_file "Gemfile" do
|
8
|
+
<<~GEMS
|
9
|
+
\n
|
10
|
+
group :test, optional: true do
|
11
|
+
gem "nokogiri"
|
12
|
+
gem "minitest"
|
13
|
+
gem "minitest-profile"
|
14
|
+
gem "minitest-reporters"
|
15
|
+
gem "shoulda"
|
16
|
+
gem "rails-dom-testing"
|
17
|
+
end
|
18
|
+
GEMS
|
19
|
+
end
|
20
|
+
|
21
|
+
new_scripts = ' "test": "BRIDGETOWN_ENV=test yarn build",'
|
22
|
+
new_scripts += "\n" + ' "deploy:test": "bundle install --with test && yarn deploy"'
|
23
|
+
package_json = "package.json"
|
24
|
+
script_regex = %r{"scripts": \{(\s+".*,?)*}
|
25
|
+
inject_into_file(package_json, ",\n" + new_scripts, after: script_regex)
|
26
|
+
|
27
|
+
create_file "test/helper.rb" do
|
28
|
+
<<~RUBY
|
29
|
+
require "nokogiri"
|
30
|
+
require "minitest/autorun"
|
31
|
+
require "minitest/reporters"
|
32
|
+
require "minitest/profile"
|
33
|
+
require "shoulda"
|
34
|
+
require "rails-dom-testing"
|
35
|
+
# Report with color.
|
36
|
+
Minitest::Reporters.use! [
|
37
|
+
Minitest::Reporters::DefaultReporter.new(
|
38
|
+
color: true
|
39
|
+
),
|
40
|
+
]
|
41
|
+
Minitest::Test.class_eval do
|
42
|
+
include Rails::Dom::Testing::Assertions
|
43
|
+
def site
|
44
|
+
@site ||= Bridgetown.sites.first
|
45
|
+
end
|
46
|
+
def nokogiri(input)
|
47
|
+
input.respond_to?(:output) ? Nokogiri::HTML(input.output) : Nokogiri::HTML(input)
|
48
|
+
end
|
49
|
+
def document_root(root)
|
50
|
+
@document_root = root.is_a?(Nokogiri::XML::Document) ? root : nokogiri(root)
|
51
|
+
end
|
52
|
+
def document_root_element
|
53
|
+
if @document_root.nil?
|
54
|
+
raise "Call `document_root' with a Nokogiri document before testing your assertions"
|
55
|
+
end
|
56
|
+
@document_root
|
57
|
+
end
|
58
|
+
end
|
59
|
+
RUBY
|
60
|
+
end
|
61
|
+
|
62
|
+
create_file "test/test_homepage.rb" do
|
63
|
+
<<~RUBY
|
64
|
+
require_relative "./helper"
|
65
|
+
class TestHomepage < Minitest::Test
|
66
|
+
context "homepage" do
|
67
|
+
setup do
|
68
|
+
page = site.pages.find { |doc| doc.url == "/" }
|
69
|
+
document_root page
|
70
|
+
end
|
71
|
+
should "exist" do
|
72
|
+
assert_select "body"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
RUBY
|
77
|
+
end
|
78
|
+
|
79
|
+
create_file "plugins/test_output.rb" do
|
80
|
+
<<~RUBY
|
81
|
+
unless Bridgetown.environment == "development"
|
82
|
+
Bridgetown::Hooks.register :site, :post_write do
|
83
|
+
# Load test suite to run on exit
|
84
|
+
require "nokogiri"
|
85
|
+
Dir["test/**/*.rb"].each { |file| require_relative("../\#{file}") }
|
86
|
+
rescue LoadError
|
87
|
+
Bridgetown.logger.warn "Testing:", "To run tests, you must first run \`bundle install --with test\`"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
RUBY
|
91
|
+
end
|
92
|
+
|
93
|
+
say_status :minitesting, "All set! To get started, look at test/test_homepage.rb and then run \`yarn test\`"
|
94
|
+
|
95
|
+
# rubocop:enable all
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# Taken from https://docs.netlify.com/configure-builds/file-based-configuration/#inject-environment-variable-values
|
3
|
+
|
4
|
+
echo "Updating netlify.toml with references to our built files"
|
5
|
+
|
6
|
+
CSS_PATH=`find output/_bridgetown/static/css/*.css -type f | sed -e 's,output\/,/,g'`
|
7
|
+
JS_PATH=`find output/_bridgetown/static/js/*.js -type f | sed -e 's,output\/,/,g'`
|
8
|
+
|
9
|
+
echo "CSS Path: ${CSS_PATH}"
|
10
|
+
echo "JS Path: ${JS_PATH}"
|
11
|
+
|
12
|
+
sed -i s,CSS_PATH,${CSS_PATH},g netlify.toml
|
13
|
+
sed -i s,JS_PATH,${JS_PATH},g netlify.toml
|
14
|
+
sed -i s,NETLIFY_IMAGES_CDN_DOMAIN,${NETLIFY_IMAGES_CDN_DOMAIN},g netlify.toml
|
@@ -0,0 +1,44 @@
|
|
1
|
+
[build]
|
2
|
+
command = "yarn deploy && ./bin/netlify.sh"
|
3
|
+
publish = "output"
|
4
|
+
|
5
|
+
[build.environment]
|
6
|
+
NODE_ENV = "development"
|
7
|
+
BRIDGETOWN_ENV = "production"
|
8
|
+
|
9
|
+
[build.processing]
|
10
|
+
skip_processing = false
|
11
|
+
[build.processing.css]
|
12
|
+
bundle = false
|
13
|
+
minify = true
|
14
|
+
[build.processing.js]
|
15
|
+
bundle = false
|
16
|
+
minify = true
|
17
|
+
[build.processing.html]
|
18
|
+
pretty_urls = true
|
19
|
+
[build.processing.images]
|
20
|
+
compress = true
|
21
|
+
|
22
|
+
[[headers]]
|
23
|
+
for = "*"
|
24
|
+
[headers.values]
|
25
|
+
X-Frame-Options = "DENY"
|
26
|
+
X-XSS-Protection = "1; mode=block"
|
27
|
+
X-Content-Type-Options = "nosniff"
|
28
|
+
Strict-Transport-Security = "max-age=15552000; includeSubDomains"
|
29
|
+
Referrer-Policy = "no-referrer-when-downgrade"
|
30
|
+
Cache-Control = "public, max-age=604800, s-max-age=604800"
|
31
|
+
|
32
|
+
[[headers]]
|
33
|
+
for = "/"
|
34
|
+
[headers.values]
|
35
|
+
Link = [
|
36
|
+
"<CSS_PATH>; rel=preload; as=style",
|
37
|
+
"<JS_PATH>; rel=preload; as=script",
|
38
|
+
"<https://NETLIFY_IMAGES_CDN_DOMAIN>; rel=preconnect"
|
39
|
+
]
|
40
|
+
|
41
|
+
[[headers]]
|
42
|
+
for = "/*.(png|jpg|js|css|svg|woff|ttf|eot|ico|woff2)"
|
43
|
+
[headers.values]
|
44
|
+
Cache-Control = "public, max-age=31536000, s-max-age=31536000"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
say_status :purgecss, "Installing PurgeCSS"
|
6
|
+
|
7
|
+
run "yarn add -D purgecss"
|
8
|
+
|
9
|
+
create_builder "purgecss_builder.rb" do
|
10
|
+
<<~RUBY
|
11
|
+
class PurgeCSS < SiteBuilder
|
12
|
+
def build
|
13
|
+
unless config[:watch] # don't run in "watch mode"
|
14
|
+
hook :site, :post_write do
|
15
|
+
purgecss_file = site.in_root_dir("purgecss.config.js")
|
16
|
+
unless File.exist?(purgecss_file)
|
17
|
+
config_js = <<~PURGE
|
18
|
+
module.exports = {
|
19
|
+
content: ['frontend/javascript/*.js','./output/**/*.html'],
|
20
|
+
output: "./output/_bridgetown/static/css"
|
21
|
+
}
|
22
|
+
PURGE
|
23
|
+
File.write(purgecss_file, config_js.strip)
|
24
|
+
end
|
25
|
+
manifest_file = site.in_root_dir(".bridgetown-webpack", "manifest.json")
|
26
|
+
if File.exist?(manifest_file)
|
27
|
+
manifest = JSON.parse(File.read(manifest_file))
|
28
|
+
css_file = manifest["main.css"].split("/").last
|
29
|
+
css_path = ["output", "_bridgetown", "static", "css", css_file].join("/")
|
30
|
+
Bridgetown.logger.info "PurgeCSS", "Purging \#{css_file}"
|
31
|
+
oldsize = File.stat(css_path).size / 1000
|
32
|
+
system "./node_modules/.bin/purgecss -c purgecss.config.js -css \#{css_path}"
|
33
|
+
newsize = File.stat(css_path).size / 1000
|
34
|
+
if newsize < oldsize
|
35
|
+
Bridgetown.logger.info "PurgeCSS", "Done! File size reduced from \#{oldsize}kB to \#{newsize}kB"
|
36
|
+
else
|
37
|
+
Bridgetown.logger.info "PurgeCSS", "Done. No apparent change in file size (\#{newsize}kB)."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
RUBY
|
45
|
+
end
|
46
|
+
|
47
|
+
say_status :purgecss, "All set! Open plugins/builders/purgecss_builder.rb if you'd like to customize the PurgeCSS config."
|
48
|
+
|
49
|
+
# rubocop:enable all
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
say "Installing Stimulus...", :green
|
6
|
+
|
7
|
+
run("yarn add stimulus")
|
8
|
+
|
9
|
+
say 'Adding Stimulus to "frontend/javascript/index.js"...', :magenta
|
10
|
+
|
11
|
+
javascript_import do
|
12
|
+
<<~JS
|
13
|
+
import { Application } from "stimulus"
|
14
|
+
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
15
|
+
JS
|
16
|
+
end
|
17
|
+
|
18
|
+
javascript_dir = File.join("frontend", "javascript")
|
19
|
+
|
20
|
+
append_to_file(File.join(javascript_dir, "index.js")) do
|
21
|
+
<<~JS
|
22
|
+
const application = Application.start()
|
23
|
+
const context = require.context("./controllers", true, /\.js$/)
|
24
|
+
application.load(definitionsFromContext(context))
|
25
|
+
JS
|
26
|
+
end
|
27
|
+
|
28
|
+
controller_dir = File.join(javascript_dir, "controllers")
|
29
|
+
|
30
|
+
say "Creating a `./#{controller_dir}` directory...", :magenta
|
31
|
+
FileUtils.mkdir_p(controller_dir)
|
32
|
+
|
33
|
+
say "Creating an example Stimulus Controller for you!...", :magenta
|
34
|
+
create_file(File.join(controller_dir, "example_controller.js")) do
|
35
|
+
<<~JS
|
36
|
+
import { Controller } from "stimulus"
|
37
|
+
export default class extends Controller {
|
38
|
+
connect() {
|
39
|
+
console.log("Hello, Stimulus!", this.element)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
JS
|
43
|
+
end
|
44
|
+
|
45
|
+
say "Stimulus successfully added", :green
|
46
|
+
|
47
|
+
say "To start adding controllers, visit the `./frontend/javascript/controllers/` directory", :blue
|
48
|
+
say "Make sure your controllers follow the `[name]_controller.js` convention", :blue
|
49
|
+
say 'For further reading, check out "https://stimulus.hotwire.dev/"', :blue
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
packages = "swup @swup/body-class-plugin @swup/scroll-plugin @swup/fade-theme"
|
6
|
+
say_status :swup, "Adding the following yarn packages: #{packages}"
|
7
|
+
system("yarn add #{packages}")
|
8
|
+
|
9
|
+
javascript_import do
|
10
|
+
<<~JS
|
11
|
+
import Swup from "swup"
|
12
|
+
import SwupBodyClassPlugin from "@swup/body-class-plugin"
|
13
|
+
import SwupScrollPlugin from "@swup/scroll-plugin"
|
14
|
+
import SwupFadeTheme from "@swup/fade-theme"
|
15
|
+
const swup = new Swup({
|
16
|
+
plugins: [
|
17
|
+
new SwupBodyClassPlugin(),
|
18
|
+
new SwupScrollPlugin(),
|
19
|
+
new SwupFadeTheme(),
|
20
|
+
]
|
21
|
+
})
|
22
|
+
JS
|
23
|
+
end
|
24
|
+
|
25
|
+
css_index = File.exist?(File.expand_path("frontend/styles/index.scss", destination_root)) ? "frontend/styles/index.scss" : "frontend/styles/index.css"
|
26
|
+
append_to_file css_index do
|
27
|
+
<<~CSS
|
28
|
+
.swup-transition-main {
|
29
|
+
transition: opacity .2s;
|
30
|
+
}
|
31
|
+
CSS
|
32
|
+
end
|
33
|
+
|
34
|
+
say_status :swup, "All done! Edit .swup-transition-main in #{css_index} if you wish to adjust the transition animation"
|
35
|
+
say_status :swup, "Make sure you add id=\"swup\" to the primary container of your HTML layout (perhaps <main>)"
|
36
|
+
|
37
|
+
# rubocop:enable all
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
TEMPLATE_PATH = File.expand_path("./tailwindcss", __dir__)
|
6
|
+
|
7
|
+
begin
|
8
|
+
find_in_source_paths("postcss.config.js")
|
9
|
+
rescue Thor::Error
|
10
|
+
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
11
|
+
|
12
|
+
@logger.error "\nError:".red, "🚨 #{error_message}"
|
13
|
+
@logger.info "\nFor new projects, you can use #{"bridgetown new my_project --use-postcss".bold.blue}\n"
|
14
|
+
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
run "yarn add -D tailwindcss"
|
19
|
+
run "npx tailwindcss init"
|
20
|
+
|
21
|
+
remove_file "postcss.config.js"
|
22
|
+
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
|
23
|
+
|
24
|
+
prepend_to_file "frontend/styles/index.css",
|
25
|
+
File.read("#{TEMPLATE_PATH}/css_imports.css")
|
26
|
+
|
27
|
+
run "bundle exec bridgetown configure purgecss"
|
28
|
+
|
29
|
+
# rubocop:enable all
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
say "Installing Turbo...", :green
|
4
|
+
|
5
|
+
run("yarn add @hotwired/turbo")
|
6
|
+
|
7
|
+
say 'Adding Turbo to "frontend/javascript/index.js"...', :magenta
|
8
|
+
|
9
|
+
javascript_import do
|
10
|
+
<<~JS
|
11
|
+
import Turbo from "@hotwired/turbo"
|
12
|
+
JS
|
13
|
+
end
|
14
|
+
|
15
|
+
say "Turbo successfully added", :green
|
16
|
+
say 'For further reading, check out "https://turbo.hotwire.dev/"', :blue
|
@@ -65,24 +65,17 @@ module Bridgetown
|
|
65
65
|
block.nil? ? input.to_s : capture(&block)
|
66
66
|
)
|
67
67
|
converter = site.find_converter_instance(Bridgetown::Converters::Markdown)
|
68
|
-
converter.convert(content).strip
|
68
|
+
result = converter.convert(content).strip
|
69
|
+
result.respond_to?(:html_safe) ? result.html_safe : result
|
69
70
|
end
|
70
71
|
|
71
|
-
def capture(
|
72
|
+
def capture(*args, &block)
|
73
|
+
return capture_in_view_component(*args, &block) if @in_view_component
|
74
|
+
|
72
75
|
previous_buffer_state = @_erbout
|
73
76
|
@_erbout = ERBBuffer.new
|
74
|
-
|
75
|
-
# For compatibility with ActionView, not used by Bridgetown normally
|
76
|
-
previous_ob_state = @output_buffer
|
77
|
-
@output_buffer = ERBBuffer.new
|
78
|
-
|
79
|
-
result = instance_exec(obj, &block)
|
80
|
-
if @output_buffer != ""
|
81
|
-
# use Rails' ActionView buffer if present
|
82
|
-
result = @output_buffer
|
83
|
-
end
|
77
|
+
result = yield(*args)
|
84
78
|
@_erbout = previous_buffer_state
|
85
|
-
@output_buffer = previous_ob_state
|
86
79
|
|
87
80
|
result.respond_to?(:html_safe) ? result.html_safe : result
|
88
81
|
end
|
@@ -375,7 +375,7 @@ module Bridgetown
|
|
375
375
|
case target
|
376
376
|
when NilClass
|
377
377
|
return true if property.nil?
|
378
|
-
when
|
378
|
+
when "" # aka `empty` or `blank`
|
379
379
|
target = target.to_s
|
380
380
|
return true if property == target || Array(property).join == target
|
381
381
|
else
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class Plugin
|
5
|
+
extend ActiveSupport::DescendantsTracker
|
6
|
+
|
5
7
|
PRIORITIES = {
|
6
8
|
low: -10,
|
7
9
|
highest: 100,
|
@@ -12,32 +14,6 @@ module Bridgetown
|
|
12
14
|
|
13
15
|
SourceManifest = Struct.new(:origin, :components, :content, :layouts, keyword_init: true)
|
14
16
|
|
15
|
-
#
|
16
|
-
|
17
|
-
def self.inherited(const)
|
18
|
-
catch_inheritance(const) do |const_|
|
19
|
-
catch_inheritance(const_)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
def self.catch_inheritance(const)
|
26
|
-
const.define_singleton_method :inherited do |const_|
|
27
|
-
(@children ||= Set.new).add const_
|
28
|
-
yield const_ if block_given?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
|
34
|
-
def self.descendants
|
35
|
-
@children ||= Set.new
|
36
|
-
out = @children.map(&:descendants)
|
37
|
-
out << self unless superclass == Plugin
|
38
|
-
Set.new(out).flatten
|
39
|
-
end
|
40
|
-
|
41
17
|
# Get or set the priority of this plugin. When called without an
|
42
18
|
# argument it returns the priority. When an argument is given, it will
|
43
19
|
# set the priority.
|
@@ -27,7 +27,15 @@ module Bridgetown
|
|
27
27
|
|
28
28
|
def render(item, options = {}, &block)
|
29
29
|
if item.respond_to?(:render_in)
|
30
|
-
|
30
|
+
previous_buffer_state = @_erbout
|
31
|
+
@_erbout = Bridgetown::ERBBuffer.new
|
32
|
+
|
33
|
+
@in_view_component ||= defined?(::ViewComponent::Base) && item.is_a?(::ViewComponent::Base)
|
34
|
+
result = item.render_in(self, &block)
|
35
|
+
@in_view_component = false
|
36
|
+
|
37
|
+
@_erbout = previous_buffer_state
|
38
|
+
result
|
31
39
|
else
|
32
40
|
partial(item, options, &block)
|
33
41
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Bridgetown Website README
|
2
|
+
|
3
|
+
Welcome to your new Bridgetown website! You can update this README file to provide additional context and setup information for yourself or other contributors.
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [Prerequisites](#prerequisites)
|
8
|
+
- [Install](#install)
|
9
|
+
- [Development](#development)
|
10
|
+
- [Commands](#commands)
|
11
|
+
- [Deployment](#deployment)
|
12
|
+
- [Contributing](#contributing)
|
13
|
+
|
14
|
+
## Prerequisites
|
15
|
+
|
16
|
+
- [GCC](https://gcc.gnu.org/install/)
|
17
|
+
- [Make](https://www.gnu.org/software/make/)
|
18
|
+
- [Ruby](https://www.ruby-lang.org/en/downloads/)
|
19
|
+
- `>= 2.5`
|
20
|
+
- [Bridgetown Gem](https://rubygems.org/gems/bridgetown)
|
21
|
+
- `gem install bundler bridgetown -N`
|
22
|
+
- [Node](https://nodejs.org)
|
23
|
+
- `>= 10.13`
|
24
|
+
- [Yarn](https://yarnpkg.com)
|
25
|
+
|
26
|
+
## Install
|
27
|
+
|
28
|
+
```sh
|
29
|
+
cd bridgetown-site-folder
|
30
|
+
bundle install && yarn install
|
31
|
+
```
|
32
|
+
> Learn more: [Bridgetown Getting Started Documentation](https://www.bridgetownrb.com/docs/).
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
To start your site in development mode, run `yarn start` and navigate to [localhost:4000](https://localhost:4000/)!
|
37
|
+
|
38
|
+
Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](https://www.bridgetownrb.com/plugins/), and/or run some [automations](https://github.com/topics/bridgetown-automation) to get started quickly.
|
39
|
+
|
40
|
+
### Commands
|
41
|
+
|
42
|
+
```sh
|
43
|
+
# running locally
|
44
|
+
yarn start
|
45
|
+
|
46
|
+
# build & deploy to production
|
47
|
+
yarn deploy
|
48
|
+
|
49
|
+
# load the site up within a Ruby console (IRB)
|
50
|
+
bundle exec bridgetown console
|
51
|
+
```
|
52
|
+
|
53
|
+
> Learn more: [Bridgetown CLI Documentation](https://www.bridgetownrb.com/docs/command-line-usage)
|
54
|
+
|
55
|
+
## Deployment
|
56
|
+
|
57
|
+
You can deploy Bridgetown sites on "Jamstack" hosts (Netlify, Vercel, Render, etc.) or virtually any tranditional web server by simply building and copying the output folder to your HTML root.
|
58
|
+
|
59
|
+
> Read the [Bridgetown Deployment Documentation](https://www.bridgetownrb.com/docs/deployment) for more information.
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
If repo is on GitHub:
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Clone the fork using `git clone` to your local development machine.
|
67
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
6. Create a new Pull Request
|
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: 0.19.
|
4
|
+
version: 0.19.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '5.0'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '5.0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: liquid-component
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,20 +192,6 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0.1'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: liquid-render-tag
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0.2'
|
202
|
-
type: :runtime
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - "~>"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0.2'
|
209
195
|
- !ruby/object:Gem::Dependency
|
210
196
|
name: listen
|
211
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,14 +268,14 @@ dependencies:
|
|
282
268
|
requirements:
|
283
269
|
- - "~>"
|
284
270
|
- !ruby/object:Gem::Version
|
285
|
-
version: '1.
|
271
|
+
version: '1.1'
|
286
272
|
type: :runtime
|
287
273
|
prerelease: false
|
288
274
|
version_requirements: !ruby/object:Gem::Requirement
|
289
275
|
requirements:
|
290
276
|
- - "~>"
|
291
277
|
- !ruby/object:Gem::Version
|
292
|
-
version: '1.
|
278
|
+
version: '1.1'
|
293
279
|
- !ruby/object:Gem::Dependency
|
294
280
|
name: tilt
|
295
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -342,6 +328,7 @@ files:
|
|
342
328
|
- lib/bridgetown-core/commands/concerns/build_options.rb
|
343
329
|
- lib/bridgetown-core/commands/concerns/configuration_overridable.rb
|
344
330
|
- lib/bridgetown-core/commands/concerns/summarizable.rb
|
331
|
+
- lib/bridgetown-core/commands/configure.rb
|
345
332
|
- lib/bridgetown-core/commands/console.rb
|
346
333
|
- lib/bridgetown-core/commands/doctor.rb
|
347
334
|
- lib/bridgetown-core/commands/new.rb
|
@@ -362,6 +349,20 @@ files:
|
|
362
349
|
- lib/bridgetown-core/concerns/site/writable.rb
|
363
350
|
- lib/bridgetown-core/concerns/validatable.rb
|
364
351
|
- lib/bridgetown-core/configuration.rb
|
352
|
+
- lib/bridgetown-core/configurations/.keep
|
353
|
+
- lib/bridgetown-core/configurations/bt-postcss.rb
|
354
|
+
- lib/bridgetown-core/configurations/bt-postcss/postcss.config.js
|
355
|
+
- lib/bridgetown-core/configurations/minitesting.rb
|
356
|
+
- lib/bridgetown-core/configurations/netlify.rb
|
357
|
+
- lib/bridgetown-core/configurations/netlify/netlify.sh
|
358
|
+
- lib/bridgetown-core/configurations/netlify/netlify.toml
|
359
|
+
- lib/bridgetown-core/configurations/purgecss.rb
|
360
|
+
- lib/bridgetown-core/configurations/stimulus.rb
|
361
|
+
- lib/bridgetown-core/configurations/swup.rb
|
362
|
+
- lib/bridgetown-core/configurations/tailwindcss.rb
|
363
|
+
- lib/bridgetown-core/configurations/tailwindcss/css_imports.css
|
364
|
+
- lib/bridgetown-core/configurations/tailwindcss/postcss.config.js
|
365
|
+
- lib/bridgetown-core/configurations/turbo.rb
|
365
366
|
- lib/bridgetown-core/converter.rb
|
366
367
|
- lib/bridgetown-core/converters/erb_templates.rb
|
367
368
|
- lib/bridgetown-core/converters/identity.rb
|
@@ -448,6 +449,7 @@ files:
|
|
448
449
|
- lib/bridgetown-core/watcher.rb
|
449
450
|
- lib/site_template/.gitignore
|
450
451
|
- lib/site_template/Gemfile.erb
|
452
|
+
- lib/site_template/README.md
|
451
453
|
- lib/site_template/bridgetown.config.yml
|
452
454
|
- lib/site_template/frontend/javascript/index.js.erb
|
453
455
|
- lib/site_template/frontend/styles/index.css
|