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)

Event Timeline

coren raised the priority of this task from to Needs Triage.
coren updated the task description. (Show Details)
coren subscribed.

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.

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

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

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

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

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