class MediaWiktory::Wikipedia::Actions::Edit

Create and edit pages.

Usage:

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

See {Base} for generic explanation of working with MediaWiki actions and {MediaWiktory::Wikipedia::Response} for working with action responses.

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

Public Instance Methods

_contentformat(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 224
def _contentformat(value)
  defined?(super) && super || ["application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain"].include?(value.to_s) && merge(contentformat: value.to_s)
end
_contentmodel(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 237
def _contentmodel(value)
  defined?(super) && super || ["GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto"].include?(value.to_s) && merge(contentmodel: value.to_s)
end
_tags(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 79
def _tags(value)
  defined?(super) && super || ["ProveIt edit", "WPCleaner", "huggle", "large plot addition"].include?(value.to_s) && merge(tags: value.to_s, replace: false)
end
_watchlist(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 164
def _watchlist(value)
  defined?(super) && super || ["watch", "unwatch", "preferences", "nochange"].include?(value.to_s) && merge(watchlist: value.to_s)
end
appendtext(value) click to toggle source

Add this text to the end of the page. Overrides text.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 188
def appendtext(value)
  merge(appendtext: value.to_s)
end
basetimestamp(value) click to toggle source

Timestamp of the base revision, used to detect edit conflicts. May be obtained through action=query&prop=revisions&rvprop=timestamp.

@param value [Time] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 108
def basetimestamp(value)
  merge(basetimestamp: value.iso8601)
end
bot() click to toggle source

Mark this edit as a bot edit.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 100
def bot()
  merge(bot: 'true')
end
captchaid(value) click to toggle source

CAPTCHA ID from previous request

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 261
def captchaid(value)
  merge(captchaid: value.to_s)
end
captchaword(value) click to toggle source

Answer to the CAPTCHA

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 253
def captchaword(value)
  merge(captchaword: value.to_s)
end
contentformat(value) click to toggle source

Content serialization format used for the input text.

@param value [String] One of “application/json”, “text/x-wiki”, “text/javascript”, “text/css”, “text/plain”. @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 219
def contentformat(value)
  _contentformat(value) or fail ArgumentError, "Unknown value for contentformat: #{value}"
end
contentmodel(value) click to toggle source

Content model of the new content.

@param value [String] One of “GadgetDefinition”, “SecurePoll”, “MassMessageListContent”, “JsonSchema”, “wikitext”, “javascript”, “json”, “css”, “text”, “Scribunto”. @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 232
def contentmodel(value)
  _contentmodel(value) or fail ArgumentError, "Unknown value for contentmodel: #{value}"
end
createonly() click to toggle source

Don't edit the page if it exists already.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 130
def createonly()
  merge(createonly: 'true')
end
md5(value) click to toggle source

The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated. If set, the edit won't be done unless the hash is correct.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 172
def md5(value)
  merge(md5: value.to_s)
end
minor() click to toggle source

Minor edit.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 86
def minor()
  merge(minor: 'true')
end
nocreate() click to toggle source

Throw an error if the page doesn't exist.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 137
def nocreate()
  merge(nocreate: 'true')
end
notminor() click to toggle source

Non-minor edit.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 93
def notminor()
  merge(notminor: 'true')
end
pageid(value) click to toggle source

Page ID of the page to edit. Cannot be used together with title.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 34
def pageid(value)
  merge(pageid: value.to_s)
end
prependtext(value) click to toggle source

Add this text to the beginning of the page. Overrides text.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 180
def prependtext(value)
  merge(prependtext: value.to_s)
end
recreate() click to toggle source

Override any errors about the page having been deleted in the meantime.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 123
def recreate()
  merge(recreate: 'true')
end
redirect() click to toggle source

Automatically resolve redirects.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 211
def redirect()
  merge(redirect: 'true')
end
section(value) click to toggle source

Section number. 0 for the top section, new for a new section.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 42
def section(value)
  merge(section: value.to_s)
end
sectiontitle(value) click to toggle source

The title for a new section.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 50
def sectiontitle(value)
  merge(sectiontitle: value.to_s)
end
starttimestamp(value) click to toggle source

Timestamp when the editing process began, used to detect edit conflicts. An appropriate value may be obtained using curtimestamp when beginning the edit process (e.g. when loading the page content to edit).

@param value [Time] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 116
def starttimestamp(value)
  merge(starttimestamp: value.iso8601)
end
summary(value) click to toggle source

Edit summary. Also section title when section=new and sectiontitle is not set.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 66
def summary(value)
  merge(summary: value.to_s)
end
tags(*values) click to toggle source

Change tags to apply to the revision.

@param values [Array<String>] Allowed values: “ProveIt edit”, “WPCleaner”, “huggle”, “large plot addition”. @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 74
def tags(*values)
  values.inject(self) { |res, val| res._tags(val) or fail ArgumentError, "Unknown value for tags: #{val}" }
end
text(value) click to toggle source

Page content.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 58
def text(value)
  merge(text: value.to_s)
end
title(value) click to toggle source

Title of the page to edit. Cannot be used together with pageid.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 26
def title(value)
  merge(title: value.to_s)
end
token(value) click to toggle source

A “csrf” token retrieved from action=query&meta=tokens

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 245
def token(value)
  merge(token: value.to_s)
end
undo(value) click to toggle source

Undo this revision. Overrides text, prependtext and appendtext.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 196
def undo(value)
  merge(undo: value.to_s)
end
undoafter(value) click to toggle source

Undo all revisions from undo to this one. If not set, just undo one revision.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 204
def undoafter(value)
  merge(undoafter: value.to_s)
end
unwatch() click to toggle source

Remove the page from the current user's watchlist.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 151
def unwatch()
  merge(unwatch: 'true')
end
watch() click to toggle source

Add the page to the current user's watchlist.

@return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 144
def watch()
  merge(watch: 'true')
end
watchlist(value) click to toggle source

Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.

@param value [String] One of “watch”, “unwatch”, “preferences”, “nochange”. @return [self]

# File lib/mediawiktory/wikipedia/actions/edit.rb, line 159
def watchlist(value)
  _watchlist(value) or fail ArgumentError, "Unknown value for watchlist: #{value}"
end