From 5d47fdff8b1cc95f6c1e5d290db97411997151bb Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Mon, 1 Dec 2008 22:58:09 -0600 Subject: [PATCH] Make Interweb Links Work Right Links to a published web should be to the 'publish' action, not to the 'show' action. Previously, the published status of the source, not the target was used. Also, correct display of the Navigation Links for the 'published' action. --- app/views/layouts/default.rhtml | 2 +- app/views/navigation.rhtml | 2 +- lib/url_generator.rb | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index af930e25..145da46a 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -2,7 +2,7 @@ - <% if @page and (@page.name == 'HomePage') and (%w( show published print ).include?(@action_name)) %> + <% if @page and (@page.name == 'HomePage') and (%w( show published print ).include?(params['action'])) %> <%= h @web.name %> <% elsif @web %> <%= @title %> in <%= h @web.name %> diff --git a/app/views/navigation.rhtml b/app/views/navigation.rhtml index 099b8b24..6bf833ee 100644 --- a/app/views/navigation.rhtml +++ b/app/views/navigation.rhtml @@ -9,7 +9,7 @@ end %> <div class="navigation"> - <% if @action_name != 'published' then %> + <% if params['action'] != 'published' then %> <%= list_item 'Home Page', {:action => 'show', :id => 'HomePage'}, 'Home, Sweet Home', 'H' %> | <%= list_item 'All Pages', {:action => 'list'}, 'Alphabetically sorted list of pages', 'A' %> | <%= list_item 'Recently Revised', {:action =>'recently_revised'}, 'Pages sorted by when they were last changed', 'U' %> | diff --git a/lib/url_generator.rb b/lib/url_generator.rb index 8f12e535..9eb44cd8 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -81,7 +81,9 @@ class UrlGenerator < AbstractUrlGenerator end when :publish if known_page - href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'published', + web = Web.find_by_address(web_address) + action = web.published? ? 'published' : 'show' + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, :id => name %{<a class="existingWikiWord" href="#{href}">#{text}</a>} else @@ -89,7 +91,9 @@ class UrlGenerator < AbstractUrlGenerator end else if known_page - href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'show', + web = Web.find_by_address(web_address) + action = web.published? ? 'published' : 'show' + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, :id => name %{<a class="existingWikiWord" href="#{href}">#{text}</a>} else