Class: MediaWiktory::Wikipedia::Actions::Expandtemplates

Inherits:
Get
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/expandtemplates.rb

Overview

Expands all templates within wikitext.

Usage:

api.expandtemplates.title(value).perform # returns string with raw output
# or
api.expandtemplates.title(value).response # returns output parsed and wrapped into Response object

See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.

All action's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Methods inherited from Get

#perform

Methods inherited from Base

#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url

Methods included from GlobalParams

#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang

Instance Method Details

#generatexmlself

Generate XML parse tree (replaced by prop=parsetree).

Returns:

  • (self)


69
70
71
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 69

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

#includecommentsself

Whether to include HTML comments in the output.

Returns:

  • (self)


62
63
64
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 62

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

#prop(*values) ⇒ self

Which pieces of information to get.

Parameters:

  • values (Array<String>)

    Allowed values: "wikitext" (The expanded wikitext), "categories" (Any categories present in the input that are not represented in the wikitext output), "properties" (Page properties defined by expanded magic words in the wikitext), "volatile" (Whether the output is volatile and should not be reused elsewhere within the page), "ttl" (The maximum time after which caches of the result should be invalidated), "modules" (Any ResourceLoader modules that parser functions have requested be added to the output. Either jsconfigvars or encodedjsconfigvars must be requested jointly with modules), "jsconfigvars" (Gives the JavaScript configuration variables specific to the page), "encodedjsconfigvars" (Gives the JavaScript configuration variables specific to the page as a JSON string), "parsetree" (The XML parse tree of the input).

Returns:

  • (self)


50
51
52
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 50

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end

#revid(value) ⇒ self

Revision ID, for {REVISIONID} and similar variables.

Parameters:

  • value (Integer)

Returns:

  • (self)


42
43
44
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 42

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

#templatesandboxcontentformat(value) ⇒ self

Content format of templatesandboxtext.

Parameters:

  • value (String)

    One of "application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain".

Returns:

  • (self)


119
120
121
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 119

def templatesandboxcontentformat(value)
  _templatesandboxcontentformat(value) or fail ArgumentError, "Unknown value for templatesandboxcontentformat: #{value}"
end

#templatesandboxcontentmodel(value) ⇒ self

Content model of templatesandboxtext.

Parameters:

  • value (String)

    One of "GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto".

Returns:

  • (self)


106
107
108
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 106

def templatesandboxcontentmodel(value)
  _templatesandboxcontentmodel(value) or fail ArgumentError, "Unknown value for templatesandboxcontentmodel: #{value}"
end

#templatesandboxprefix(*values) ⇒ self

Template sandbox prefix, as with Special:TemplateSandbox.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


77
78
79
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 77

def templatesandboxprefix(*values)
  values.inject(self) { |res, val| res._templatesandboxprefix(val) }
end

#templatesandboxtext(value) ⇒ self

Parse the page using this page content in place of the page named by templatesandboxtitle.

Parameters:

  • value (String)

Returns:

  • (self)


98
99
100
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 98

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

#templatesandboxtitle(value) ⇒ self

Parse the page using templatesandboxtext in place of the contents of the page named here.

Parameters:

  • value (String)

Returns:

  • (self)


90
91
92
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 90

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

#text(value) ⇒ self

Wikitext to convert.

Parameters:

  • value (String)

Returns:

  • (self)


34
35
36
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 34

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

#title(value) ⇒ self

Title of page.

Parameters:

  • value (String)

Returns:

  • (self)


26
27
28
# File 'lib/mediawiktory/wikipedia/actions/expandtemplates.rb', line 26

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