@@ -246,12 +246,12 module ApplicationHelper | |||
|
246 | 246 | case options[:wiki_links] |
|
247 | 247 | when :local |
|
248 | 248 | # used for local links to html files |
|
249 | format_wiki_link = Proc.new {|project, title| "#{title}.html" } | |
|
249 | format_wiki_link = Proc.new {|project, title, anchor| "#{title}.html" } | |
|
250 | 250 | when :anchor |
|
251 | 251 | # used for single-file wiki export |
|
252 | format_wiki_link = Proc.new {|project, title| "##{title}" } | |
|
252 | format_wiki_link = Proc.new {|project, title, anchor| "##{title}" } | |
|
253 | 253 | else |
|
254 | format_wiki_link = Proc.new {|project, title| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title) } | |
|
254 | format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) } | |
|
255 | 255 | end |
|
256 | 256 | |
|
257 | 257 | project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) |
@@ -277,9 +277,14 module ApplicationHelper | |||
|
277 | 277 | end |
|
278 | 278 | |
|
279 | 279 | if link_project && link_project.wiki |
|
280 | # extract anchor | |
|
281 | anchor = nil | |
|
282 | if page =~ /^(.+?)\#(.+)$/ | |
|
283 | page, anchor = $1, $2 | |
|
284 | end | |
|
280 | 285 | # check if page exists |
|
281 | 286 | wiki_page = link_project.wiki.find_page(page) |
|
282 | link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), | |
|
287 | link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page), anchor), | |
|
283 | 288 | :class => ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
284 | 289 | else |
|
285 | 290 | # project or wiki doesn't exist |
@@ -133,6 +133,9 class ApplicationHelperTest < HelperTestCase | |||
|
133 | 133 | to_test = { |
|
134 | 134 | '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>', |
|
135 | 135 | '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>', |
|
136 | # link with anchor | |
|
137 | '[[CookBook documentation#One-section]]' => '<a href="/wiki/ecookbook/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>', | |
|
138 | '[[Another page#anchor|Page]]' => '<a href="/wiki/ecookbook/Another_page#anchor" class="wiki-page">Page</a>', | |
|
136 | 139 | # page that doesn't exist |
|
137 | 140 | '[[Unknown page]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">Unknown page</a>', |
|
138 | 141 | '[[Unknown page|404]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">404</a>', |
General Comments 0
You need to be logged in to leave comments.
Login now