utopia 3.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0a73ea69813127b09be72632c42f1ce6a6a4e94678c823575125223ae19b520
4
- data.tar.gz: 8c50126b47f9184bce9237dade14818cf70d959f0aae2fb34f8fb486a22a0d0d
3
+ metadata.gz: b209f640f2956c9d656cbac537793f828bb7dd398b9e7a2df41f3591aedd2aa6
4
+ data.tar.gz: 3d4ad85f0e311e7ec907e51bc837fad936658648f718986d2049c05b8e9391a3
5
5
  SHA512:
6
- metadata.gz: 12bf144743c5b6cae0f147e60d37815c081025a86c6ac7c4146fbb392087819ddafa80c431579855ddd1e7b565fbc24a00902df3bc56222e6d218e48e5eade98
7
- data.tar.gz: 76d0216724af21e389d71b6236ab36ebf5810f6365a536f000e6601d83c8df03a451a9e5eecc2cdcb045c8c1b206018a02a4762433e2e6b227a1508dd6df34f2
6
+ metadata.gz: 93c77c5abbef5ed5436b00220acdaeec1a774d23ea6e3418ebe0c29b5511b7da4439902bccbc264c4111ba5f5bb529e30e0215a93bc94cd6607f4ee89445ec2e
7
+ data.tar.gz: 59463ee050dec081e27b81829c79515e3845a7f15cab56cfbca7763a317ce11a864f4b019dca9ac276f95068ed7f5bb2ab21ad7923a5c40535faf79c033639ff
checksums.yaml.gz.sig CHANGED
Binary file
@@ -39,3 +39,9 @@ In order to render this, you will need two additional files, `_page.xnode` and `
39
39
  ```
40
40
 
41
41
  When the parser encounters `<content:heading>...` in the main page, it would evaluate the above template. `<utopia:content/>` is a special tag that evaluates to the content that the parent tag provided, so in this case: `"Welcome to my page"`. Thus, the final output is `<h1>Welcome to my page</h1>`.
42
+
43
+ ## Relative Content
44
+
45
+ By default, `<content:...>` tags resolve relative to the physical location of the template which contains them. This ensures that a shared template uses its own related content templates consistently.
46
+
47
+ Use the `<relative:...>` namespace when a shared template should instead allow content to be overridden relative to the node being rendered. For example, a root `_page.xnode` can render `<relative:header/>`; when it wraps `blog/index.xnode`, Utopia first looks for `blog/_header.xnode` before falling back to `/_header.xnode`.
@@ -25,6 +25,7 @@ module Utopia
25
25
  include Localization::Resolver
26
26
 
27
27
  CONTENT_NAMESPACE = "content".freeze
28
+ RELATIVE_NAMESPACE = "relative".freeze
28
29
  UTOPIA_NAMESPACE = "utopia".freeze
29
30
  CONTENT_TAG_NAME = "utopia:content".freeze
30
31
 
@@ -45,6 +46,9 @@ module Utopia
45
46
  # Default content namespace for dynamic path based lookup:
46
47
  @namespaces[CONTENT_NAMESPACE] ||= self.method(:content_tag)
47
48
 
49
+ # Resolve content relative to the logical invocation path:
50
+ @namespaces[RELATIVE_NAMESPACE] ||= self.method(:relative_tag)
51
+
48
52
  # The core namespace for utopia specific functionality:
49
53
  @namespaces[UTOPIA_NAMESPACE] ||= Tags
50
54
  end
@@ -190,8 +194,8 @@ module Utopia
190
194
  return nil
191
195
  end
192
196
 
193
- def content_tag(name, node)
194
- full_path = node.parent_path + name
197
+ def content_tag(name, node, parent_path: node.parent_path)
198
+ full_path = parent_path + name
195
199
 
196
200
  name = full_path.pop
197
201
 
@@ -206,6 +210,10 @@ module Utopia
206
210
  lookup_content(name, full_path)
207
211
  end
208
212
  end
213
+
214
+ def relative_tag(name, node)
215
+ content_tag(name, node, parent_path: node.request_path.dirname)
216
+ end
209
217
  end
210
218
 
211
219
  Traces::Provider(Middleware) do
@@ -16,8 +16,11 @@ module Utopia
16
16
  :media => [
17
17
  :xiph, "mp3", "mp4", "wav", "aiff", "aac", "webm", "weba", "mov", "avi", "wmv", "mpg", "m3u8", "ts"
18
18
  ],
19
+ :scripts => [
20
+ "js", "mjs", "wasm"
21
+ ],
19
22
  :text => [
20
- "html", "css", "js", "map", "txt", "rtf", "xml", "pdf"
23
+ "html", "css", "map", "txt", "rtf", "xml", "pdf"
21
24
  ],
22
25
  :fonts => [
23
26
  "otf", "eot", "ttf", "woff", "woff2"
@@ -29,7 +32,7 @@ module Utopia
29
32
  "png", "gif", "jpeg", "tiff", "svg", "webp"
30
33
  ],
31
34
  :default => [
32
- :media, :text, :archive, :images, :fonts
35
+ :media, :scripts, :text, :archive, :images, :fonts
33
36
  ]
34
37
  }
35
38
 
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Utopia
8
- VERSION = "3.0.0"
8
+ VERSION = "3.0.2"
9
9
  end
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: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file