Module: MediaWiki::Query::Meta::SiteInfo
- Included in:
- Butt
- Defined in:
- lib/mediawiki/query/meta/siteinfo.rb
Overview
Instance Method Summary collapse
-
#get_all_usergroups ⇒ Hash<String, Array<String>>
Gets all user groups total.
-
#get_allowed_file_extensions ⇒ Array<String>
Gets all file extensions that are allowed to be uploaded.
-
#get_article_path(article_name) ⇒ String
The full article path for the provided article.
-
#get_base_article_path ⇒ String
The article path for the wiki.
-
#get_extension_tags ⇒ Array<String>
Gets all HTML tags added by installed extensions.
-
#get_extensions ⇒ Array<String>
Gets all extensions installed on the wiki.
-
#get_function_hooks ⇒ Array<String>
Gets all function hooks.
-
#get_general ⇒ Hash<String, Any>
Gets the general information for the wiki.
-
#get_languages ⇒ Hash<String, String>
Gets all languages and their codes.
-
#get_magic_words ⇒ Hash<String, Array<String>>
Gets all magic words and their aliases.
-
#get_namespace_aliases ⇒ Hash<Fixnum, String>
Gets all namespace aliases and their IDs.
-
#get_namespaces ⇒ Hash<Fixnum, String>
Gets all namespaces on the wiki and their IDs.
-
#get_restriction_levels ⇒ Array<String>
Gets all restriction/protection levels.
-
#get_restriction_types ⇒ Array<String>
Gets all restriction/protection types.
-
#get_restrictions_data ⇒ Hash<String, Array<String>>
Gets the response for the restrictions siteinfo API.
-
#get_server ⇒ String
Gets the protocol-relative server URL for the wiki.
-
#get_siteinfo(prop) ⇒ Hash
Gets wiki information.
-
#get_skins ⇒ Hash<String, String>
Gets all skins and their codes.
-
#get_special_page_aliases ⇒ Hash<String, Array<String>>
Gets all special page aliases.
-
#get_statistics ⇒ Hash<String, Fixnum>
Gets the statistics for the wiki.
-
#get_variables ⇒ Array<String>
Gets all variables that are usable on the wiki, such as NUMBEROFPAGES.
Instance Method Details
#get_all_usergroups ⇒ Hash<String, Array<String>>
Gets all user groups total.
110 111 112 113 114 115 116 117 |
# 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 ⇒ Array<String>
Gets all file extensions that are allowed to be uploaded.
122 123 124 |
# 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) ⇒ String
Returns The full article path for the provided article. This is protocol-relative.
195 196 197 |
# 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 ⇒ String
Returns 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.
189 190 191 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 189 def get_base_article_path get_general['articlepath'] end |
#get_extension_tags ⇒ Array<String>
Gets all HTML tags added by installed extensions.
163 164 165 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 163 def get_siteinfo('extensiontags')['query']['extensiontags'] end |
#get_extensions ⇒ Array<String>
Gets all extensions installed on the wiki.
43 44 45 |
# 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 ⇒ Array<String>
Gets all function hooks.
170 171 172 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 170 def get_function_hooks get_siteinfo('functionhooks')['query']['functionhooks'] end |
#get_general ⇒ Hash<String, Any>
Gets the general information for the wiki.
33 34 35 36 37 38 |
# 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 ⇒ Hash<String, String>
Gets all languages and their codes.
50 51 52 53 54 55 |
# 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 ⇒ Hash<String, Array<String>>
Gets all magic words and their aliases.
98 99 100 101 102 103 104 105 |
# 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 ⇒ Hash<Fixnum, String>
Gets all namespace aliases and their IDs.
74 75 76 77 78 79 80 81 |
# 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 ⇒ Hash<Fixnum, String>
Gets all namespaces on the wiki and their IDs. Different from the Namespaces module.
60 61 62 63 64 65 66 67 68 69 |
# 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 ⇒ Array<String>
Gets all restriction/protection levels.
144 145 146 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 144 def get_restriction_levels get_restrictions_data['levels'] end |
#get_restriction_types ⇒ Array<String>
Gets all restriction/protection types.
137 138 139 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 137 def get_restriction_types get_restrictions_data['types'] end |
#get_restrictions_data ⇒ Hash<String, Array<String>>
Gets the response for the restrictions siteinfo API. Not really for use by users, mostly for the other two restriction methods.
130 131 132 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 130 def get_restrictions_data get_siteinfo('restrictions')['query']['restrictions'] end |
#get_server ⇒ String
Gets the protocol-relative server URL for the wiki.
183 184 185 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 183 def get_server get_general['server'] end |
#get_siteinfo(prop) ⇒ Hash
Gets wiki information. This method should rarely be used by normal users.
10 11 12 13 14 15 16 17 18 |
# 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 ⇒ Hash<String, String>
Gets all skins and their codes.
151 152 153 154 155 156 157 158 |
# 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 ⇒ Hash<String, Array<String>>
Gets all special page aliases.
86 87 88 89 90 91 92 93 |
# 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 ⇒ Hash<String, Fixnum>
Gets the statistics for the wiki.
23 24 25 26 27 28 |
# 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 ⇒ Array<String>
Gets all variables that are usable on the wiki, such as NUMBEROFPAGES.
177 178 179 |
# File 'lib/mediawiki/query/meta/siteinfo.rb', line 177 def get_variables get_siteinfo('variables')['query']['variables'] end |