Wikilinks to Published Webs

Should be to the published action. This
didn't work right for inter-web links.
(Reported by Mike Shulman)

Also, change some .length's to .size's
(for Andrew Stacey)
This commit is contained in:
Jacques Distler 2009-09-03 23:09:10 -05:00
parent 888e93a7fd
commit 342298ed0e
5 changed files with 11 additions and 8 deletions

View file

@ -98,7 +98,7 @@ class WikiController < ApplicationController
<div class="byline">
#{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 }) }
</div>
</body>
</html>

View file

@ -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

View file

@ -8,9 +8,9 @@
<%- for page in @pages_by_day[day] -%>
<li>
<%= link_to_existing_page page %>
<%- if page.revisions.length > 1 %>
<%- if page.revisions.size > 1 %>
<span class="views">
( <%= 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') %> )
</span>
<%- end -%>

View file

@ -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
%{<a class="existingWikiWord" href="#{href}">#{text}</a>}
else

View file

@ -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