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
21
lib/chunks/redirect.rb
Normal file
21
lib/chunks/redirect.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue