bridgetown-core 1.2.0.beta5 → 1.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +21 -23
- data/lib/bridgetown-core/collection.rb +1 -1
- data/lib/bridgetown-core/commands/new.rb +2 -0
- data/lib/bridgetown-core/commands/plugins.rb +19 -13
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +2 -2
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +6 -2
- data/lib/bridgetown-core/configuration.rb +1 -1
- data/lib/bridgetown-core/configurations/purgecss.rb +1 -1
- data/lib/bridgetown-core/errors.rb +10 -1
- data/lib/bridgetown-core/liquid_renderer/table.rb +3 -1
- data/lib/bridgetown-core/model/repo_origin.rb +2 -2
- data/lib/bridgetown-core/rack/boot.rb +13 -1
- data/lib/bridgetown-core/rack/routes.rb +40 -6
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/utils/loaders_manager.rb +4 -0
- data/lib/bridgetown-core/utils.rb +18 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +1 -1
- data/lib/bridgetown-core.rb +54 -0
- data/lib/roda/plugins/bridgetown_server.rb +140 -0
- data/lib/site_template/Gemfile.erb +6 -3
- data/lib/site_template/server/roda_app.rb +4 -2
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
- metadata +8 -39
- data/lib/bridgetown-core/commands/serve/servlet.rb +0 -68
- data/lib/bridgetown-core/commands/serve.rb +0 -253
- data/lib/bridgetown-core/rack/roda.rb +0 -157
- data/lib/roda/plugins/bridgetown_boot.rb +0 -25
@@ -1,157 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
unless Bridgetown::Current.preloaded_configuration
|
4
|
-
raise "You must supply a preloaded configuration before loading Bridgetown's Roda superclass"
|
5
|
-
end
|
6
|
-
|
7
|
-
module Bridgetown
|
8
|
-
module Rack
|
9
|
-
class Roda < ::Roda
|
10
|
-
class << self
|
11
|
-
def inherited(klass)
|
12
|
-
super
|
13
|
-
klass.plugin :initializers
|
14
|
-
end
|
15
|
-
|
16
|
-
# rubocop:disable Bridgetown/NoPutsAllowed
|
17
|
-
def print_routes
|
18
|
-
# TODO: this needs to be fully documented
|
19
|
-
routes = begin
|
20
|
-
JSON.parse(
|
21
|
-
File.read(
|
22
|
-
File.join(Bridgetown::Current.preloaded_configuration.root_dir, ".routes.json")
|
23
|
-
)
|
24
|
-
)
|
25
|
-
rescue StandardError
|
26
|
-
[]
|
27
|
-
end
|
28
|
-
puts
|
29
|
-
puts "Routes:"
|
30
|
-
puts "======="
|
31
|
-
if routes.blank?
|
32
|
-
puts "No routes found. Have you commented all of your routes?"
|
33
|
-
puts "Documentation: https://github.com/jeremyevans/roda-route_list#basic-usage-"
|
34
|
-
end
|
35
|
-
|
36
|
-
routes.each do |route|
|
37
|
-
puts [
|
38
|
-
route["methods"]&.join("|") || "GET",
|
39
|
-
route["path"],
|
40
|
-
route["file"] ? "\n File: #{route["file"]}" : nil,
|
41
|
-
].compact.join(" ")
|
42
|
-
end
|
43
|
-
puts
|
44
|
-
end
|
45
|
-
# rubocop:enable Bridgetown/NoPutsAllowed
|
46
|
-
end
|
47
|
-
|
48
|
-
SiteContext = Struct.new(:registers) # for use by Liquid-esque URL helpers
|
49
|
-
|
50
|
-
plugin :method_override
|
51
|
-
plugin :all_verbs
|
52
|
-
plugin :hooks
|
53
|
-
plugin :common_logger, Bridgetown::Rack::Logger.new($stdout), method: :info
|
54
|
-
plugin :json
|
55
|
-
plugin :json_parser
|
56
|
-
plugin :indifferent_params
|
57
|
-
plugin :cookies
|
58
|
-
plugin :streaming
|
59
|
-
plugin :bridgetown_boot
|
60
|
-
plugin :public, root: Bridgetown::Current.preloaded_configuration.destination
|
61
|
-
plugin :not_found do
|
62
|
-
output_folder = Bridgetown::Current.preloaded_configuration.destination
|
63
|
-
File.read(File.join(output_folder, "404.html"))
|
64
|
-
rescue Errno::ENOENT
|
65
|
-
"404 Not Found"
|
66
|
-
end
|
67
|
-
plugin :exception_page
|
68
|
-
plugin :error_handler do |e|
|
69
|
-
Bridgetown::Errors.print_build_error(
|
70
|
-
e, logger: Bridgetown::LogAdapter.new(self.class.opts[:common_logger])
|
71
|
-
)
|
72
|
-
next exception_page(e) if ENV.fetch("RACK_ENV", nil) == "development"
|
73
|
-
|
74
|
-
output_folder = Bridgetown::Current.preloaded_configuration.destination
|
75
|
-
File.read(File.join(output_folder, "500.html"))
|
76
|
-
rescue Errno::ENOENT
|
77
|
-
"500 Internal Server Error"
|
78
|
-
end
|
79
|
-
|
80
|
-
::Roda::RodaPlugins::ExceptionPage.class_eval do
|
81
|
-
def self.css
|
82
|
-
<<~CSS
|
83
|
-
html * { padding:0; margin:0; }
|
84
|
-
body * { padding:10px 20px; }
|
85
|
-
body * * { padding:0; }
|
86
|
-
body { font-family: -apple-system, sans-serif; font-size: 90%; }
|
87
|
-
body>div { border-bottom:1px solid #ddd; }
|
88
|
-
code { font-family: ui-monospace, monospace; }
|
89
|
-
h1 { font-weight: bold; margin-block-end: .8em; }
|
90
|
-
h2 { margin-block-end:.8em; }
|
91
|
-
h2 span { font-size:80%; color:#f7f7db; font-weight:normal; }
|
92
|
-
h3 { margin:1em 0 .5em 0; }
|
93
|
-
h4 { margin:0 0 .5em 0; font-weight: normal; }
|
94
|
-
table {
|
95
|
-
border:1px solid #ccc; border-collapse: collapse; background:white; }
|
96
|
-
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
|
97
|
-
thead th {
|
98
|
-
padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
|
99
|
-
font-weight:normal; font-size:11px; border:1px solid #ddd; }
|
100
|
-
tbody th { text-align:right; opacity: 0.7; padding-right:.5em; }
|
101
|
-
table.vars { margin:5px 0 2px 40px; }
|
102
|
-
table.vars td, table.req td { font-family: ui-monospace, monospace; }
|
103
|
-
table td.code { width:100%;}
|
104
|
-
table td.code div { overflow:hidden; }
|
105
|
-
table.source th { color:#666; }
|
106
|
-
table.source td {
|
107
|
-
font-family: ui-monospace, monospace; white-space:pre; border-bottom:1px solid #eee; }
|
108
|
-
ul.traceback { list-style-type:none; }
|
109
|
-
ul.traceback li.frame { margin-bottom:1em; }
|
110
|
-
div.context { margin: 10px 0; }
|
111
|
-
div.context ol {
|
112
|
-
padding-left:30px; margin:0 10px; list-style-position: inside; }
|
113
|
-
div.context ol li {
|
114
|
-
font-family: ui-monospace, monospace; white-space:pre; color:#666; cursor:pointer; }
|
115
|
-
div.context ol.context-line li { color:black; background-color:#f7f7db; }
|
116
|
-
div.context ol.context-line li span { float: right; }
|
117
|
-
div.commands { margin-left: 40px; }
|
118
|
-
div.commands a { color:black; text-decoration:none; }
|
119
|
-
#summary { background: #1D453C; color: white; }
|
120
|
-
#summary h2 { font-weight: normal; color: white; }
|
121
|
-
#summary ul#quicklinks { list-style-type: none; margin-bottom: 2em; }
|
122
|
-
#summary ul#quicklinks li { float: left; padding: 0 1em; }
|
123
|
-
#summary ul#quicklinks>li+li { border-left: 1px #666 solid; }
|
124
|
-
#summary a { color: #f47c3c; }
|
125
|
-
#explanation { background:#eee; }
|
126
|
-
#traceback { background: white; }
|
127
|
-
#requestinfo { background:#f6f6f6; padding-left:120px; }
|
128
|
-
#summary table { border:none; background:transparent; }
|
129
|
-
#requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
|
130
|
-
#requestinfo h3 { margin-bottom:-1em; }
|
131
|
-
.error { background: #ffc; }
|
132
|
-
.specific { color:#cc3300; font-weight:bold; }
|
133
|
-
CSS
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
before do
|
138
|
-
if self.class.opts[:bridgetown_site]
|
139
|
-
# The site had previously been initialized via the bridgetown_ssr plugin
|
140
|
-
Bridgetown::Current.sites[self.class.opts[:bridgetown_site].label] =
|
141
|
-
self.class.opts[:bridgetown_site]
|
142
|
-
@context ||= SiteContext.new({ site: self.class.opts[:bridgetown_site] })
|
143
|
-
end
|
144
|
-
Bridgetown::Current.preloaded_configuration ||=
|
145
|
-
self.class.opts[:bridgetown_preloaded_config]
|
146
|
-
|
147
|
-
request.root do
|
148
|
-
output_folder = Bridgetown::Current.preloaded_configuration.destination
|
149
|
-
File.read(File.join(output_folder, "index.html"))
|
150
|
-
rescue StandardError
|
151
|
-
response.status = 500
|
152
|
-
"<p>ERROR: cannot find <code>index.html</code> in the output folder.</p>"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Roda
|
4
|
-
module RodaPlugins
|
5
|
-
module BridgetownBoot
|
6
|
-
Roda::RodaRequest.alias_method :_previous_roda_cookies, :cookies
|
7
|
-
|
8
|
-
module RequestMethods
|
9
|
-
# Monkeypatch Roda/Rack's Request object so it returns a hash which allows for
|
10
|
-
# indifferent access
|
11
|
-
def cookies
|
12
|
-
# TODO: maybe replace with a simpler hash that offers an overloaded `[]` method
|
13
|
-
_previous_roda_cookies.with_indifferent_access
|
14
|
-
end
|
15
|
-
|
16
|
-
# Starts up the Bridgetown routing system
|
17
|
-
def bridgetown
|
18
|
-
Bridgetown::Rack::Routes.start!(scope)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
register_plugin :bridgetown_boot, BridgetownBoot
|
24
|
-
end
|
25
|
-
end
|