Open DannyS712 opened 4 years ago
Some analysis:
scribunto
(page won't get saved if there's a syntax error, and also templates and categories don't work even if commented out) has been handled by Amorymeltzer in #515, without any changes were made to morebits. I guess it would have been better to add a .setEditDocIfLua
option to morebits.wiki.page (when used before .load()
, it would cause the /doc page to be loaded), for better extensibility. (The string "doc" varies from wiki to wiki; such strings are not used in morebits, except in error/status messages. But I guess this isn't an issue as all wikis use a copy of morebits rather than load it from enwiki.)
for sanitized-css
(again, the page won't get saved if there's a syntax error, but at least templates and cats work if commented out) If we want to automate the commenting out via morebits,
.prepend()
and .append()
. for javascript
and css
, the only Twinkle modules that edit them are speedy and xfd. If the page is anyway being nominated for deletion, it is not an issue that the script/stylesheet is being broken due to the syntax error. But if a comment-out option is being added for the sake of sanitized-css, it would benefit here too.
for json
, heck the page can't be saved with a syntax error, and no type of comments are allowed in JSON. It seems there is just no way to tag such a page for deletion!
for MassMessageListContent
:
edit
function, but the trouble is that API:Edit doesn't work. I think the way to handle this is by adding a new private function fnEditMassMessageListDescription
to morebits.wiki.page. We can note the content model from load API output. If it's a massmessagelist, extract only the description (throwing away the list of names) from the load API output and save that to ctx.pageText
. When .save()
is called, first check if the contentmodel is MassMessageListContent. If so, exit from save(), and go into fnEditMassMessageListDescription.
While .append()
ing or .prepend()
ing, if the page is same as the page being viewed, the contentmodel is available via mw.config
. A condition can be added to fnCanUseMwEditToken
to force a page load.
Problem arises if the page isn't same as page being viewed. In this case, we don't get to know the contentmodel beforehand. The edit API will fail with invalid-content-data
("Invalid content data") error, which tells us that the content model is either MMS or json
(because other content models just work). A hacky workaround would be to just load the page when such an error is encountered - since this means the contentmodel would now be known and if it's MMS, the edit would subsequently be handled correctly.for flow boards - not there on enwiki. No idea about them.
Patch for editing mass message descriptions via api just got +2 and will be deployed next week, at which point the ApiEditMassMessageList class can be used - as long as Twinkle doesn't try to specify users that should be added or removed, only the description will change.
@DannyS712 Can you link that?
/* foo */