utopia 2.9.5 → 2.10.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
- data/lib/utopia/content/link.rb +9 -10
- data/lib/utopia/content/node.rb +8 -1
- data/lib/utopia/static/local_file.rb +1 -1
- data/lib/utopia/version.rb +1 -1
- data/spec/utopia/content/node_spec.rb +60 -32
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 473bc20c3cb5a2b2b0bc08830a5b34ac5519f60fbc97453292da59671a857c6f
|
4
|
+
data.tar.gz: 1c78fb9a0d685502b675ac1351eaa465c4140317ad0aa1fbd323632822b5d84f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2d06006aff49f81104a7fa0bf7b03167e1b92d3afe2412409032b22f652b3493a6fccef5b578aa7dcb9b14c10797248db6e5e5d24e088f122af7957bffe1a3
|
7
|
+
data.tar.gz: 001e36314faf87ab21c25b047d2ad532c7e96990d9f365fa4b407e04e2fe61cc2ffaa35c1ce883fa91501c6e192164d50223581ad52bec6b6fc58d5a6da490ce
|
data/lib/utopia/content/link.rb
CHANGED
@@ -94,21 +94,20 @@ module Utopia
|
|
94
94
|
@info.fetch(:title, @title)
|
95
95
|
end
|
96
96
|
|
97
|
-
def to_anchor(**
|
98
|
-
|
97
|
+
def to_anchor(base: nil, content: self.title, builder: nil, **attributes)
|
98
|
+
attributes[:class] ||= 'link'
|
99
|
+
|
100
|
+
Trenni::Builder.fragment(builder) do |builder|
|
99
101
|
if href?
|
100
|
-
attributes
|
101
|
-
|
102
|
-
:href => relative_href(options[:base]),
|
103
|
-
:target => options.fetch(:target, @info[:target])
|
104
|
-
}
|
102
|
+
attributes[:href] ||= relative_href(base)
|
103
|
+
attributes[:target] ||= @info[:target]
|
105
104
|
|
106
105
|
builder.inline('a', attributes) do
|
107
|
-
builder.text(
|
106
|
+
builder.text(content)
|
108
107
|
end
|
109
108
|
else
|
110
|
-
builder.inline('span',
|
111
|
-
builder.text(
|
109
|
+
builder.inline('span', attributes) do
|
110
|
+
builder.text(content)
|
112
111
|
end
|
113
112
|
end
|
114
113
|
end
|
data/lib/utopia/content/node.rb
CHANGED
data/lib/utopia/version.rb
CHANGED
@@ -20,48 +20,76 @@
|
|
20
20
|
|
21
21
|
require 'utopia/content'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
RSpec.describe Utopia::Content::Node do
|
24
|
+
let(:root) {File.expand_path("node", __dir__)}
|
25
|
+
let(:content) {Utopia::Content.new(lambda{}, root: root)}
|
26
|
+
|
27
|
+
it "should list siblings in correct order" do
|
28
|
+
node = content.lookup_node(Utopia::Path['/ordered/first'])
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
links = node.sibling_links
|
31
|
+
|
32
|
+
expect(links.size).to be == 2
|
33
|
+
expect(links[0].name).to be == 'first'
|
34
|
+
expect(links[1].name).to be == 'second'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should list all links in correct order" do
|
38
|
+
node = content.lookup_node(Utopia::Path['/ordered/index'])
|
39
|
+
|
40
|
+
links = node.links
|
41
|
+
|
42
|
+
expect(links.size).to be == 2
|
43
|
+
expect(links[0].name).to be == 'first'
|
44
|
+
expect(links[1].name).to be == 'second'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should list related links" do
|
48
|
+
node = content.lookup_node(Utopia::Path['/related/foo.en'])
|
49
|
+
|
50
|
+
links = node.related_links
|
51
|
+
|
52
|
+
expect(links.size).to be == 2
|
53
|
+
expect(links[0].name).to be == 'foo'
|
54
|
+
expect(links[0].locale).to be == 'en'
|
37
55
|
|
38
|
-
|
56
|
+
expect(links[1].name).to be == 'foo'
|
57
|
+
expect(links[1].locale).to be == 'ja'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should look up node by path" do
|
61
|
+
node = content.lookup_node(Utopia::Path['/lookup/index'])
|
62
|
+
|
63
|
+
expect(node.process!(nil)).to be == [200, {"Content-Type"=>"text/html; charset=utf-8"}, ["<p>Hello World</p>"]]
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#local_path' do
|
67
|
+
let(:base) {Pathname.new(root)}
|
68
|
+
|
69
|
+
it "can compute relative path from index node" do
|
39
70
|
node = content.lookup_node(Utopia::Path['/ordered/index'])
|
40
71
|
|
41
|
-
|
42
|
-
|
43
|
-
expect(links.size).to be == 2
|
44
|
-
expect(links[0].name).to be == 'first'
|
45
|
-
expect(links[1].name).to be == 'second'
|
72
|
+
expect(node.local_path("preview.jpg")).to eq(base + 'ordered/preview.jpg')
|
46
73
|
end
|
47
74
|
|
48
|
-
it "
|
49
|
-
node = content.lookup_node(Utopia::Path['/
|
50
|
-
|
51
|
-
links = node.related_links
|
75
|
+
it "can compute relative path from named node" do
|
76
|
+
node = content.lookup_node(Utopia::Path['/ordered/first'])
|
52
77
|
|
53
|
-
expect(
|
54
|
-
|
55
|
-
|
78
|
+
expect(node.local_path("preview.jpg")).to eq(base + 'ordered/preview.jpg')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#relative_path' do
|
83
|
+
it "can compute relative path from index node" do
|
84
|
+
node = content.lookup_node(Utopia::Path['/ordered/index'])
|
56
85
|
|
57
|
-
expect(
|
58
|
-
expect(links[1].locale).to be == 'ja'
|
86
|
+
expect(node.relative_path("preview.jpg")).to eq(Utopia::Path['/ordered/preview.jpg'])
|
59
87
|
end
|
60
88
|
|
61
|
-
it "
|
62
|
-
node = content.lookup_node(Utopia::Path['/
|
89
|
+
it "can compute relative path from named node" do
|
90
|
+
node = content.lookup_node(Utopia::Path['/ordered/first'])
|
63
91
|
|
64
|
-
expect(node.
|
92
|
+
expect(node.relative_path("preview.jpg")).to eq(Utopia::Path['/ordered/preview.jpg'])
|
65
93
|
end
|
66
94
|
end
|
67
|
-
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -792,7 +792,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
792
792
|
- !ruby/object:Gem::Version
|
793
793
|
version: '0'
|
794
794
|
requirements: []
|
795
|
-
rubygems_version: 3.0.
|
795
|
+
rubygems_version: 3.0.6
|
796
796
|
signing_key:
|
797
797
|
specification_version: 4
|
798
798
|
summary: Utopia is a framework for building dynamic content-driven websites.
|