Skip to content

Commit

Permalink
Add a methods to list all navigation links
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaben committed Sep 18, 2010
1 parent db41cfe commit 7ccdf14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/opds/navigation_feed.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
module OPDS
class NavigationFeed < Feed
def navigation_links
nav_links=Support::LinkSet.new @browser
self.links.each do |l|
nav_links.push_link l if l.type=='application/atom+xml'
end

self.entries.each do |entry|
entry.links.each do |l|
nav_links.push_link l if l.type=='application/atom+xml'
end
end
nav_links
end
end
end
8 changes: 8 additions & 0 deletions lib/opds/support/linkset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def push(rel,link,text=nil,type=nil, price=nil, currency=nil)
self[rel]=tab
end

def push_link(link)
@store.push link if link.is_a?Link
end

def link_url(k)
ty,v=k.first
t=remap(collection(ty)[v])
Expand Down Expand Up @@ -144,6 +148,10 @@ def last
@store.last
end

def to_yaml
@store.to_yaml
end

protected
def collection(type)
case type.to_s
Expand Down

0 comments on commit 7ccdf14

Please sign in to comment.