Class: MediaWiktory::Wikipedia::Actions::Mobileview

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

Overview

Returns data needed for mobile views.

Usage:

api.mobileview.page(value).perform # returns string with raw output
# or
api.mobileview.page(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

#maxlen(value) ⇒ self

Pretend all text result is one string, and limit result to this length.

Parameters:

  • value (Integer)

Returns:

  • (self)


133
134
135
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 133

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

#noheadingsself

Don't include headings in output.

Returns:

  • (self)


103
104
105
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 103

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

#noimagesself

Return HTML without images.

Returns:

  • (self)


96
97
98
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 96

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

#notransformself

Don't transform HTML into mobile-specific version.

Returns:

  • (self)


110
111
112
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 110

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

#offset(value) ⇒ self

Pretend all text result is one string, and return the substring starting at this point.

Parameters:

  • value (Integer)

Returns:

  • (self)


125
126
127
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 125

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

#onlyrequestedsectionsself

Return only requested sections even with prop=sections.

Returns:

  • (self)


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

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

#page(value) ⇒ self

Title of page to process.

Parameters:

  • value (String)

Returns:

  • (self)


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

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

#pageprops(value) ⇒ self

What page properties to return, a pipe ("|") separated list or "*" for all properties.

Parameters:

  • value (String)

Returns:

  • (self)


81
82
83
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 81

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

#prop(*values) ⇒ self

Which information to get:

Parameters:

  • values (Array<String>)

    Allowed values: "text" (HTML of selected sections), "sections" (Information about all sections on the page), "normalizedtitle" (Normalized page title), "lastmodified" (ISO 8601 timestamp for when the page was last modified, e.g. "2014-04-13T22:42:14Z"), "lastmodifiedby" (Information about the user who modified the page last), "revision" (Return the current revision ID of the page), "protection" (Information about protection level), "editable" (Whether the current user can edit this page. This includes all factors for logged-in users but not blocked status for anons), "languagecount" (Number of languages that the page is available in), "hasvariants" (Whether or not the page is available in other language variants), "displaytitle" (The rendered title of the page, with {DISPLAYTITLE} and such applied), "pageprops" (Page properties).

Returns:

  • (self)


55
56
57
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 55

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

#redirect(value) ⇒ self

Whether redirects should be followed.

Parameters:

  • value (String)

    One of "yes", "no".

Returns:

  • (self)


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

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

#revision(value) ⇒ self

Request a specific revision.

Parameters:

  • value (Integer)

Returns:

  • (self)


141
142
143
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 141

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

#sectionprop(*values) ⇒ self

What information about sections to get.

Parameters:

  • values (Array<String>)

    Allowed values: "toclevel", "level", "line", "number", "index", "fromtitle", "anchor".

Returns:

  • (self)


68
69
70
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 68

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

#sections(value) ⇒ self

Pipe-separated list of section numbers for which to return text. "all" can be used to return for all. Ranges in format "1-4" mean get sections 1,2,3,4. Ranges without second number, e.g. "1-" means get all until the end. "references" can be used to specify that all sections containing references should be returned.

Parameters:

  • value (String)

Returns:

  • (self)


47
48
49
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 47

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

#thumbheight(value) ⇒ self

Maximum thumbnail height.

Parameters:

  • value (Integer)

Returns:

  • (self)


149
150
151
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 149

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

#thumbsize(value) ⇒ self

Maximum thumbnail dimensions.

Parameters:

  • value (Integer)

Returns:

  • (self)


165
166
167
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 165

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

#thumbwidth(value) ⇒ self

Maximum thumbnail width.

Parameters:

  • value (Integer)

Returns:

  • (self)


157
158
159
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 157

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

#variant(value) ⇒ self

Convert content into this language variant.

Parameters:

  • value (String)

Returns:

  • (self)


89
90
91
# File 'lib/mediawiktory/wikipedia/actions/mobileview.rb', line 89

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