module MediaWiktory::Wikipedia::Actions::GlobalParams

Global setup methods included into every action through {Base}.

Public Instance Methods

_assert(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/base.rb, line 64
def _assert(value)
  defined?(super) && super || ["user", "bot"].include?(value.to_s) && merge(assert: value.to_s)
end
_errorformat(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/base.rb, line 130
def _errorformat(value)
  defined?(super) && super || [" plaintext", " wikitext", " html", " raw", " none", " bc"].include?(value.to_s) && merge(errorformat: value.to_s)
end
_format(value) click to toggle source

@private

# File lib/mediawiktory/wikipedia/actions/base.rb, line 27
def _format(value)
  [:json, :jsonfm, :none, :php, :phpfm, :rawfm, :xml, :xmlfm].include?(value.to_sym) && merge(format: value.to_s).submodule({json: Modules::Json, jsonfm: Modules::Jsonfm, none: Modules::None, php: Modules::Php, phpfm: Modules::Phpfm, rawfm: Modules::Rawfm, xml: Modules::Xml, xmlfm: Modules::Xmlfm}[value.to_sym])
end
assert(value) click to toggle source

Verify the user is logged in if set to user, or has the bot user right if bot.

@param value [String] One of “user”, “bot”. @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 59
def assert(value)
  _assert(value) or fail ArgumentError, "Unknown value for assert: #{value}"
end
assertuser(value) click to toggle source

Verify the current user is the named user.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 72
def assertuser(value)
  merge(assertuser: value.to_s)
end
centralauthtoken(value) click to toggle source

When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user. Use action=centralauthtoken on this wiki to retrieve the token, before making the CORS request. Each token may only be used once, and expires after 10 seconds. This should be included in any pre-flight request, and therefore should be included in the request URI (not the POST body).

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 153
def centralauthtoken(value)
  merge(centralauthtoken: value.to_s)
end
curtimestamp() click to toggle source

Include the current timestamp in the result.

@return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 94
def curtimestamp()
  merge(curtimestamp: 'true')
end
errorformat(value) click to toggle source

Format to use for warning and error text output.

@param value [String] One of “ plaintext” ( Wikitext with HTML tags removed and entities replaced), “ wikitext” ( Unparsed wikitext), “ html” ( HTML), “ raw” ( Message key and parameters), “ none” ( No text output, only the error codes), “ bc” ( Format used prior to MediaWiki 1.29. errorlang and errorsuselocal are ignored). @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 125
def errorformat(value)
  _errorformat(value) or fail ArgumentError, "Unknown value for errorformat: #{value}"
end
errorlang(value) click to toggle source

Language to use for warnings and errors. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify content to use this wiki's content language, or specify uselang to use the same value as the uselang parameter.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 138
def errorlang(value)
  merge(errorlang: value.to_s)
end
errorsuselocal() click to toggle source

If given, error texts will use locally-customized messages from the MediaWiki namespace.

@return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 145
def errorsuselocal()
  merge(errorsuselocal: 'true')
end
format(value) click to toggle source

The format of the output.

@param value [Symbol] Selecting an option includes tweaking methods from corresponding module:

* `:json` - {MediaWiktory::Wikipedia::Modules::Json} Output data in JSON format.
* `:jsonfm` - {MediaWiktory::Wikipedia::Modules::Jsonfm} Output data in JSON format (pretty-print in HTML).
* `:none` - {MediaWiktory::Wikipedia::Modules::None} Output nothing.
* `:php` - {MediaWiktory::Wikipedia::Modules::Php} Output data in serialized PHP format.
* `:phpfm` - {MediaWiktory::Wikipedia::Modules::Phpfm} Output data in serialized PHP format (pretty-print in HTML).
* `:rawfm` - {MediaWiktory::Wikipedia::Modules::Rawfm} Output data, including debugging elements, in JSON format (pretty-print in HTML).
* `:xml` - {MediaWiktory::Wikipedia::Modules::Xml} Output data in XML format.
* `:xmlfm` - {MediaWiktory::Wikipedia::Modules::Xmlfm} Output data in XML format (pretty-print in HTML).

@return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 22
def format(value)
  _format(value) or fail ArgumentError, "Unknown value for format: #{value}"
end
maxage(value) click to toggle source

Set the max-age HTTP cache control header to this many seconds. Errors are never cached.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 51
def maxage(value)
  merge(maxage: value.to_s)
end
maxlag(value) click to toggle source

Maximum lag can be used when MediaWiki is installed on a database replicated cluster. To save actions causing any more site replication lag, this parameter can make the client wait until the replication lag is less than the specified value. In case of excessive lag, error code maxlag is returned with a message like Waiting for $host: $lag seconds lagged.See Manual: Maxlag parameter for more information.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 35
def maxlag(value)
  merge(maxlag: value.to_s)
end
origin(value) click to toggle source

When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body).

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 109
def origin(value)
  merge(origin: value.to_s)
end
requestid(value) click to toggle source

Any value given here will be included in the response. May be used to distinguish requests.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 80
def requestid(value)
  merge(requestid: value.to_s)
end
responselanginfo() click to toggle source

Include the languages used for uselang and errorlang in the result.

@return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 101
def responselanginfo()
  merge(responselanginfo: 'true')
end
servedby() click to toggle source

Include the hostname that served the request in the results.

@return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 87
def servedby()
  merge(servedby: 'true')
end
smaxage(value) click to toggle source

Set the s-maxage HTTP cache control header to this many seconds. Errors are never cached.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 43
def smaxage(value)
  merge(smaxage: value.to_s)
end
uselang(value) click to toggle source

Language to use for message translations. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify user to use the current user's language preference, or specify content to use this wiki's content language.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/base.rb, line 117
def uselang(value)
  merge(uselang: value.to_s)
end