Class: MediaWiktory::Wikipedia::Actions::Edit
- Defined in:
- lib/mediawiktory/wikipedia/actions/edit.rb
Overview
Create and edit pages.
Usage:
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 Response for working with action responses.
All action's parameters are documented as its public methods, see below.
Instance Method Summary collapse
-
#appendtext(value) ⇒ self
Add this text to the end of the page.
-
#basetimestamp(value) ⇒ self
Timestamp of the base revision, used to detect edit conflicts.
-
#bot ⇒ self
Mark this edit as a bot edit.
-
#captchaid(value) ⇒ self
CAPTCHA ID from previous request.
-
#captchaword(value) ⇒ self
Answer to the CAPTCHA.
-
#contentformat(value) ⇒ self
Content serialization format used for the input text.
-
#contentmodel(value) ⇒ self
Content model of the new content.
-
#createonly ⇒ self
Don't edit the page if it exists already.
-
#md5(value) ⇒ self
The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated.
-
#minor ⇒ self
Minor edit.
-
#nocreate ⇒ self
Throw an error if the page doesn't exist.
-
#notminor ⇒ self
Non-minor edit.
-
#pageid(value) ⇒ self
Page ID of the page to edit.
-
#prependtext(value) ⇒ self
Add this text to the beginning of the page.
-
#recreate ⇒ self
Override any errors about the page having been deleted in the meantime.
-
#redirect ⇒ self
Automatically resolve redirects.
-
#section(value) ⇒ self
Section number.
-
#sectiontitle(value) ⇒ self
The title for a new section.
-
#starttimestamp(value) ⇒ self
Timestamp when the editing process began, used to detect edit conflicts.
-
#summary(value) ⇒ self
Edit summary.
-
#tags(*values) ⇒ self
Change tags to apply to the revision.
-
#text(value) ⇒ self
Page content.
-
#title(value) ⇒ self
Title of the page to edit.
-
#token(value) ⇒ self
A "csrf" token retrieved from action=query&meta=tokens.
-
#undo(value) ⇒ self
Undo this revision.
-
#undoafter(value) ⇒ self
Undo all revisions from undo to this one.
-
#unwatch ⇒ self
Remove the page from the current user's watchlist.
-
#watch ⇒ self
Add the page to the current user's watchlist.
-
#watchlist(value) ⇒ self
Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.
Methods inherited from Post
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
#appendtext(value) ⇒ self
Add this text to the end of the page. Overrides text.
188 189 190 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 188 def appendtext(value) merge(appendtext: value.to_s) end |
#basetimestamp(value) ⇒ self
Timestamp of the base revision, used to detect edit conflicts. May be obtained through action=query&prop=revisions&rvprop=timestamp.
108 109 110 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 108 def (value) merge(basetimestamp: value.iso8601) end |
#bot ⇒ self
Mark this edit as a bot edit.
100 101 102 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 100 def bot() merge(bot: 'true') end |
#captchaid(value) ⇒ self
CAPTCHA ID from previous request
261 262 263 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 261 def captchaid(value) merge(captchaid: value.to_s) end |
#captchaword(value) ⇒ self
Answer to the CAPTCHA
253 254 255 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 253 def captchaword(value) merge(captchaword: value.to_s) end |
#contentformat(value) ⇒ self
Content serialization format used for the input text.
219 220 221 |
# 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) ⇒ self
Content model of the new content.
232 233 234 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 232 def contentmodel(value) _contentmodel(value) or fail ArgumentError, "Unknown value for contentmodel: #{value}" end |
#createonly ⇒ self
Don't edit the page if it exists already.
130 131 132 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 130 def createonly() merge(createonly: 'true') end |
#md5(value) ⇒ self
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.
172 173 174 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 172 def md5(value) merge(md5: value.to_s) end |
#minor ⇒ self
Minor edit.
86 87 88 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 86 def minor() merge(minor: 'true') end |
#nocreate ⇒ self
Throw an error if the page doesn't exist.
137 138 139 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 137 def nocreate() merge(nocreate: 'true') end |
#notminor ⇒ self
Non-minor edit.
93 94 95 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 93 def notminor() merge(notminor: 'true') end |
#pageid(value) ⇒ self
Page ID of the page to edit. Cannot be used together with title.
34 35 36 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 34 def pageid(value) merge(pageid: value.to_s) end |
#prependtext(value) ⇒ self
Add this text to the beginning of the page. Overrides text.
180 181 182 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 180 def prependtext(value) merge(prependtext: value.to_s) end |
#recreate ⇒ self
Override any errors about the page having been deleted in the meantime.
123 124 125 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 123 def recreate() merge(recreate: 'true') end |
#redirect ⇒ self
Automatically resolve redirects.
211 212 213 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 211 def redirect() merge(redirect: 'true') end |
#section(value) ⇒ self
Section number. 0 for the top section, new for a new section.
42 43 44 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 42 def section(value) merge(section: value.to_s) end |
#sectiontitle(value) ⇒ self
The title for a new section.
50 51 52 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 50 def sectiontitle(value) merge(sectiontitle: value.to_s) end |
#starttimestamp(value) ⇒ self
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).
116 117 118 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 116 def (value) merge(starttimestamp: value.iso8601) end |
#summary(value) ⇒ self
Edit summary. Also section title when section=new and sectiontitle is not set.
66 67 68 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 66 def summary(value) merge(summary: value.to_s) end |
#tags(*values) ⇒ self
Change tags to apply to the revision.
74 75 76 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 74 def (*values) values.inject(self) { |res, val| res.(val) or fail ArgumentError, "Unknown value for tags: #{val}" } end |
#text(value) ⇒ self
Page content.
58 59 60 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 58 def text(value) merge(text: value.to_s) end |
#title(value) ⇒ self
Title of the page to edit. Cannot be used together with pageid.
26 27 28 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 26 def title(value) merge(title: value.to_s) end |
#token(value) ⇒ self
A "csrf" token retrieved from action=query&meta=tokens
245 246 247 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 245 def token(value) merge(token: value.to_s) end |
#undo(value) ⇒ self
Undo this revision. Overrides text, prependtext and appendtext.
196 197 198 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 196 def undo(value) merge(undo: value.to_s) end |
#undoafter(value) ⇒ self
Undo all revisions from undo to this one. If not set, just undo one revision.
204 205 206 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 204 def undoafter(value) merge(undoafter: value.to_s) end |
#unwatch ⇒ self
Remove the page from the current user's watchlist.
151 152 153 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 151 def unwatch() merge(unwatch: 'true') end |
#watch ⇒ self
Add the page to the current user's watchlist.
144 145 146 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 144 def watch() merge(watch: 'true') end |
#watchlist(value) ⇒ self
Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.
159 160 161 |
# File 'lib/mediawiktory/wikipedia/actions/edit.rb', line 159 def watchlist(value) _watchlist(value) or fail ArgumentError, "Unknown value for watchlist: #{value}" end |