Respect base URL in OPDS feed

This commit is contained in:
Alex Ling 2020-06-05 15:18:46 +00:00
parent 012fd71ab4
commit 6ad4385b18
3 changed files with 10 additions and 9 deletions

View File

@ -133,6 +133,7 @@ def validate_password(password)
end end
macro render_xml(path) macro render_xml(path)
base_url = Config.current.base_url
send_file env, ECR.render({{path}}).to_slice, "application/xml" send_file env, ECR.render({{path}}).to_slice, "application/xml"
end end

View File

@ -4,8 +4,8 @@
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<id>urn:mango:index</id> <id>urn:mango:index</id>
<link rel="self" href="/opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" /> <link rel="self" href="<%= base_url %>opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<link rel="start" href="/opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" /> <link rel="start" href="<%= base_url %>opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<title>Library</title> <title>Library</title>
@ -18,7 +18,7 @@
<entry> <entry>
<title><%= t.display_name %></title> <title><%= t.display_name %></title>
<id>urn:mango:<%= t.id %></id> <id>urn:mango:<%= t.id %></id>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" href="/opds/book/<%= t.id %>" /> <link type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" href="<%= base_url %>opds/book/<%= t.id %>" />
</entry> </entry>
<% end %> <% end %>
</feed> </feed>

View File

@ -2,8 +2,8 @@
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<id>urn:mango:<%= title.id %></id> <id>urn:mango:<%= title.id %></id>
<link rel="self" href="/opds/book/<%= title.id %>" type="application/atom+xml;profile=opds-catalog;kind=navigation" /> <link rel="self" href="<%= base_url %>opds/book/<%= title.id %>" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<link rel="start" href="/opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" /> <link rel="start" href="<%= base_url %>opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<title><%= title.display_name %></title> <title><%= title.display_name %></title>
@ -16,7 +16,7 @@
<entry> <entry>
<title><%= t.display_name %></title> <title><%= t.display_name %></title>
<id>urn:mango:<%= t.id %></id> <id>urn:mango:<%= t.id %></id>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" href="/opds/book/<%= t.id %>" /> <link type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" href="<%= base_url %>opds/book/<%= t.id %>" />
</entry> </entry>
<% end %> <% end %>
@ -28,10 +28,10 @@
<link rel="http://opds-spec.org/image" href="<%= e.cover_url %>" /> <link rel="http://opds-spec.org/image" href="<%= e.cover_url %>" />
<link rel="http://opds-spec.org/image/thumbnail" href="<%= e.cover_url %>" /> <link rel="http://opds-spec.org/image/thumbnail" href="<%= e.cover_url %>" />
<link rel="http://opds-spec.org/acquisition" href="/opds/download/<%= e.title_id %>/<%= e.id %>" title="Read" type="<%= MIME.from_filename e.zip_path %>" /> <link rel="http://opds-spec.org/acquisition" href="<%= base_url %>opds/download/<%= e.title_id %>/<%= e.id %>" title="Read" type="<%= MIME.from_filename e.zip_path %>" />
<link type="text/html" rel="alternate" title="Read in Mango" href="/reader/<%= e.title_id %>/<%= e.id %>" /> <link type="text/html" rel="alternate" title="Read in Mango" href="<%= base_url %>reader/<%= e.title_id %>/<%= e.id %>" />
<link type="text/html" rel="alternate" title="Open in Mango" href="/book/<%= e.title_id %>" /> <link type="text/html" rel="alternate" title="Open in Mango" href="<%= base_url %>book/<%= e.title_id %>" />
</entry> </entry>
<% end %> <% end %>