Module: MediaWiktory::Wikipedia::Actions::GlobalParams

Included in:
Base
Defined in:
lib/mediawiktory/wikipedia/actions/base.rb

Overview

Global setup methods included into every action through Base.

Instance Method Summary collapse

Instance Method Details

#assert(value) ⇒ self

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

Parameters:

  • value (String)

    One of "user", "bot".

Returns:

  • (self)


59
60
61
# 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) ⇒ self

Verify the current user is the named user.

Parameters:

  • value (String)

Returns:

  • (self)


72
73
74
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 72

def assertuser(value)
  merge(assertuser: value.to_s)
end

#centralauthtoken(value) ⇒ self

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).

Parameters:

  • value (String)

Returns:

  • (self)


153
154
155
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 153

def centralauthtoken(value)
  merge(centralauthtoken: value.to_s)
end

#curtimestampself

Include the current timestamp in the result.

Returns:

  • (self)


94
95
96
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 94

def curtimestamp()
  merge(curtimestamp: 'true')
end

#errorformat(value) ⇒ self

Format to use for warning and error text output.

Parameters:

  • 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).

Returns:

  • (self)


125
126
127
# 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) ⇒ self

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.

Parameters:

  • value (String)

Returns:

  • (self)


138
139
140
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 138

def errorlang(value)
  merge(errorlang: value.to_s)
end

#errorsuselocalself

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

Returns:

  • (self)


145
146
147
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 145

def errorsuselocal()
  merge(errorsuselocal: 'true')
end

#format(value) ⇒ self

The format of the output.

Parameters:

  • value (Symbol)

    Selecting an option includes tweaking methods from corresponding module:

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

Returns:

  • (self)


22
23
24
# 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) ⇒ self

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

Parameters:

  • value (Integer)

Returns:

  • (self)


51
52
53
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 51

def maxage(value)
  merge(maxage: value.to_s)
end

#maxlag(value) ⇒ self

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.

Parameters:

  • value (Integer)

Returns:

  • (self)


35
36
37
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 35

def maxlag(value)
  merge(maxlag: value.to_s)
end

#origin(value) ⇒ self

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).

Parameters:

  • value (String)

Returns:

  • (self)


109
110
111
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 109

def origin(value)
  merge(origin: value.to_s)
end

#requestid(value) ⇒ self

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

Parameters:

  • value (String)

Returns:

  • (self)


80
81
82
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 80

def requestid(value)
  merge(requestid: value.to_s)
end

#responselanginfoself

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

Returns:

  • (self)


101
102
103
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 101

def responselanginfo()
  merge(responselanginfo: 'true')
end

#servedbyself

Include the hostname that served the request in the results.

Returns:

  • (self)


87
88
89
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 87

def servedby()
  merge(servedby: 'true')
end

#smaxage(value) ⇒ self

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

Parameters:

  • value (Integer)

Returns:

  • (self)


43
44
45
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 43

def smaxage(value)
  merge(smaxage: value.to_s)
end

#uselang(value) ⇒ self

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.

Parameters:

  • value (String)

Returns:

  • (self)


117
118
119
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 117

def uselang(value)
  merge(uselang: value.to_s)
end