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
@private
# 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
@private
# 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
@private
# 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
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
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
Mark this edit as a bot edit.
@return [self]
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 100 def bot() merge(bot: 'true') end
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
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
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
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
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
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 edit.
@return [self]
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 86 def minor() merge(minor: 'true') end
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
Non-minor edit.
@return [self]
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 93 def notminor() merge(notminor: 'true') end
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
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
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
Automatically resolve redirects.
@return [self]
# File lib/mediawiktory/wikipedia/actions/edit.rb, line 211 def redirect() merge(redirect: 'true') end
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
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
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
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
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 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
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 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
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
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
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
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