Wiki Redirects and Page Renaming
Added the ability to rename existing pages. [[!redirects Some Page Name]] redirects Wikilinks [[Some Page Name]] to the current page (assuming "Some Page Name" does not exist). Real pages trump redirects (though this may change, depending on user feedback).
This commit is contained in:
parent
634f635f16
commit
d7832ba262
16 changed files with 161 additions and 33 deletions
|
@ -10,23 +10,30 @@ 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(name, web, text = nil, options = {})
|
||||
def make_link(asked_name, web, text = nil, options = {})
|
||||
mode = (options[:mode] || :show).to_sym
|
||||
link_type = (options[:link_type] || :show).to_sym
|
||||
|
||||
if (link_type == :show)
|
||||
known_page = web.has_page?(name)
|
||||
page_exists = web.has_page?(asked_name)
|
||||
known_page = page_exists || web.has_redirect_for?(asked_name)
|
||||
if known_page && !page_exists
|
||||
name = web.page_that_redirects_for(asked_name)
|
||||
else
|
||||
name = asked_name
|
||||
end
|
||||
else
|
||||
name = asked_name
|
||||
known_page = web.has_file?(name)
|
||||
description = web.description(name)
|
||||
description = description.unescapeHTML.escapeHTML if description
|
||||
end
|
||||
if (text == name)
|
||||
if (text == asked_name)
|
||||
text = description || text
|
||||
else
|
||||
text = text || description
|
||||
end
|
||||
text = (text || WikiWords.separate(name)).unescapeHTML.escapeHTML
|
||||
text = (text || WikiWords.separate(asked_name)).unescapeHTML.escapeHTML
|
||||
|
||||
case link_type
|
||||
when :show
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue