bridgetown-core 1.3.4 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bridgetown +0 -6
- data/bin/bt +6 -0
- data/bridgetown-core.gemspec +9 -6
- data/lib/bridgetown-core/cleaner.rb +1 -1
- data/lib/bridgetown-core/collection.rb +30 -18
- data/lib/bridgetown-core/commands/build.rb +9 -22
- data/lib/bridgetown-core/commands/concerns/actions.rb +15 -8
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +1 -1
- data/lib/bridgetown-core/commands/console.rb +3 -0
- data/lib/bridgetown-core/commands/doctor.rb +2 -4
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +1 -1
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
- data/lib/bridgetown-core/commands/esbuild/update.rb +2 -2
- data/lib/bridgetown-core/commands/esbuild.rb +3 -3
- data/lib/bridgetown-core/commands/new.rb +32 -39
- data/lib/bridgetown-core/commands/start.rb +76 -60
- data/lib/bridgetown-core/component.rb +19 -13
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/prioritizable.rb +11 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +7 -18
- data/lib/bridgetown-core/concerns/site/content.rb +10 -9
- data/lib/bridgetown-core/concerns/site/extensible.rb +4 -6
- data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +161 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +31 -7
- data/lib/bridgetown-core/concerns/site/ssr.rb +23 -9
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
- data/lib/bridgetown-core/concerns/transformable.rb +3 -5
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +23 -14
- data/lib/bridgetown-core/configuration.rb +67 -114
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -2
- data/lib/bridgetown-core/configurations/cypress/cypress_tasks +2 -2
- data/lib/bridgetown-core/configurations/cypress.rb +1 -1
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +3 -3
- data/lib/bridgetown-core/configurations/is-land.rb +1 -1
- data/lib/bridgetown-core/configurations/lit.rb +1 -1
- data/lib/bridgetown-core/configurations/open-props.rb +1 -1
- data/lib/bridgetown-core/configurations/purgecss.rb +1 -1
- data/lib/bridgetown-core/configurations/ruby2js.rb +1 -1
- data/lib/bridgetown-core/configurations/shoelace.rb +8 -20
- data/lib/bridgetown-core/configurations/stimulus.rb +17 -36
- data/lib/bridgetown-core/configurations/turbo.rb +1 -2
- data/lib/bridgetown-core/converter.rb +38 -10
- data/lib/bridgetown-core/converters/erb_templates.rb +9 -26
- data/lib/bridgetown-core/converters/identity.rb +1 -1
- data/lib/bridgetown-core/converters/liquid_templates.rb +2 -20
- data/lib/bridgetown-core/converters/ruby_templates.rb +61 -3
- data/lib/bridgetown-core/converters/serbea_templates.rb +12 -24
- data/lib/bridgetown-core/current.rb +19 -17
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/drop.rb +3 -3
- data/lib/bridgetown-core/drops/relations_drop.rb +3 -2
- data/lib/bridgetown-core/drops/site_drop.rb +0 -5
- data/lib/bridgetown-core/entry_filter.rb +4 -6
- data/lib/bridgetown-core/errors.rb +2 -2
- data/lib/bridgetown-core/filters/from_liquid.rb +6 -10
- data/lib/bridgetown-core/filters/localization_filters.rb +1 -1
- data/lib/bridgetown-core/filters/translation_filters.rb +2 -2
- data/lib/bridgetown-core/filters.rb +3 -3
- data/lib/bridgetown-core/front_matter/defaults.rb +225 -0
- data/lib/bridgetown-core/front_matter/importer.rb +34 -0
- data/lib/bridgetown-core/front_matter/loaders/base.rb +29 -0
- data/lib/bridgetown-core/front_matter/loaders/ruby.rb +113 -0
- data/lib/bridgetown-core/front_matter/loaders/yaml.rb +42 -0
- data/lib/bridgetown-core/front_matter/loaders.rb +44 -0
- data/lib/bridgetown-core/{utils/ruby_front_matter.rb → front_matter/ruby.rb} +5 -5
- data/lib/bridgetown-core/front_matter.rb +11 -0
- data/lib/bridgetown-core/generated_page.rb +71 -31
- data/lib/bridgetown-core/generators/prototype_generator.rb +30 -18
- data/lib/bridgetown-core/helpers.rb +36 -47
- data/lib/bridgetown-core/hooks.rb +5 -5
- data/lib/bridgetown-core/inflector.rb +40 -0
- data/lib/bridgetown-core/kramdown/parser/gfm.rb +2 -2
- data/lib/bridgetown-core/layout.rb +3 -3
- data/lib/bridgetown-core/log_adapter.rb +12 -13
- data/lib/bridgetown-core/log_writer.rb +4 -4
- data/lib/bridgetown-core/model/base.rb +17 -17
- data/lib/bridgetown-core/model/builder_origin.rb +5 -3
- data/lib/bridgetown-core/model/origin.rb +1 -3
- data/lib/bridgetown-core/model/repo_origin.rb +12 -14
- data/lib/bridgetown-core/plugin.rb +0 -1
- data/lib/bridgetown-core/plugin_manager.rb +27 -84
- data/lib/bridgetown-core/rack/boot.rb +0 -15
- data/lib/bridgetown-core/rack/routes.rb +30 -90
- data/lib/bridgetown-core/reader.rb +6 -4
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +2 -2
- data/lib/bridgetown-core/resource/base.rb +112 -29
- data/lib/bridgetown-core/resource/destination.rb +1 -1
- data/lib/bridgetown-core/resource/relations.rb +11 -8
- data/lib/bridgetown-core/resource/taxonomy_type.rb +3 -1
- data/lib/bridgetown-core/resource/transformer.rb +4 -4
- data/lib/bridgetown-core/ruby_template_view.rb +44 -28
- data/lib/bridgetown-core/signals.rb +95 -0
- data/lib/bridgetown-core/site.rb +22 -4
- data/lib/bridgetown-core/slot.rb +5 -5
- data/lib/bridgetown-core/static_file.rb +5 -7
- data/lib/bridgetown-core/tags/asset_path.rb +11 -2
- data/lib/bridgetown-core/tags/find.rb +3 -5
- data/lib/bridgetown-core/tags/highlight.rb +3 -3
- data/lib/bridgetown-core/tags/post_url.rb +1 -1
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +2 -2
- data/lib/bridgetown-core/utils/aux.rb +41 -41
- data/lib/bridgetown-core/utils/loaders_manager.rb +2 -21
- data/lib/bridgetown-core/utils/ruby_exec.rb +17 -0
- data/lib/bridgetown-core/utils.rb +46 -110
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +21 -10
- data/lib/bridgetown-core.rb +35 -49
- data/lib/roda/plugins/bridgetown_server.rb +54 -12
- data/lib/roda/plugins/bridgetown_ssr.rb +13 -2
- data/lib/roda/plugins/ssg.rb +72 -0
- data/lib/site_template/.gitignore +9 -3
- data/lib/site_template/Gemfile.erb +3 -3
- data/lib/site_template/README.md +3 -4
- data/lib/site_template/Rakefile.erb +2 -15
- data/lib/site_template/TEMPLATES/erb/_partials/_head.erb +2 -2
- data/lib/site_template/TEMPLATES/serbea/_partials/_head.serb +2 -2
- data/lib/site_template/config/initializers.rb +60 -22
- data/lib/site_template/config/puma.rb +2 -0
- data/lib/site_template/package.json.erb +2 -27
- data/lib/site_template/src/index.md.erb +3 -3
- data/lib/site_template/tmp/pids/.keep +0 -0
- metadata +98 -63
- data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +0 -12
- data/lib/bridgetown-core/commands/webpack/setup.rb +0 -4
- data/lib/bridgetown-core/commands/webpack/update.rb +0 -24
- data/lib/bridgetown-core/commands/webpack/webpack.config.js +0 -31
- data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +0 -135
- data/lib/bridgetown-core/commands/webpack.rb +0 -82
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +0 -52
- data/lib/bridgetown-core/concerns/liquid_renderable.rb +0 -30
- data/lib/bridgetown-core/core_ext/psych.rb +0 -15
- data/lib/bridgetown-core/drops/url_drop.rb +0 -152
- data/lib/bridgetown-core/frontmatter_defaults.rb +0 -223
- data/lib/bridgetown-core/rack/static_indexes.rb +0 -31
- data/lib/bridgetown-core/url.rb +0 -166
- data/lib/bridgetown-core/utils/ansi.rb +0 -57
- data/lib/site_template/bridgetown.config.yml +0 -33
data/lib/bridgetown-core/url.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Public: Methods that generate a URL for GeneratedPage.
|
4
|
-
#
|
5
|
-
# Examples
|
6
|
-
#
|
7
|
-
# URL.new({
|
8
|
-
# :template => /:categories/:title.html",
|
9
|
-
# :placeholders => {:categories => "ruby", :title => "something"}
|
10
|
-
# }).to_s
|
11
|
-
#
|
12
|
-
module Bridgetown
|
13
|
-
# TODO: remove this class in favor of the new Resource permalink processor
|
14
|
-
class URL
|
15
|
-
# options - One of :permalink or :template must be supplied.
|
16
|
-
# :template - The String used as template for URL generation,
|
17
|
-
# for example "/:path/:basename:output_ext", where
|
18
|
-
# a placeholder is prefixed with a colon.
|
19
|
-
# :placeholders - A hash containing the placeholders which will be
|
20
|
-
# replaced when used inside the template. E.g.
|
21
|
-
# { "year" => Time.now.strftime("%Y") } would replace
|
22
|
-
# the placeholder ":year" with the current year.
|
23
|
-
# :permalink - If supplied, no URL will be generated from the
|
24
|
-
# template. Instead, the given permalink will be
|
25
|
-
# used as URL.
|
26
|
-
def initialize(options)
|
27
|
-
@template = options[:template]
|
28
|
-
@placeholders = options[:placeholders] || {}
|
29
|
-
@permalink = options[:permalink]
|
30
|
-
|
31
|
-
return unless (@template || @permalink).nil?
|
32
|
-
|
33
|
-
raise ArgumentError, "One of :template or :permalink must be supplied."
|
34
|
-
end
|
35
|
-
|
36
|
-
# The generated relative URL of the resource
|
37
|
-
#
|
38
|
-
# Returns the String URL
|
39
|
-
def to_s
|
40
|
-
sanitize_url(generated_permalink || generated_url)
|
41
|
-
end
|
42
|
-
|
43
|
-
# Generates a URL from the permalink
|
44
|
-
#
|
45
|
-
# Returns the _unsanitized String URL
|
46
|
-
def generated_permalink
|
47
|
-
(@generated_permalink ||= generate_url(@permalink)) if @permalink
|
48
|
-
end
|
49
|
-
|
50
|
-
# Generates a URL from the template
|
51
|
-
#
|
52
|
-
# Returns the unsanitized String URL
|
53
|
-
def generated_url
|
54
|
-
@generated_url ||= generate_url(@template)
|
55
|
-
end
|
56
|
-
|
57
|
-
# Internal: Generate the URL by replacing all placeholders with their
|
58
|
-
# respective values in the given template
|
59
|
-
#
|
60
|
-
# Returns the unsanitized String URL
|
61
|
-
def generate_url(template)
|
62
|
-
if @placeholders.is_a? Drops::UrlDrop
|
63
|
-
generate_url_from_drop(template)
|
64
|
-
else
|
65
|
-
generate_url_from_hash(template)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def generate_url_from_hash(template)
|
70
|
-
@placeholders.inject(template) do |result, token|
|
71
|
-
break result if result.index(":").nil?
|
72
|
-
|
73
|
-
if token.last.nil?
|
74
|
-
# Remove leading "/" to avoid generating urls with `//`
|
75
|
-
result.gsub("/:#{token.first}", "")
|
76
|
-
else
|
77
|
-
result.gsub(":#{token.first}", self.class.escape_path(token.last))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# We include underscores in keys to allow for 'i_month' and so forth.
|
83
|
-
# This poses a problem for keys which are followed by an underscore
|
84
|
-
# but the underscore is not part of the key, e.g. '/:month_:day'.
|
85
|
-
# That should be :month and :day, but our key extraction regexp isn't
|
86
|
-
# smart enough to know that so we have to make it an explicit
|
87
|
-
# possibility.
|
88
|
-
def possible_keys(key)
|
89
|
-
if key.end_with?("_")
|
90
|
-
[key, key.chomp("_")]
|
91
|
-
else
|
92
|
-
[key]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def generate_url_from_drop(template)
|
97
|
-
template.gsub(%r!:([a-z_]+)!) do |match|
|
98
|
-
pool = possible_keys(match.sub(":", ""))
|
99
|
-
|
100
|
-
winner = pool.find { |key| @placeholders.key?(key) }
|
101
|
-
if winner.nil?
|
102
|
-
raise NoMethodError,
|
103
|
-
"The URL template doesn't have #{pool.join(" or ")} keys. " \
|
104
|
-
"Check your permalink template!"
|
105
|
-
end
|
106
|
-
|
107
|
-
value = @placeholders[winner]
|
108
|
-
value = "" if value.nil?
|
109
|
-
replacement = self.class.escape_path(value)
|
110
|
-
|
111
|
-
match.sub(":#{winner}", replacement)
|
112
|
-
end.squeeze("/")
|
113
|
-
end
|
114
|
-
|
115
|
-
# Returns a sanitized String URL, stripping "../../" and multiples of "/",
|
116
|
-
# as well as the beginning "/" so we can enforce and ensure it.
|
117
|
-
|
118
|
-
def sanitize_url(str)
|
119
|
-
"/#{str}".gsub("..", "/").gsub("./", "").squeeze("/")
|
120
|
-
end
|
121
|
-
|
122
|
-
# Escapes a path to be a valid URL path segment
|
123
|
-
#
|
124
|
-
# path - The path to be escaped.
|
125
|
-
#
|
126
|
-
# Examples:
|
127
|
-
#
|
128
|
-
# URL.escape_path("/a b")
|
129
|
-
# # => "/a%20b"
|
130
|
-
#
|
131
|
-
# Returns the escaped path.
|
132
|
-
def self.escape_path(path)
|
133
|
-
path = path.to_s
|
134
|
-
return path if path.empty? || %r!^[a-zA-Z0-9./-]+$!.match?(path)
|
135
|
-
|
136
|
-
# Because URI.escape doesn't escape "?", "[" and "]" by default,
|
137
|
-
# specify unsafe string (except unreserved, sub-delims, ":", "@" and "/").
|
138
|
-
#
|
139
|
-
# URI path segment is defined in RFC 3986 as follows:
|
140
|
-
# segment = *pchar
|
141
|
-
# pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
142
|
-
# unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
143
|
-
# pct-encoded = "%" HEXDIG HEXDIG
|
144
|
-
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
145
|
-
# / "*" / "+" / "," / ";" / "="
|
146
|
-
Addressable::URI.encode(path).encode("utf-8").sub("#", "%23")
|
147
|
-
end
|
148
|
-
|
149
|
-
# Unescapes a URL path segment
|
150
|
-
#
|
151
|
-
# path - The path to be unescaped.
|
152
|
-
#
|
153
|
-
# Examples:
|
154
|
-
#
|
155
|
-
# URL.unescape_path("/a%20b")
|
156
|
-
# # => "/a b"
|
157
|
-
#
|
158
|
-
# Returns the unescaped path.
|
159
|
-
def self.unescape_path(path)
|
160
|
-
path = path.encode("utf-8")
|
161
|
-
return path unless path.include?("%")
|
162
|
-
|
163
|
-
Addressable::URI.unencode(path)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bridgetown
|
4
|
-
module Utils
|
5
|
-
module Ansi
|
6
|
-
extend self
|
7
|
-
|
8
|
-
ESCAPE = format("%c", 27)
|
9
|
-
MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix.freeze
|
10
|
-
COLORS = {
|
11
|
-
red: 31,
|
12
|
-
green: 32,
|
13
|
-
black: 30,
|
14
|
-
magenta: 35,
|
15
|
-
yellow: 33,
|
16
|
-
white: 37,
|
17
|
-
blue: 34,
|
18
|
-
cyan: 36,
|
19
|
-
}.freeze
|
20
|
-
|
21
|
-
# Strip ANSI from the current string. It also strips cursor stuff,
|
22
|
-
# well some of it, and it also strips some other stuff that a lot of
|
23
|
-
# the other ANSI strippers don't.
|
24
|
-
|
25
|
-
def strip(str)
|
26
|
-
str.gsub MATCH, ""
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
def has?(str)
|
32
|
-
!!(str =~ MATCH)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Reset the color back to the default color so that you do not leak any
|
36
|
-
# colors when you move onto the next line. This is probably normally
|
37
|
-
# used as part of a wrapper so that we don't leak colors.
|
38
|
-
|
39
|
-
def reset(str = "")
|
40
|
-
@ansi_reset ||= format("%c[0m", 27)
|
41
|
-
"#{@ansi_reset}#{str}"
|
42
|
-
end
|
43
|
-
|
44
|
-
# SEE: `self::COLORS` for a list of methods. They are mostly
|
45
|
-
# standard base colors supported by pretty much any xterm-color, we do
|
46
|
-
# not need more than the base colors so we do not include them.
|
47
|
-
# Actually... if I'm honest we don't even need most of the
|
48
|
-
# base colors.
|
49
|
-
|
50
|
-
COLORS.each do |color, num|
|
51
|
-
define_method color do |str|
|
52
|
-
"#{format("%c", 27)}[#{num}m#{str}#{reset}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Welcome to Bridgetown!
|
2
|
-
#
|
3
|
-
# This config file is for settings that affect your whole site, values
|
4
|
-
# which you are expected to set up once and rarely edit after that.
|
5
|
-
#
|
6
|
-
# A list of all available configuration options can be found here:
|
7
|
-
# https://www.bridgetownrb.com/docs/configuration/options
|
8
|
-
#
|
9
|
-
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
10
|
-
# `bin/bridgetown start`. If you change this file, please restart the server process.
|
11
|
-
#
|
12
|
-
# For reloadable site metadata like title, SEO description, social media
|
13
|
-
# handles, etc., take a look at `src/_data/site_metadata.yml`
|
14
|
-
#
|
15
|
-
# If you need help with YAML syntax, here are some quick references for you:
|
16
|
-
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
|
17
|
-
# https://learnxinyminutes.com/docs/yaml/
|
18
|
-
#
|
19
|
-
|
20
|
-
url: "" # the base hostname & protocol for your site, e.g. https://example.com
|
21
|
-
|
22
|
-
permalink: pretty
|
23
|
-
|
24
|
-
# Other options you might want to investigate:
|
25
|
-
#
|
26
|
-
# base_path: "/" # the subpath of your site, e.g. /blog. If you set this option,
|
27
|
-
# ensure you use the `relative_url` helper for all links and assets in your HTML.
|
28
|
-
# If you're using esbuild for frontend assets, edit `esbuild.config.js` to
|
29
|
-
# update `publicPath`.
|
30
|
-
|
31
|
-
# timezone: America/Los_Angeles
|
32
|
-
# pagination:
|
33
|
-
# enabled: true
|