Fix page_for_archive_file.

This commit is contained in:
邱博亞 2024-08-03 13:03:50 +08:00
parent f020221a47
commit 18d4162c7e
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,5 @@
module Admin::ArchiveFilesHelper module Admin::ArchiveFilesHelper
def page_for_archive_file(archive_file) def page_for_archive_file(archive_file, full_url=false)
archive_file_page = nil archive_file_page = nil
pages = Page.where(:module=>'archive').select{|page| page.enabled_for.include?(I18n.locale.to_s)} pages = Page.where(:module=>'archive').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
@ -18,8 +18,12 @@ module Admin::ArchiveFilesHelper
end end
break if !archive_file_page.nil? break if !archive_file_page.nil?
end end
archive_file_page = pages.first if archive_file_page.nil?
end
if full_url
request.protocol+(request.host_with_port+archive_file_page.url+'/'+archive_file.to_param).gsub('//','/') rescue "#"
else
"#{archive_file_page.url}?title=#{archive_file.title}"
end end
archive_file_page = pages.first if archive_file_page.nil?
request.protocol+(request.host_with_port+archive_file_page.url+'/'+archive_file.to_param).gsub('//','/') rescue "#"
end end
end end

View File

@ -113,7 +113,7 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<a href="/admin/archive_files/show?title=<%= archive.title %>" target="_blank"><%= archive.title %></a> <a href="<%= page_for_archive_file(archive) %>" target="_blank"><%= archive.title %></a>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<% if is_editable %> <% if is_editable %>

View File

@ -9,7 +9,7 @@ xml.rss :version => "2.0" do
xml.title archive_file.title xml.title archive_file.title
xml.description archive_file.description xml.description archive_file.description
xml.pubDate archive_file.created_at.to_s(:rfc822) xml.pubDate archive_file.created_at.to_s(:rfc822)
xml.link page_for_archive_file(archive_file) xml.link page_for_archive_file(archive_file, true)
end end
end end
end end