Module MediaWiki
In: lib/media_wiki/config.rb
lib/media_wiki/utils.rb
lib/media_wiki/gateway.rb

Methods

Classes and Modules

Class MediaWiki::Config
Class MediaWiki::Gateway

Public Class methods

Extract path leading up to subpage. If title does not contain a subpage, returns nil.

Examples: get_path_to_subpage("Namespace:Foo/Bar/Baz") -> "Namespace:Foo/Bar" get_path_to_subpage("Namespace:Foo") -> nil

title
Page name string in Wiki format

[Source]

    # File lib/media_wiki/utils.rb, line 11
11:     def get_path_to_subpage(title)
12:       return nil unless title and title.include? '/'
13:       parts = title.split(/\/([^\/]*)$/).first
14:     end

Extract subpage name. If there is no hierarchy above, return page name.

Examples: get_subpage("Namespace:Foo/Bar/Baz") -> "Baz" get_subpage("Namespace:Foo") -> "Namespace:Foo"

title
Page name string in Wiki format

[Source]

    # File lib/media_wiki/utils.rb, line 23
23:     def get_subpage(title)
24:       title.split('/').last if title
25:     end

Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("getting there & away"). Also strips out any illegal characters (#<>[]|{}, cf. meta.wikimedia.org/wiki/Help:Page_name#Restrictions).

wiki
Page name string in URL

[Source]

    # File lib/media_wiki/utils.rb, line 31
31:     def uri_to_wiki(uri)
32:       CGI.unescape(uri).tr('_', ' ').tr('#<>[]|{}', '') if uri
33:     end

Return current version of MediaWiki::Gateway

[Source]

    # File lib/media_wiki/utils.rb, line 43
43:     def version
44:       MediaWiki::VERSION
45:     end

Convert a Wiki page name ("getting there & away") to URI-safe format ("getting_there_%26_away"), taking care not to mangle slashes or colons

wiki
Page name string in Wiki format

[Source]

    # File lib/media_wiki/utils.rb, line 38
38:     def wiki_to_uri(wiki)
39:       wiki.to_s.split('/').map {|chunk| CGI.escape(chunk.tr(' ', '_')) }.join('/').gsub('%3A', ':') if wiki
40:     end

[Validate]