module MediaWiki::Query::Meta::SiteInfo

@see www.mediawiki.org/wiki/API:Siteinfo MediaWiki Siteinfo API Docs

Public Instance Methods

get_all_usergroups() click to toggle source

Gets all user groups total. @since 0.6.0 @return [Hash<String, Array<String>>] All groups, formatted as Name => [Rights].

# File lib/mediawiki/query/meta/siteinfo.rb, line 110
def get_all_usergroups
  response = get_siteinfo('usergroups')
  ret = {}
  response['query']['usergroups'].each do |g|
    ret[g['name']] = g['rights']
  end
  ret
end
get_allowed_file_extensions() click to toggle source

Gets all file extensions that are allowed to be uploaded. @since 0.6.0 @return [Array<String>] All file extensions.

# File lib/mediawiki/query/meta/siteinfo.rb, line 122
def get_allowed_file_extensions
  get_siteinfo('fileextensions')['query']['fileextensions'].collect { |e| e['ext'] }
end
get_article_path(article_name) click to toggle source

@param article_name [String] The name of the article. @return [String] The full article path for the provided article. This is protocol-relative.

# File lib/mediawiki/query/meta/siteinfo.rb, line 195
def get_article_path(article_name)
  get_server + get_base_article_path.sub('$1', article_name)
end
get_base_article_path() click to toggle source

@return [String] The article path for the wiki. It includes “$1”, which should be replaced with the actual

name of the article. Does not include the URL for the wiki. For example: /wiki/$1 for Wikpedia.
# File lib/mediawiki/query/meta/siteinfo.rb, line 189
def get_base_article_path
  get_general['articlepath']
end
get_extension_tags() click to toggle source

Gets all HTML tags added by installed extensions. @since 0.6.0 @return [Array<String>] All extension tags.

# File lib/mediawiki/query/meta/siteinfo.rb, line 163
def get_extension_tags
  get_siteinfo('extensiontags')['query']['extensiontags']
end
get_extensions() click to toggle source

Gets all extensions installed on the wiki. @since 0.6.0 @return [Array<String>] All extension names.

# File lib/mediawiki/query/meta/siteinfo.rb, line 43
def get_extensions
   get_siteinfo('extensions')['query']['extensions'].collect { |e| e['name'] }
end
get_function_hooks() click to toggle source

Gets all function hooks. @since 0.6.0 @return [Array<String>] All function hooks.

# File lib/mediawiki/query/meta/siteinfo.rb, line 170
def get_function_hooks
  get_siteinfo('functionhooks')['query']['functionhooks']
end
get_general() click to toggle source

Gets the general information for the wiki. @since 0.6.0 @return [Hash<String, Any>] The general info and their according values.

# File lib/mediawiki/query/meta/siteinfo.rb, line 33
def get_general
  response = get_siteinfo('general')
  ret = {}
  response['query']['general'].each { |k, v| ret[k] = v }
  ret
end
get_languages() click to toggle source

Gets all languages and their codes. @since 0.6.0 @return [Hash<String, String>] All languages. Hash key value pair formatted as code => name.

# File lib/mediawiki/query/meta/siteinfo.rb, line 50
def get_languages
  response = get_siteinfo('languages')
  ret = {}
  response['query']['languages'].each { |l| ret[l['code']] = l['*'] }
  ret
end
get_magic_words() click to toggle source

Gets all magic words and their aliases. @since 0.6.0 @return [Hash<String, Array<String>>] All magic words, formatted as Name => Alias.

# File lib/mediawiki/query/meta/siteinfo.rb, line 98
def get_magic_words
  response = get_siteinfo('magicwords')
  ret = {}
  response['query']['magicwords'].each do |w|
    ret[w['name']] = w['aliases']
  end
  ret
end
get_namespace_aliases() click to toggle source

Gets all namespace aliases and their IDs. @since 0.6.0 @return [Hash<Fixnum, String>] All aliases, formatted as ID => Alias.

# File lib/mediawiki/query/meta/siteinfo.rb, line 74
def get_namespace_aliases
  response = get_siteinfo('namespacealiases')
  ret = {}
  response['query']['namespacealiases'].each do |i|
    ret[i['id']] = i['*']
  end
  ret
end
get_namespaces() click to toggle source

Gets all namespaces on the wiki and their IDs. Different from the Namespaces module. @since 0.6.0 @return [Hash<Fixnum, String>] All namespaces, formatted as ID => Name.

# File lib/mediawiki/query/meta/siteinfo.rb, line 60
def get_namespaces
  response = get_siteinfo('namespaces')
  ret = {}
  response['query']['namespaces'].each do |id, _|
    idid = response['query']['namespaces'][id]['id']
    name = response['query']['namespaces'][id]['*']
    ret[idid] = name
  end
  ret
end
get_restriction_levels() click to toggle source

Gets all restriction/protection levels. @since 0.6.0 @return [Array<String>] All protection levels.

# File lib/mediawiki/query/meta/siteinfo.rb, line 144
def get_restriction_levels
  get_restrictions_data['levels']
end
get_restriction_types() click to toggle source

Gets all restriction/protection types. @since 0.6.0 @return [Array<String>] All protection types.

# File lib/mediawiki/query/meta/siteinfo.rb, line 137
def get_restriction_types
  get_restrictions_data['types']
end
get_restrictions_data() click to toggle source

Gets the response for the restrictions siteinfo API. Not really for use by users, mostly for the other two restriction methods. @since 0.6.0 @return [Hash<String, Array<String>>] All restriction data. See the other restriction methods.

# File lib/mediawiki/query/meta/siteinfo.rb, line 130
def get_restrictions_data
  get_siteinfo('restrictions')['query']['restrictions']
end
get_server() click to toggle source

Gets the protocol-relative server URL for the wiki. @return [String] The server URL for the wiki. For example: //en.wikipedia.org for Wikipedia.

# File lib/mediawiki/query/meta/siteinfo.rb, line 183
def get_server
  get_general['server']
end
get_siteinfo(prop) click to toggle source

Gets wiki information. This method should rarely be used by normal users. @param prop [String] The siprop parameter. @since 0.6.0 @return [Hash] Parsed full response.

# File lib/mediawiki/query/meta/siteinfo.rb, line 10
def get_siteinfo(prop)
  params = {
    action: 'query',
    meta: 'siteinfo',
    siprop: prop
  }

  post(params)
end
get_skins() click to toggle source

Gets all skins and their codes. @since 0.6.0 @return [Hash<String, String>] All skins, formatted as Code => Name

# File lib/mediawiki/query/meta/siteinfo.rb, line 151
def get_skins
  response = get_siteinfo('skins')
  ret = {}
  response['query']['skins'].each do |s|
    ret[s['code']] = s['*']
  end
  ret
end
get_special_page_aliases() click to toggle source

Gets all special page aliases. @since 0.6.0 @return [Hash<String, Array<String>>] All aliases, formatted as RealName => Alias.

# File lib/mediawiki/query/meta/siteinfo.rb, line 86
def get_special_page_aliases
  response = get_siteinfo('specialpagealiases')
  ret = {}
  response['query']['specialpagealiases'].each do |i|
    ret[i['realname']] = i['aliases']
  end
  ret
end
get_statistics() click to toggle source

Gets the statistics for the wiki. @since 0.6.0 @return [Hash<String, Fixnum>] The statistics and their according values.

# File lib/mediawiki/query/meta/siteinfo.rb, line 23
def get_statistics
  response = get_siteinfo('statistics')
  ret = {}
  response['query']['statistics'].each { |k, v| ret[k] = v }
  ret
end
get_variables() click to toggle source

Gets all variables that are usable on the wiki, such as NUMBEROFPAGES. @since 0.6.0 @return [Array<String>] All variable string values.

# File lib/mediawiki/query/meta/siteinfo.rb, line 177
def get_variables
  get_siteinfo('variables')['query']['variables']
end