d7832ba262
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).
22 lines
613 B
Ruby
22 lines
613 B
Ruby
require 'chunks/wiki'
|
|
|
|
# [[!redirects Foo]]
|
|
# redirects Wikilinks for the (nonexistent) page "Foo" to this page.
|
|
# If "Foo" exists, then the Redirect has no effect. But if "Foo"
|
|
# does not exist, then a Wikilink [[Foo]] will produce a link to this
|
|
# page, rather than produce a create-a-new-page link.
|
|
|
|
class Redirect < WikiChunk::WikiReference
|
|
|
|
REDIRECT_PATTERN = /\[\[!redirects\s+([^\]\s][^\]]*?)\s*\]\]/i
|
|
def self.pattern() REDIRECT_PATTERN end
|
|
|
|
def initialize(match_data, content)
|
|
super
|
|
@page_name = match_data[1].strip
|
|
@link_type = :redirect
|
|
@unmask_text = ''
|
|
end
|
|
|
|
end
|