utopia 2.19.1 → 2.20.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df0d36fb6627871090306a7049fcbd487139fa7e30c861c6c2abf270a3ad07ec
4
- data.tar.gz: d6b3592a95d1652a9069d5841a5aa9ff7bf43d73c1a171b9be212602f888989c
3
+ metadata.gz: 98a414341752cd45376ffac50a8ebd4b5e3ee49eb2868ce87dc41f3696c07d76
4
+ data.tar.gz: 989e031a0c3f3680d52f28540f94712f32e00cb95af7c5575a81ef7f7b8ed6d6
5
5
  SHA512:
6
- metadata.gz: 00e3a8f9df669e72d419c490fd86f255981a3e05ab05a0f740d468e306494879c4e78449332b0c88151a64e2296a0968e117b8965e556c6225ec95f5795cd261
7
- data.tar.gz: 9764e94964545f5b8bdd6f99763872d0391d71eef1327e3121c045e555f2a1b3821641640037d6d77c934f2f5145b9aa40e515096a9694d7c3698aa7044b45b5
6
+ metadata.gz: 5d8ff1cf0d72eabbef7550ef1c049f6af84c9cd110403cff6999c506ac8200697fa8930cc2db29cc666b23dd13b144a81c45301d669c43bff618719254247293
7
+ data.tar.gz: dbd8e4c9379ad5d539a8e099402630a23b9c7a5422d369a2f5cdcea1426d07b1bffb2532b1694dad71b8966dcdb8a8084d4270af809ce3ef23e3b0dfddd48883
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ F�`%�|��p��/�`�>
2
+ "Z��i�Q!7���I��Q�GV�)D4Zvf���T��i&#�7�j��_gbV��x֜��_���&"9о�fP���@\�'8�@���g<P�"�����b 1�Y<��
3
+ �fm7����f�cA�<�ֻ��Z��G?���pI�?�Q*4�"�gfM�Ṇ�JK7%w�Q�U9�8P9�0��{_trg;`zޘ��@(�D-ķƔw�d�w�x��?ɒ�}9f�0�^pt
@@ -43,10 +43,12 @@ module Utopia
43
43
  end
44
44
 
45
45
  def key
46
- if locale
47
- "#{@path.last}.#{@locale}"
48
- else
49
- @path.last
46
+ if @path
47
+ if locale
48
+ "#{@path.last}.#{@locale}"
49
+ else
50
+ @path.last
51
+ end
50
52
  end
51
53
  end
52
54
 
@@ -32,6 +32,8 @@ require 'trenni/template'
32
32
 
33
33
  require 'concurrent/map'
34
34
 
35
+ require 'traces/provider'
36
+
35
37
  module Utopia
36
38
  # A middleware which serves dynamically generated content based on markup files.
37
39
  class Content
@@ -107,6 +109,16 @@ module Utopia
107
109
  end
108
110
  end
109
111
 
112
+ def respond(link, request)
113
+ if node = resolve_link(link)
114
+ attributes = request.env.fetch(VARIABLES_KEY, {}).to_hash
115
+
116
+ return node.process!(request, attributes)
117
+ elsif redirect_uri = link[:uri]
118
+ return [307, {HTTP::LOCATION => redirect_uri}, []]
119
+ end
120
+ end
121
+
110
122
  def call(env)
111
123
  request = Rack::Request.new(env)
112
124
  path = Path.create(request.path_info)
@@ -124,12 +136,8 @@ module Utopia
124
136
 
125
137
  locale = env[Localization::CURRENT_LOCALE_KEY]
126
138
  if link = @links.for(path, locale)
127
- if node = resolve_link(link)
128
- attributes = request.env.fetch(VARIABLES_KEY, {}).to_hash
129
-
130
- return node.process!(request, attributes)
131
- elsif redirect_uri = link[:uri]
132
- return [307, {HTTP::LOCATION => redirect_uri}, []]
139
+ if response = self.respond(link, request)
140
+ return response
133
141
  end
134
142
  end
135
143
 
@@ -191,4 +199,15 @@ module Utopia
191
199
  end
192
200
  end
193
201
  end
202
+
203
+ Traces::Provider(Content) do
204
+ def respond(link, request)
205
+ attributes = {
206
+ 'link.key' => link.key,
207
+ 'link.href' => link.href
208
+ }
209
+
210
+ trace("utopia.content.respond", attributes: attributes) {super}
211
+ end
212
+ end
194
213
  end
@@ -219,6 +219,8 @@ module Utopia
219
219
  response = @app.call(localized_env)
220
220
 
221
221
  break unless response[0] >= 400
222
+
223
+ response[2].close if response[2].respond_to?(:close)
222
224
  end
223
225
 
224
226
  return vary(env, response)
@@ -52,7 +52,7 @@ module Utopia
52
52
  ["torrent", "application/x-bittorrent"]
53
53
  ],
54
54
  :images => [
55
- "png", "gif", "jpeg", "tiff", "svg"
55
+ "png", "gif", "jpeg", "tiff", "svg", "webp"
56
56
  ],
57
57
  :default => [
58
58
  :media, :text, :archive, :images, :fonts
data/lib/utopia/static.rb CHANGED
@@ -26,6 +26,8 @@ require_relative 'localization'
26
26
  require_relative 'static/local_file'
27
27
  require_relative 'static/mime_types'
28
28
 
29
+ require 'traces/provider'
30
+
29
31
  module Utopia
30
32
  # A middleware which serves static files from the specified root directory.
31
33
  class Static
@@ -72,36 +74,52 @@ module Utopia
72
74
  ETAG = 'ETag'.freeze
73
75
  ACCEPT_RANGES = 'Accept-Ranges'.freeze
74
76
 
77
+ def respond(env, path_info, extension)
78
+ path = Path[path_info].simplify
79
+
80
+ if locale = env[Localization::CURRENT_LOCALE_KEY]
81
+ path.last.insert(path.last.rindex('.') || -1, ".#{locale}")
82
+ end
83
+
84
+ if file = fetch_file(path)
85
+ response_headers = {
86
+ LAST_MODIFIED => file.mtime_date,
87
+ CONTENT_TYPE => @extensions[extension],
88
+ CACHE_CONTROL => @cache_control,
89
+ ETAG => file.etag,
90
+ ACCEPT_RANGES => "bytes"
91
+ }
92
+
93
+ if file.modified?(env)
94
+ return file.serve(env, response_headers)
95
+ else
96
+ return [304, response_headers, []]
97
+ end
98
+ end
99
+ end
100
+
75
101
  def call(env)
76
102
  path_info = env[Rack::PATH_INFO]
77
103
  extension = File.extname(path_info)
78
-
79
- if @extensions.key? extension.downcase
80
- path = Path[path_info].simplify
81
-
82
- if locale = env[Localization::CURRENT_LOCALE_KEY]
83
- path.last.insert(path.last.rindex('.') || -1, ".#{locale}")
84
- end
85
-
86
- if file = fetch_file(path)
87
- response_headers = {
88
- LAST_MODIFIED => file.mtime_date,
89
- CONTENT_TYPE => @extensions[extension],
90
- CACHE_CONTROL => @cache_control,
91
- ETAG => file.etag,
92
- ACCEPT_RANGES => "bytes"
93
- }
94
-
95
- if file.modified?(env)
96
- return file.serve(env, response_headers)
97
- else
98
- return [304, response_headers, []]
99
- end
104
+
105
+ if @extensions.key?(extension.downcase)
106
+ if response = self.respond(env, path_info, extension)
107
+ return response
100
108
  end
101
109
  end
102
-
110
+
103
111
  # else if no file was found:
104
112
  return @app.call(env)
105
113
  end
106
114
  end
115
+
116
+ Traces::Provider(Static) do
117
+ def respond(env, path_info, extension)
118
+ attributes = {
119
+ path_info: path_info,
120
+ }
121
+
122
+ trace("utopia.static.respond", attributes: attributes) {super}
123
+ end
124
+ end
107
125
  end
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Utopia
24
- VERSION = "2.19.1"
24
+ VERSION = "2.20.1"
25
25
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative 'website_context'
4
4
 
5
- # Learn about best practice specs from http://betterspecs.org
6
5
  RSpec.describe "website", timeout: 120 do
7
6
  include_context "server"
8
7
 
@@ -13,7 +12,7 @@ RSpec.describe "website", timeout: 120 do
13
12
  Async::HTTP::Client.open(endpoint, connection_limit: 8) do |client|
14
13
  spider.fetch(statistics, client, endpoint.url) do |method, uri, response|
15
14
  if response.failure?
16
- Async.logger.error{"#{method} #{uri} -> #{response.status}"}
15
+ Console.logger.error(endpoint) {"#{method} #{uri} -> #{response.status}"}
17
16
  end
18
17
  end.wait
19
18
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.1
4
+ version: 2.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Huba Nagy
9
+ - Michael Adams
10
+ - Olle Jonsson
11
+ - System Administrator
12
+ - k1tsu
8
13
  autorequire:
9
14
  bindir: bin
10
- cert_chain: []
11
- date: 2021-12-25 00:00:00.000000000 Z
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsF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4IBgQBVoM+pu3dpdUhZM1w051iw5GfiqclAr1Psypf16Tiod/ho//4oAu6T
35
+ 9fj3DPX/acWV9P/FScvqo4Qgv6g4VWO5ZU7z2JmPoTXZtYMunRAmQPFL/gSUc6aK
36
+ vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
37
+ x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
38
+ bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
39
+ Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
40
+ y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
41
+ RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
42
+ HiLJ8VOFx6w=
43
+ -----END CERTIFICATE-----
44
+ date: 2022-08-03 00:00:00.000000000 Z
12
45
  dependencies:
13
46
  - !ruby/object:Gem::Dependency
14
47
  name: concurrent-ruby
@@ -112,14 +145,14 @@ dependencies:
112
145
  name: rack
113
146
  requirement: !ruby/object:Gem::Requirement
114
147
  requirements:
115
- - - "~>"
148
+ - - ">="
116
149
  - !ruby/object:Gem::Version
117
150
  version: '2.2'
118
151
  type: :runtime
119
152
  prerelease: false
120
153
  version_requirements: !ruby/object:Gem::Requirement
121
154
  requirements:
122
- - - "~>"
155
+ - - ">="
123
156
  - !ruby/object:Gem::Version
124
157
  version: '2.2'
125
158
  - !ruby/object:Gem::Dependency
@@ -136,6 +169,20 @@ dependencies:
136
169
  - - "~>"
137
170
  - !ruby/object:Gem::Version
138
171
  version: '2.1'
172
+ - !ruby/object:Gem::Dependency
173
+ name: traces
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ type: :runtime
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
139
186
  - !ruby/object:Gem::Dependency
140
187
  name: trenni
141
188
  requirement: !ruby/object:Gem::Requirement
@@ -367,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
414
  - !ruby/object:Gem::Version
368
415
  version: '0'
369
416
  requirements: []
370
- rubygems_version: 3.3.3
417
+ rubygems_version: 3.3.7
371
418
  signing_key:
372
419
  specification_version: 4
373
420
  summary: Utopia is a framework for building dynamic content-driven websites.
metadata.gz.sig ADDED
Binary file