Page MenuHomePhabricator

Introduce MediaWiki:Mainpage.css
Closed, DeclinedPublic

Description

Many main pages use inline styles and templates to style
Or they add classes to the MediaWiki:Common.css page specific just to the main page and loaded on just the main page.

Most main pages look terrible on mobile and are difficult to fix. e.g. https://www.wikidata.org/wiki/Wikidata:Main_Page
We have a bunch of code in MobileFrontend to workaround this but I'm keen to destroy the code.

We should thus introduce MediaWiki:Mainpage.css which is only loaded on the main page with the ResourceLoader other group set. This would allow us to use media queries on the main page and remove this code debt from MobileFrontend.

Any thoughts? Any problems with such an approach?

Event Timeline

Jdlrobson raised the priority of this task from to Needs Triage.
Jdlrobson updated the task description. (Show Details)
Jdlrobson changed Security from none to None.
Jdlrobson added a project: Web-Team-Backlog.

Doesn't sound unreasonable to me. By the way, the Polish Wikipedia currently has a default-on gadget that implements styles for the main page (which is as mobile-friendly as it gets, I think, and almost free of inline styling). https://pl.wikipedia.org/wiki/MediaWiki:Gadget-main-page.css

(Somwhat related: T483: RfC: Allow styling in templates.)

+9000

I would like some sandbox mechanism though, that allows me to test CSS wihtout having to load it manually via importStylesheet, withCSS or some other hack.

(A default gadget just loads indiscriminatelyon all pages, just as Common.css, so not a good idea.)

See also T32405 - this would allow us to deprecate a bunch of code debt we have in MobileFrontend.

There might be more than one page, where the main page CSS needs to be loaded:

Perhaps this can be solved by use of some keyword or link, making it more universally applicable in the long run, ie. [[css:MediaWiki:Mainpage.css]].

Should I create an RFC for this?

Yes please.

Krinkle closed this task as Declined.EditedJul 8 2015, 2:11 PM
Krinkle claimed this task.
Krinkle subscribed.

We will not be creating new legacy css/js pages. Please resolve this by using gadgets instead.

The problem with these pages is that they need hardcoded infrastructure in MediaWiki core, tend to be loaded in the global scope, and have no well-defined behaviour for when and how they are expected to be loaded. Gadgets are more mature in that sense.

At this time gadgets do not yet have the capability to be enqueued in the loader for specific page contexts only, but that's something we can work on. Let's file a task for that instead.

As an alternative for the interim, one could easily add a hook in wmf-config or WikimediaMessages that will check whether the page isMainPage() and that a module ext.gadget.mainpage exists, and then pass it to addModules() or addModuleStyles().

We already have several extensions that can load page-bound CSS. Why are these not used?

We already have several extensions that can load page-bound CSS. Why are these not used?

I'm not sure I understand what you mean. What existing extensions are you referring to? This is task is about enabling wikis to author a stylesheet on-wiki that is loaded on the Main Page only.

The problem with these pages is that they need hardcoded infrastructure in MediaWiki core, tend to be loaded in the global scope, and have no well-defined behaviour for when and how they are expected to be loaded. Gadgets are more mature in that sense.

This is just a CSS page, so global scope isn't an issue. The behavior for this page seems pretty obvious, it's whenever $title->isMainPage() is true.

At this time gadgets do not yet have the capability to be enqueued in the loader for specific page contexts only, but that's something we can work on. Let's file a task for that instead.

That's T63007: Allow specifying when a gadget should load (action, namespace, content model), which is doable in 2.0.

As an alternative for the interim, one could easily add a hook in wmf-config or WikimediaMessages that will check whether the page isMainPage() and that a module ext.gadget.mainpage exists, and then pass it to addModules() or addModuleStyles().

Let's not add more hacks upon hacks please.

Most of the styling should be done using TemplateStyles. The rest (e.g. styles affecting the page title) can be put in a gadget once T241524 is done (which is not bound to the main page, so the necessary styles can be loaded on localized main pages, yesterday/tomorrow pages, sandboxes and the like as well).