utopia 2.32.0 → 3.0.0
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
- checksums.yaml.gz.sig +0 -0
- data/bake/utopia/environment.rb +6 -6
- data/bake/utopia/server.rb +4 -1
- data/bake/utopia/site.rb +14 -14
- data/bake/utopia/static.rb +26 -13
- data/bake/utopia.rb +1 -1
- data/context/getting-started.md +7 -5
- data/context/index.yaml +1 -2
- data/context/middleware.md +42 -13
- data/lib/utopia/application.rb +83 -0
- data/lib/utopia/content/builder.rb +25 -0
- data/lib/utopia/content/document.rb +64 -6
- data/lib/utopia/content/link.rb +50 -5
- data/lib/utopia/content/links.rb +44 -7
- data/lib/utopia/content/markup.rb +74 -0
- data/lib/utopia/content/middleware.rb +48 -20
- data/lib/utopia/content/namespace.rb +10 -1
- data/lib/utopia/content/node.rb +66 -4
- data/lib/utopia/content/response.rb +12 -3
- data/lib/utopia/content.rb +3 -0
- data/lib/utopia/controller/actions.md +4 -4
- data/lib/utopia/controller/actions.rb +51 -3
- data/lib/utopia/controller/base.rb +72 -29
- data/lib/utopia/controller/middleware.rb +20 -15
- data/lib/utopia/controller/respond.rb +36 -32
- data/lib/utopia/controller/responder.rb +106 -45
- data/lib/utopia/controller/result.rb +11 -0
- data/lib/utopia/controller/rewrite.rb +39 -0
- data/lib/utopia/controller/variables.rb +15 -3
- data/lib/utopia/controller.rb +2 -0
- data/lib/utopia/exceptions/handler.rb +20 -11
- data/lib/utopia/exceptions/mailer.rb +56 -51
- data/lib/utopia/extensions/array_split.rb +6 -0
- data/lib/utopia/extensions/date_comparisons.rb +6 -0
- data/lib/utopia/http.rb +11 -48
- data/lib/utopia/import_map.rb +19 -11
- data/lib/utopia/localization/locales.rb +60 -0
- data/lib/utopia/localization/middleware.rb +107 -73
- data/lib/utopia/localization/preferences.rb +76 -0
- data/lib/utopia/localization/resolver.rb +47 -0
- data/lib/utopia/localization.rb +6 -0
- data/lib/utopia/middleware.rb +3 -4
- data/lib/utopia/path/matcher.rb +15 -0
- data/lib/utopia/path.rb +146 -10
- data/lib/utopia/redirection/client_redirect.rb +87 -0
- data/lib/utopia/redirection/directory_index.rb +41 -0
- data/lib/utopia/redirection/errors.rb +78 -0
- data/lib/utopia/redirection/moved.rb +52 -0
- data/lib/utopia/redirection/request_failure.rb +26 -0
- data/lib/utopia/redirection/rewrite.rb +42 -0
- data/lib/utopia/redirection.rb +7 -165
- data/lib/utopia/request.rb +202 -0
- data/lib/utopia/response.rb +73 -0
- data/lib/utopia/session/lazy_hash.rb +27 -1
- data/lib/utopia/session/middleware.rb +103 -30
- data/lib/utopia/session/serialization.rb +8 -0
- data/lib/utopia/session.rb +5 -0
- data/lib/utopia/setup.rb +23 -3
- data/lib/utopia/shell.rb +28 -7
- data/lib/utopia/static/local_file.rb +84 -61
- data/lib/utopia/static/middleware.rb +65 -33
- data/lib/utopia/static/mime_types.rb +38 -29
- data/lib/utopia/static.rb +2 -0
- data/lib/utopia/version.rb +3 -2
- data/lib/utopia.rb +1 -1
- data/license.md +1 -1
- data/readme.md +33 -4
- data/releases.md +15 -0
- data/setup/site/bake.rb +1 -1
- data/setup/site/config/application.rb +51 -0
- data/setup/site/config/serve.rb +8 -0
- data/setup/site/falcon.rb +17 -4
- data/setup/site/fixtures/website.rb +27 -11
- data/setup/site/gems.rb +1 -3
- data/setup/site/lib/readme.txt +1 -1
- data/setup/site/pages/welcome/index.xnode +3 -3
- data/setup/site/readme.md +0 -3
- data/setup/site/test/website.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +60 -34
- metadata.gz.sig +0 -0
- data/lib/utopia/localization/wrapper.rb +0 -52
- data/setup/site/Guardfile +0 -12
- data/setup/site/config.ru +0 -49
data/setup/site/test/website.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2016-
|
|
4
|
+
# Copyright, 2016-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
require "website"
|
|
7
7
|
require "benchmark/http"
|
|
@@ -16,7 +16,7 @@ describe "website" do
|
|
|
16
16
|
it "should be responsive" do
|
|
17
17
|
spider.fetch(statistics, client, endpoint.url) do |method, uri, response|
|
|
18
18
|
if response.failure?
|
|
19
|
-
Console.error(endpoint)
|
|
19
|
+
Console.error(endpoint){"#{method} #{uri} -> #{response.status}"}
|
|
20
20
|
end
|
|
21
21
|
end.wait
|
|
22
22
|
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utopia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -86,21 +86,35 @@ dependencies:
|
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
87
|
version: '1.24'
|
|
88
88
|
- !ruby/object:Gem::Dependency
|
|
89
|
-
name:
|
|
89
|
+
name: irb
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
type: :runtime
|
|
96
|
+
prerelease: false
|
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: mail
|
|
90
104
|
requirement: !ruby/object:Gem::Requirement
|
|
91
105
|
requirements:
|
|
92
106
|
- - "~>"
|
|
93
107
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '2.
|
|
108
|
+
version: '2.6'
|
|
95
109
|
type: :runtime
|
|
96
110
|
prerelease: false
|
|
97
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
112
|
requirements:
|
|
99
113
|
- - "~>"
|
|
100
114
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '2.
|
|
115
|
+
version: '2.6'
|
|
102
116
|
- !ruby/object:Gem::Dependency
|
|
103
|
-
name:
|
|
117
|
+
name: msgpack
|
|
104
118
|
requirement: !ruby/object:Gem::Requirement
|
|
105
119
|
requirements:
|
|
106
120
|
- - ">="
|
|
@@ -114,89 +128,89 @@ dependencies:
|
|
|
114
128
|
- !ruby/object:Gem::Version
|
|
115
129
|
version: '0'
|
|
116
130
|
- !ruby/object:Gem::Dependency
|
|
117
|
-
name:
|
|
131
|
+
name: net-smtp
|
|
118
132
|
requirement: !ruby/object:Gem::Requirement
|
|
119
133
|
requirements:
|
|
120
|
-
- - "
|
|
134
|
+
- - ">="
|
|
121
135
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: '
|
|
136
|
+
version: '0'
|
|
123
137
|
type: :runtime
|
|
124
138
|
prerelease: false
|
|
125
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
126
140
|
requirements:
|
|
127
|
-
- - "
|
|
141
|
+
- - ">="
|
|
128
142
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '
|
|
143
|
+
version: '0'
|
|
130
144
|
- !ruby/object:Gem::Dependency
|
|
131
|
-
name:
|
|
145
|
+
name: protocol-content
|
|
132
146
|
requirement: !ruby/object:Gem::Requirement
|
|
133
147
|
requirements:
|
|
134
148
|
- - "~>"
|
|
135
149
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '
|
|
150
|
+
version: '0.1'
|
|
137
151
|
type: :runtime
|
|
138
152
|
prerelease: false
|
|
139
153
|
version_requirements: !ruby/object:Gem::Requirement
|
|
140
154
|
requirements:
|
|
141
155
|
- - "~>"
|
|
142
156
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: '
|
|
157
|
+
version: '0.1'
|
|
144
158
|
- !ruby/object:Gem::Dependency
|
|
145
|
-
name:
|
|
159
|
+
name: protocol-http
|
|
146
160
|
requirement: !ruby/object:Gem::Requirement
|
|
147
161
|
requirements:
|
|
148
|
-
- - "
|
|
162
|
+
- - "~>"
|
|
149
163
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '0'
|
|
164
|
+
version: '0.70'
|
|
151
165
|
type: :runtime
|
|
152
166
|
prerelease: false
|
|
153
167
|
version_requirements: !ruby/object:Gem::Requirement
|
|
154
168
|
requirements:
|
|
155
|
-
- - "
|
|
169
|
+
- - "~>"
|
|
156
170
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: '0'
|
|
171
|
+
version: '0.70'
|
|
158
172
|
- !ruby/object:Gem::Dependency
|
|
159
|
-
name:
|
|
173
|
+
name: protocol-media
|
|
160
174
|
requirement: !ruby/object:Gem::Requirement
|
|
161
175
|
requirements:
|
|
162
|
-
- - "
|
|
176
|
+
- - "~>"
|
|
163
177
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '0'
|
|
178
|
+
version: '0.3'
|
|
165
179
|
type: :runtime
|
|
166
180
|
prerelease: false
|
|
167
181
|
version_requirements: !ruby/object:Gem::Requirement
|
|
168
182
|
requirements:
|
|
169
|
-
- - "
|
|
183
|
+
- - "~>"
|
|
170
184
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '0'
|
|
185
|
+
version: '0.3'
|
|
172
186
|
- !ruby/object:Gem::Dependency
|
|
173
|
-
name: protocol-
|
|
187
|
+
name: protocol-media-registry
|
|
174
188
|
requirement: !ruby/object:Gem::Requirement
|
|
175
189
|
requirements:
|
|
176
190
|
- - "~>"
|
|
177
191
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: '0.
|
|
192
|
+
version: '0.1'
|
|
179
193
|
type: :runtime
|
|
180
194
|
prerelease: false
|
|
181
195
|
version_requirements: !ruby/object:Gem::Requirement
|
|
182
196
|
requirements:
|
|
183
197
|
- - "~>"
|
|
184
198
|
- !ruby/object:Gem::Version
|
|
185
|
-
version: '0.
|
|
199
|
+
version: '0.1'
|
|
186
200
|
- !ruby/object:Gem::Dependency
|
|
187
|
-
name:
|
|
201
|
+
name: protocol-url
|
|
188
202
|
requirement: !ruby/object:Gem::Requirement
|
|
189
203
|
requirements:
|
|
190
204
|
- - "~>"
|
|
191
205
|
- !ruby/object:Gem::Version
|
|
192
|
-
version: '
|
|
206
|
+
version: '0.16'
|
|
193
207
|
type: :runtime
|
|
194
208
|
prerelease: false
|
|
195
209
|
version_requirements: !ruby/object:Gem::Requirement
|
|
196
210
|
requirements:
|
|
197
211
|
- - "~>"
|
|
198
212
|
- !ruby/object:Gem::Version
|
|
199
|
-
version: '
|
|
213
|
+
version: '0.16'
|
|
200
214
|
- !ruby/object:Gem::Dependency
|
|
201
215
|
name: samovar
|
|
202
216
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -272,6 +286,7 @@ files:
|
|
|
272
286
|
- context/updating-utopia.md
|
|
273
287
|
- context/what-is-xnode.md
|
|
274
288
|
- lib/utopia.rb
|
|
289
|
+
- lib/utopia/application.rb
|
|
275
290
|
- lib/utopia/content.rb
|
|
276
291
|
- lib/utopia/content/builder.rb
|
|
277
292
|
- lib/utopia/content/document.rb
|
|
@@ -290,6 +305,7 @@ files:
|
|
|
290
305
|
- lib/utopia/controller/middleware.rb
|
|
291
306
|
- lib/utopia/controller/respond.rb
|
|
292
307
|
- lib/utopia/controller/responder.rb
|
|
308
|
+
- lib/utopia/controller/result.rb
|
|
293
309
|
- lib/utopia/controller/rewrite.md
|
|
294
310
|
- lib/utopia/controller/rewrite.rb
|
|
295
311
|
- lib/utopia/controller/variables.rb
|
|
@@ -301,12 +317,22 @@ files:
|
|
|
301
317
|
- lib/utopia/http.rb
|
|
302
318
|
- lib/utopia/import_map.rb
|
|
303
319
|
- lib/utopia/localization.rb
|
|
320
|
+
- lib/utopia/localization/locales.rb
|
|
304
321
|
- lib/utopia/localization/middleware.rb
|
|
305
|
-
- lib/utopia/localization/
|
|
322
|
+
- lib/utopia/localization/preferences.rb
|
|
323
|
+
- lib/utopia/localization/resolver.rb
|
|
306
324
|
- lib/utopia/middleware.rb
|
|
307
325
|
- lib/utopia/path.rb
|
|
308
326
|
- lib/utopia/path/matcher.rb
|
|
309
327
|
- lib/utopia/redirection.rb
|
|
328
|
+
- lib/utopia/redirection/client_redirect.rb
|
|
329
|
+
- lib/utopia/redirection/directory_index.rb
|
|
330
|
+
- lib/utopia/redirection/errors.rb
|
|
331
|
+
- lib/utopia/redirection/moved.rb
|
|
332
|
+
- lib/utopia/redirection/request_failure.rb
|
|
333
|
+
- lib/utopia/redirection/rewrite.rb
|
|
334
|
+
- lib/utopia/request.rb
|
|
335
|
+
- lib/utopia/response.rb
|
|
310
336
|
- lib/utopia/session.rb
|
|
311
337
|
- lib/utopia/session/lazy_hash.rb
|
|
312
338
|
- lib/utopia/session/middleware.rb
|
|
@@ -323,11 +349,11 @@ files:
|
|
|
323
349
|
- releases.md
|
|
324
350
|
- setup/server/git/hooks/post-receive
|
|
325
351
|
- setup/site/.gitignore
|
|
326
|
-
- setup/site/Guardfile
|
|
327
352
|
- setup/site/bake.rb
|
|
328
|
-
- setup/site/config.
|
|
353
|
+
- setup/site/config/application.rb
|
|
329
354
|
- setup/site/config/environment.rb
|
|
330
355
|
- setup/site/config/readme.md
|
|
356
|
+
- setup/site/config/serve.rb
|
|
331
357
|
- setup/site/config/sus.rb
|
|
332
358
|
- setup/site/falcon.rb
|
|
333
359
|
- setup/site/fixtures/website.rb
|
|
@@ -360,14 +386,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
360
386
|
requirements:
|
|
361
387
|
- - ">="
|
|
362
388
|
- !ruby/object:Gem::Version
|
|
363
|
-
version: '3.
|
|
389
|
+
version: '3.3'
|
|
364
390
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
365
391
|
requirements:
|
|
366
392
|
- - ">="
|
|
367
393
|
- !ruby/object:Gem::Version
|
|
368
394
|
version: '0'
|
|
369
395
|
requirements: []
|
|
370
|
-
rubygems_version:
|
|
396
|
+
rubygems_version: 4.0.10
|
|
371
397
|
specification_version: 4
|
|
372
398
|
summary: Utopia is a framework for building dynamic content-driven websites.
|
|
373
399
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2009-2025, by Samuel Williams.
|
|
5
|
-
|
|
6
|
-
require_relative "middleware"
|
|
7
|
-
|
|
8
|
-
module Utopia
|
|
9
|
-
# A middleware which attempts to find localized content.
|
|
10
|
-
module Localization
|
|
11
|
-
LOCALIZATION_KEY = "utopia.localization".freeze
|
|
12
|
-
CURRENT_LOCALE_KEY = "utopia.localization.current_locale".freeze
|
|
13
|
-
|
|
14
|
-
# A wrapper to provide easy access to locale related data in the request.
|
|
15
|
-
class Wrapper
|
|
16
|
-
def initialize(env)
|
|
17
|
-
@env = env
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def localization
|
|
21
|
-
@env[LOCALIZATION_KEY]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def localized?
|
|
25
|
-
localization != nil
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Returns the current locale or nil if not localized.
|
|
29
|
-
def current_locale
|
|
30
|
-
@env[CURRENT_LOCALE_KEY]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Returns the default locale or nil if not localized.
|
|
34
|
-
def default_locale
|
|
35
|
-
localization && localization.default_locale
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Returns an empty array if not localized.
|
|
39
|
-
def all_locales
|
|
40
|
-
localization && localization.all_locales || []
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def localized_path(path, locale)
|
|
44
|
-
"/#{locale}#{path}"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.[] request
|
|
49
|
-
Wrapper.new(request.env)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
data/setup/site/Guardfile
DELETED
data/setup/site/config.ru
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env rackup
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "config/environment"
|
|
5
|
-
|
|
6
|
-
self.freeze_app
|
|
7
|
-
|
|
8
|
-
if UTOPIA.production?
|
|
9
|
-
# Handle exceptions in production with a error page and send an email notification:
|
|
10
|
-
use Utopia::Exceptions::Handler
|
|
11
|
-
use Utopia::Exceptions::Mailer
|
|
12
|
-
else
|
|
13
|
-
# We want to propate exceptions up when running tests:
|
|
14
|
-
use Rack::ShowExceptions unless UTOPIA.testing?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Serve static files from "public" directory:
|
|
18
|
-
use Utopia::Static, root: "public"
|
|
19
|
-
|
|
20
|
-
use Utopia::Redirection::Rewrite, {
|
|
21
|
-
"/" => "/welcome/index"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
use Utopia::Redirection::DirectoryIndex
|
|
25
|
-
|
|
26
|
-
use Utopia::Redirection::Errors, {
|
|
27
|
-
404 => "/errors/file-not-found"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
require "utopia/localization"
|
|
31
|
-
use Utopia::Localization,
|
|
32
|
-
default_locale: "en",
|
|
33
|
-
locales: ["en", "de", "ja", "zh"]
|
|
34
|
-
|
|
35
|
-
require "utopia/session"
|
|
36
|
-
use Utopia::Session,
|
|
37
|
-
expires_after: 3600 * 24,
|
|
38
|
-
secret: UTOPIA.secret_for(:session),
|
|
39
|
-
secure: true
|
|
40
|
-
|
|
41
|
-
use Utopia::Controller
|
|
42
|
-
|
|
43
|
-
# Serve static files from "pages" directory:
|
|
44
|
-
use Utopia::Static
|
|
45
|
-
|
|
46
|
-
# Serve dynamic content:
|
|
47
|
-
use Utopia::Content
|
|
48
|
-
|
|
49
|
-
run lambda {|env| [404, {}, []]}
|