Class: MediaWiktory::Wikipedia::Actions::Import

Inherits:
Post
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/import.rb

Overview

Import a page from another wiki, or from an XML file.

Usage:

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

#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

#fullhistoryself

For interwiki imports: import the full history, not just the current version.

Returns:

  • (self)


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

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

#interwikipage(value) ⇒ self

For interwiki imports: page to import.

Parameters:

  • value (String)

Returns:

  • (self)


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

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

#interwikisource(value) ⇒ self

For interwiki imports: wiki to import from.

Parameters:

  • value (String)

    One of "meta", "nost", "de", "es", "fr", "it", "pl", "outreachwiki", "test2wiki".

Returns:

  • (self)


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

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

#namespace(value) ⇒ self

Import to this namespace. Cannot be used together with rootpage.

Parameters:

  • value (String)

    One of "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "446", "447", "710", "711", "828", "829", "2300", "2301", "2302", "2303".

Returns:

  • (self)


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

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

#rootpage(value) ⇒ self

Import as subpage of this page. Cannot be used together with namespace.

Parameters:

  • value (String)

Returns:

  • (self)


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

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

#summary(value) ⇒ self

Log entry import summary.

Parameters:

  • value (String)

Returns:

  • (self)


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

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

#tags(*values) ⇒ self

Change tags to apply to the entry in the import log and to the null revision on the imported pages.

Parameters:

  • values (Array<String>)

    Allowed values: "ProveIt edit", "WPCleaner", "huggle", "large plot addition".

Returns:

  • (self)


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

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

#templatesself

For interwiki imports: import all included templates as well.

Returns:

  • (self)


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

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

#token(value) ⇒ self

A "csrf" token retrieved from action=query&meta=tokens

Parameters:

  • value (String)

Returns:

  • (self)


111
112
113
# File 'lib/mediawiktory/wikipedia/actions/import.rb', line 111

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

#xml(value) ⇒ self

Uploaded XML file.

Parameters:

  • value (String)

Returns:

  • (self)


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

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