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
-
#assert(value) ⇒ self
Verify the user is logged in if set to user, or has the bot user right if bot.
-
#assertuser(value) ⇒ self
Verify the current user is the named user.
-
#centralauthtoken(value) ⇒ self
When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user.
-
#curtimestamp ⇒ self
Include the current timestamp in the result.
-
#errorformat(value) ⇒ self
Format to use for warning and error text output.
-
#errorlang(value) ⇒ self
Language to use for warnings and errors.
-
#errorsuselocal ⇒ self
If given, error texts will use locally-customized messages from the MediaWiki namespace.
-
#format(value) ⇒ self
The format of the output.
-
#maxage(value) ⇒ self
Set the max-age HTTP cache control header to this many seconds.
-
#maxlag(value) ⇒ self
Maximum lag can be used when MediaWiki is installed on a database replicated cluster.
-
#origin(value) ⇒ self
When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain.
-
#requestid(value) ⇒ self
Any value given here will be included in the response.
-
#responselanginfo ⇒ self
Include the languages used for uselang and errorlang in the result.
-
#servedby ⇒ self
Include the hostname that served the request in the results.
-
#smaxage(value) ⇒ self
Set the s-maxage HTTP cache control header to this many seconds.
-
#uselang(value) ⇒ self
Language to use for message translations.
Instance Method Details
#assert(value) ⇒ self
Verify the user is logged in if set to user, or has the bot user right if bot.
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.
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).
153 154 155 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 153 def centralauthtoken(value) merge(centralauthtoken: value.to_s) end |
#curtimestamp ⇒ self
Include the current timestamp in the result.
94 95 96 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 94 def () merge(curtimestamp: 'true') end |
#errorformat(value) ⇒ self
Format to use for warning and error text output.
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.
138 139 140 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 138 def errorlang(value) merge(errorlang: value.to_s) end |
#errorsuselocal ⇒ self
If given, error texts will use locally-customized messages from the MediaWiki namespace.
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.
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.
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.
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).
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.
80 81 82 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 80 def requestid(value) merge(requestid: value.to_s) end |
#responselanginfo ⇒ self
Include the languages used for uselang and errorlang in the result.
101 102 103 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 101 def responselanginfo() merge(responselanginfo: 'true') end |
#servedby ⇒ self
Include the hostname that served the request in the results.
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.
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.
117 118 119 |
# File 'lib/mediawiktory/wikipedia/actions/base.rb', line 117 def uselang(value) merge(uselang: value.to_s) end |