diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index a1110e4b..404a116a 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -98,7 +98,7 @@ class WikiController < ApplicationController
#{page.revisions? ? "Revised" : "Created" } on #{ page.revised_at.strftime('%B %d, %Y %H:%M:%S') } by - #{ UrlGenerator.new(self).make_link(page.author.name, @web, nil, { :mode => :export }) } + #{ UrlGenerator.new(self).make_link(@web, page.author.name, @web, nil, { :mode => :export }) }
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f6662834..c0602606 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -44,12 +44,12 @@ module ApplicationHelper # Creates a hyperlink to a Wiki page, or to a "new page" form if the page doesn't exist yet def link_to_page(page_name, web = @web, text = nil, options = {}) raise 'Web not defined' if web.nil? - UrlGenerator.new(@controller).make_link(page_name, web, text, + UrlGenerator.new(@controller).make_link(@web, page_name, web, text, options.merge(:base_url => "#{base_url}/#{web.address}")) end def author_link(page, options = {}) - UrlGenerator.new(@controller).make_link(page.author.name, page.web, nil, options) + UrlGenerator.new(@controller).make_link(@web, page.author.name, page.web, nil, options) end # Create a hyperlink to a particular revision of a Wiki page diff --git a/app/views/wiki/recently_revised.rhtml b/app/views/wiki/recently_revised.rhtml index abf49a04..9c604000 100644 --- a/app/views/wiki/recently_revised.rhtml +++ b/app/views/wiki/recently_revised.rhtml @@ -8,9 +8,9 @@ <%- for page in @pages_by_day[day] -%>
  • <%= link_to_existing_page page %> - <%- if page.revisions.length > 1 %> + <%- if page.revisions.size > 1 %> - ( <%= link_to_revision(page, page.revisions.length, text='diff', + ( <%= link_to_revision(page, page.revisions.size, text='diff', mode='diff') %> | <%= link_to_history(page, text='history') %> ) <%- end -%> diff --git a/lib/url_generator.rb b/lib/url_generator.rb index cbfbf110..ba3fab57 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -10,7 +10,8 @@ class AbstractUrlGenerator # Create a link for the given page (or file) name and link text based # on the render mode in options and whether the page (file) exists # in the web. - def make_link(asked_name, web, text = nil, options = {}) + def make_link(current_web, asked_name, web, text = nil, options = {}) + @web = current_web mode = (options[:mode] || :show).to_sym link_type = (options[:link_type] || :show).to_sym @@ -105,7 +106,9 @@ class UrlGenerator < AbstractUrlGenerator end when :show if known_page - href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'show', + web = Web.find_by_address(web_address) + action = web.published? && web != @web ? 'published' : 'show' + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, :id => name, :only_path => true %{#{text}} else diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index cc0784dc..8825029f 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -155,7 +155,7 @@ class WikiContent < String def page_link(web_name, name, text, link_type) web = Web.find_by_name(web_name) || Web.find_by_address(web_name) || @web @options[:link_type] = (link_type || :show) - @url_generator.make_link(name, web, text, @options) + @url_generator.make_link(@web, name, web, text, @options) end def build_chunks