utopia 2.9.5 → 2.10.0

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: 96bc613a811559da9b85d83e9bf9465874582cf1bc6cb6bca7b8fe93d0768290
4
- data.tar.gz: 3e9a80e381f58ee71c455999e1ff6d5600ce2c34c8c2d7cad1742fe9c6bd0f47
3
+ metadata.gz: 473bc20c3cb5a2b2b0bc08830a5b34ac5519f60fbc97453292da59671a857c6f
4
+ data.tar.gz: 1c78fb9a0d685502b675ac1351eaa465c4140317ad0aa1fbd323632822b5d84f
5
5
  SHA512:
6
- metadata.gz: 948b833d0e28b70f133127ede3efe3eacde864b4fc8d56ade1aa11f308bce613d3cb7e5c2d4c303dcc06f7740cf39da4933c80758c7ea21029692e1524cb4f66
7
- data.tar.gz: d74697bf496eecec19821b678a2aaf47cd886327006a8b5cad94bccdbfb4f62726228009a57d3acf8814234db8ccdcb0918956b22f2effd4499b42fa39a7da5c
6
+ metadata.gz: 2b2d06006aff49f81104a7fa0bf7b03167e1b92d3afe2412409032b22f652b3493a6fccef5b578aa7dcb9b14c10797248db6e5e5d24e088f122af7957bffe1a3
7
+ data.tar.gz: 001e36314faf87ab21c25b047d2ad532c7e96990d9f365fa4b407e04e2fe61cc2ffaa35c1ce883fa91501c6e192164d50223581ad52bec6b6fc58d5a6da490ce
@@ -94,21 +94,20 @@ module Utopia
94
94
  @info.fetch(:title, @title)
95
95
  end
96
96
 
97
- def to_anchor(**options)
98
- Trenni::Builder.fragment(options[:builder]) do |builder|
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
- :class => options.fetch(:class, 'link'),
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(options[:content] || title)
106
+ builder.text(content)
108
107
  end
109
108
  else
110
- builder.inline('span', class: options.fetch(:class, 'link')) do
111
- builder.text(options[:content] || title)
109
+ builder.inline('span', attributes) do
110
+ builder.text(content)
112
111
  end
113
112
  end
114
113
  end
@@ -65,7 +65,14 @@ module Utopia
65
65
  return root.join(*(base + path).components)
66
66
  end
67
67
  end
68
-
68
+
69
+ def relative_path(path = '.')
70
+ path = Path[path]
71
+ base = uri_path.dirname
72
+
73
+ return base + path
74
+ end
75
+
69
76
  def parent_path
70
77
  @uri_path.dirname
71
78
  end
@@ -109,7 +109,7 @@ module Utopia
109
109
  else
110
110
  # Partial content:
111
111
  @range = ranges[0]
112
- partial_size = @range.count
112
+ partial_size = @range.size
113
113
 
114
114
  response[0] = 206
115
115
  response[1][CONTENT_LENGTH] = partial_size.to_s
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "2.9.5"
22
+ VERSION = "2.10.0"
23
23
  end
@@ -20,48 +20,76 @@
20
20
 
21
21
  require 'utopia/content'
22
22
 
23
- module Utopia::ContentSpec
24
- describe Utopia::Content::Node do
25
- let(:root) {File.expand_path("node", __dir__)}
26
- let(:content) {Utopia::Content.new(lambda{}, root: root)}
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
- it "should list siblings in correct order" do
29
- node = content.lookup_node(Utopia::Path['/ordered/first'])
30
-
31
- links = node.sibling_links
32
-
33
- expect(links.size).to be == 2
34
- expect(links[0].name).to be == 'first'
35
- expect(links[1].name).to be == 'second'
36
- end
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
- it "should list all links in correct order" do
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
- links = node.links
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 "should list related links" do
49
- node = content.lookup_node(Utopia::Path['/related/foo.en'])
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(links.size).to be == 2
54
- expect(links[0].name).to be == 'foo'
55
- expect(links[0].locale).to be == 'en'
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(links[1].name).to be == 'foo'
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 "should look up node by path" do
62
- node = content.lookup_node(Utopia::Path['/lookup/index'])
89
+ it "can compute relative path from named node" do
90
+ node = content.lookup_node(Utopia::Path['/ordered/first'])
63
91
 
64
- expect(node.process!(nil)).to be == [200, {"Content-Type"=>"text/html; charset=utf-8"}, ["<p>Hello World</p>"]]
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.9.5
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-09-17 00:00:00.000000000 Z
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.4
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.