Page MenuHomePhabricator

Allow previewing a specific page when editing site JS/CSS (e.g. Common.css, Vector.js)
Closed, ResolvedPublic

Description

When one edits templates, there is a small box below the edit area which allows one to preview any page as it would look like after submitting the changes (from the TemplateSandbox extension)

Preview page with this template
Page title: [______________________________] [Show preview]

A similar feature should be made for Common.css/js and similar css/js pages which affect the whole wiki.

Event Timeline

He7d3r created this task.Sep 13 2015, 5:18 PM
He7d3r raised the priority of this task from to Needs Triage.
He7d3r updated the task description. (Show Details)
He7d3r added a subscriber: He7d3r.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 13 2015, 5:18 PM
Legoktm updated the task description. (Show Details)Sep 13 2015, 11:23 PM
Legoktm set Security to None.
Krinkle updated the task description. (Show Details)Sep 14 2015, 12:18 AM
Anomie triaged this task as Low priority.Sep 14 2015, 4:27 PM
Anomie added a subscriber: Anomie.Sep 14 2015, 4:30 PM

This is something of an interesting idea, although it's expanding the scope of TemplateSandbox beyond transclusions. It would require that there be some way to tell ResourceLoader to use arbitrary text in place of the on-wiki js or css page it would normally use, which might be difficult since RL's work actually happens outside of the parse.

The ResourceLoaderUserModule class takes an excludepage parameter that removes it from the RL module and then the new JavaScript content is embedded in the page source (see OutputPage L3090).

ori moved this task from Inbox to Backlog on the MediaWiki-ResourceLoader board.Sep 14 2015, 6:19 PM
Anomie claimed this task.Feb 28 2017, 9:23 PM

The ResourceLoaderUserModule class takes an excludepage parameter that removes it from the RL module and then the new JavaScript content is embedded in the page source (see OutputPage L3090).

Yeah, I see that. I'm going to have to generalize it heavily to make it useful for this.

Would moving it to the parent ResourceLoaderWikiModule class be enough?

Anomie added a comment.Mar 1 2017, 4:43 PM

The part that really needs generalization is how OutputPage currently has special exceptions for the 'user' and 'user.styles' modules and edits of user JS/CSS in order to set that parameter. The plan I'm working on at the moment is roughly:

  • ResourceLoaderContext is able to map Titles to Content, something like ParserOptions does for the Parser with getCurrentRevisionCallback().
    • Actually it's DerivativeResourceLoaderContext that will do this, the ResourceLoaderContext version will be hard-coded for "no mappings".
  • ResourceLoaderClientHtml asks each module whether it uses the mappings in the context object that it's using for the request. If so, it embeds the whole module exactly as it does already for 'private' modules.
  • OutputPage no longer does any special casing. It just gets the Title-to-Content mapping injected by EditPage or TemplateSandbox and passes it into the RL context it passes to ResourceLoaderClientHtml.

I've already got some code started for this plan, although I went a wrong direction (passing an array of Title ⇒ Content instead of a callback for the first bullet) that I need to fix.

Change 340768 had a related patch set uploaded (by Anomie):
[mediawiki/core] Generalize ResourceLoader 'excludepage' functionality

https://gerrit.wikimedia.org/r/340768

Change 340769 had a related patch set uploaded (by Anomie):
[mediawiki/extensions/TemplateSandbox] Use new OutputPage::addContentOverride to allow previewing edits to JS/CSS

https://gerrit.wikimedia.org/r/340769

Magol added a subscriber: Magol.Feb 5 2018, 7:54 AM
Restricted Application added a project: Performance-Team. · View Herald TranscriptFeb 5 2018, 7:54 AM
Imarlier moved this task from Inbox to Radar on the Performance-Team board.Feb 5 2018, 9:12 PM
Imarlier edited projects, added Performance-Team (Radar); removed Performance-Team.

Change 340768 merged by jenkins-bot:
[mediawiki/core@master] Generalize ResourceLoader 'excludepage' functionality

https://gerrit.wikimedia.org/r/340768

Change 340769 merged by jenkins-bot:
[mediawiki/extensions/TemplateSandbox@master] Use new OutputPage::addContentOverride to allow previewing edits to JS/CSS

https://gerrit.wikimedia.org/r/340769

Tgr added a subscriber: Tgr.Apr 25 2018, 10:20 AM

With the two patches merged, the functionality now exists, although there is no UI for it the way there is for the template editing page (Special:TemplateStyle works, and so does previewing the edited page itself). Should that be tracked here or in a separate task?

Anomie added a comment.EditedApr 25 2018, 3:13 PM

Could go either way. If you want to track it here, though, remove me as the assignee please. At least until a plan is made.