Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/utopia/content/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ def freeze
end

attr :root

# TODO we should remove this method and expose `@links` directly.
def links(path, **options)
@links.index(path, **options)
end
attr :links

# Load and cache a content template.
# @parameter path [Utopia::Path | String] The path.
Expand Down
6 changes: 3 additions & 3 deletions lib/utopia/content/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def parent_path
def links(path = ".", **options, &block)
path = uri_path.dirname + Path[path]

links = @controller.links(path, **options)
links = @controller.links.index(path, **options)

if block_given?
links.each(&block)
Expand All @@ -96,7 +96,7 @@ def links(path = ".", **options, &block)
# Return localized and indexed variants related to this node.
# @returns [Array(Link)] The related links.
def related_links
@controller.links(@uri_path.dirname, name: @uri_path.basename, indices: true)
@controller.links.index(@uri_path.dirname, name: @uri_path.basename, indices: true)
end

# Return the directory whose links are siblings of this node.
Expand All @@ -113,7 +113,7 @@ def siblings_path
# @parameter options [Hash] The options.
# @returns [Array(Link)] The sibling links.
def sibling_links(**options)
return @controller.links(siblings_path, **options)
return @controller.links.index(siblings_path, **options)
end

# Lookup the given tag which is being rendered within the given node. Invoked by {Document}.
Expand Down
1 change: 1 addition & 0 deletions releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- **Breaking** Remove support for JavaScript packages installed in `lib/components`; use `node_modules` instead.
- **Breaking** Expose {ruby Utopia::Content::Middleware#links} as the content link resolver rather than an indexed lookup method.
- **Security** Authenticate encrypted session cookies using AES-256-GCM. Existing session cookies are invalidated.
- **Security** Redact sensitive exception report fields and make bounded request body attachments opt-in.

Expand Down
4 changes: 4 additions & 0 deletions test/utopia/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
let(:root) {File.expand_path(".content", __dir__)}
let(:content) {Utopia::Content.new(Protocol::HTTP::Middleware::NotFound, root: root)}

it "exposes its link resolver" do
expect(content.links).to be_a Utopia::Content::Links
end

it "should parse file and expand variables" do
path = Utopia::Path.create("/index")
node = content.lookup_node(path)
Expand Down
Loading