Rather than just displaying the catalog entry url, I've made it into a link.
The link will redirect to the actual url only if the url is reachable and the
xml is valid, else it will display a warning to the user.
Show replies by date
The links will validate the validity of the url (is reachable and valid xml).
If the url passes validation, it will redirect to the actual xml file that's
hosted. If it doesn't validate, a warning message will be displayed to the user.
---
src/app/controllers/catalog_entries_controller.rb | 15 +++++++++++++++
src/app/views/catalog_entries/_properties.haml | 2 +-
src/app/views/catalogs/show.haml | 3 ++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/catalog_entries_controller.rb
b/src/app/controllers/catalog_entries_controller.rb
index 6c9addf..7b687a7 100644
--- a/src/app/controllers/catalog_entries_controller.rb
+++ b/src/app/controllers/catalog_entries_controller.rb
@@ -33,6 +33,15 @@ class CatalogEntriesController < ApplicationController
end
def show
+ if params[:deployable_xml]
+ if redirect_to_deployable_xml?
+ redirect_to @catalog_entry.url
+ return
+ end
+
+ flash[:warning] = "Catalog entry XML file is either invalid or no longer
reachable at #{(a)catalog_entry.url}"
+ redirect_to catalog_path((a)catalog_entry.owner)
+ end
@catalog_entry = CatalogEntry.find(params[:id])
require_privilege(Privilege::VIEW, @catalog_entry)
save_breadcrumb(catalog_entry_path(@catalog_entry), @catalog_entry.name)
@@ -106,6 +115,12 @@ class CatalogEntriesController < ApplicationController
]
end
+ def redirect_to_deployable_xml?
+ @catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::VIEW, @catalog_entry)
+ @catalog_entry.accessible_and_valid_deployable_xml?((a)catalog_entry.url)
+ end
+
def load_catalogs
@catalogs = Catalog.list_for_user(current_user, Privilege::MODIFY)
end
diff --git a/src/app/views/catalog_entries/_properties.haml
b/src/app/views/catalog_entries/_properties.haml
index 67c6221..d24284a 100644
--- a/src/app/views/catalog_entries/_properties.haml
+++ b/src/app/views/catalog_entries/_properties.haml
@@ -20,4 +20,4 @@
%td
%label{:name => 'url'} URL:
%td
- = @catalog_entry.url
+ = link_to @catalog_entry.url, catalog_entry_path((a)catalog_entry.id,
:deployable_xml => true)
diff --git a/src/app/views/catalogs/show.haml b/src/app/views/catalogs/show.haml
index 00b8830..8321b58 100644
--- a/src/app/views/catalogs/show.haml
+++ b/src/app/views/catalogs/show.haml
@@ -31,4 +31,5 @@
%td
= link_to catalog_entry.name, catalog_entry_path(catalog_entry.id)
%td
- = catalog_entry.url
+ = link_to catalog_entry.url, catalog_entry_path(catalog_entry.id,
:deployable_xml => true)
+
--
1.7.6.2