Page MenuHomePhabricator

Add to <body> a class named after the root basepage to specify per-page/book CSS
Closed, ResolvedPublic

Description

Currently, the only ways to provide CSS that is to apply to one or a few pages [other than specific extensions for the purpose] are:

  • Load them with javascript (compatibility issues)
  • Place them in [common].css, with page classname selectors (does not work well with Translate extension or I18N, still requires modifying common.css with projectwide effects)

The Translate extension in particular causes issues because the language of the page is reflected in the page classname selector (e.g. .page-Foo vs .page-Foo_de)

Details

Related Gerrit Patches:
mediawiki/core : masterAdd root title class to <body>

Event Timeline

coren created this task.Jan 9 2016, 4:01 AM
coren raised the priority of this task from to Needs Triage.
coren updated the task description. (Show Details)
coren added a subscriber: coren.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptJan 9 2016, 4:01 AM

I think this task is mistagged. Translate provides translation tools, not generic i18n support which should be in core.

The Translate extension in particular causes issues because the language of the page is reflected in the page classname selector (e.g. .page-Foo vs .page-Foo_de)

This has nothing to do with Translate, the same happens with any subpage e.g. https://www.mediawiki.org/wiki/Manual:$wgSpamRegex/fr

I guess core could add another class that be the same on all subpages, like .page-Foo-subpage.

Nemo_bis updated the task description. (Show Details)Jan 22 2016, 10:22 PM
Nemo_bis set Security to None.

The easiest path to this will probably be actually implementing T483: RfC: Allow styling in templates.

He7d3r added a subscriber: He7d3r.EditedFeb 8 2016, 7:01 PM

I guess core could add another class that be the same on all subpages, like .page-Foo-subpage.

...and that would serve as another workaround for "Per book CSS" (T17075)

Nemo_bis renamed this task from Provide a method to specity per-page CSS to Add to <body> a class named after the root basepage to specity per-page/book CSS.Feb 12 2016, 2:50 PM

I guess core could add another class that be the same on all subpages, like .page-Foo-subpage.

...and that would serve as a workaround for "Per book CSS" (T17075)

Good point!

He7d3r renamed this task from Add to <body> a class named after the root basepage to specity per-page/book CSS to Add to <body> a class named after the root basepage to specify per-page/book CSS.Feb 12 2016, 4:24 PM
coren claimed this task.Apr 3 2016, 7:20 AM

I have an opportunity to work on this while at the Hackathon; with luck I may be able to submit a changeset today.

Change 281253 had a related patch set uploaded (by coren):
Add root title class to <body>

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

coren added a comment.EditedApr 3 2016, 8:22 AM

I guess core could add another class that be the same on all subpages, like .page-Foo-subpage.

The current patch provides for .pageroot-Foo that is fixed for Foo and all its subpages. The usecase of -subpage can be handled by having class selectors in the form:

.pageroot-Foo :not(.page-Foo)

So, afaict, that completely covers the book usecase?

Change 281253 merged by jenkins-bot:
Add root title class to <body>

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

Nemo_bis closed this task as Resolved.Apr 20 2016, 6:13 AM

Assuming resolved. I trust @He7d3r will test whether this fixes the Wikibooks request as well. :)