Page MenuHomePhabricator

naming of body class "page-Foo_Bar" should ignore pseudo-sub-pages in ns -1
Closed, ResolvedPublic

Description

Author: M8R-cyc3n3

Description:
Here's one example; let's say i want to set all links
pink if i'm on Special:Contributions. Not so easy:

.page-Special_Contributions a { color:pink; }

But if I go to [[Special:Contributions/Some_user]] and
look closely i see that it produces a unique className
like ".page-Special_Contributions_Some_user" for each
"sub-page", despite them not being sub-pages but rather
a short-hand for the "target" parameter cf.
/index.php?title=Special:Contributions&target=Some_user
is a completely identical page except for the user-name
not being part of its body-class.

target-specific skinning of special pages *may* have a
few weird and niche uses, but i doubt it's what most
people would expect or ever want.

Looks like the cleanest way is to fulfill the example
exercise is to inject css via js? Poor.

if(wgPageName=="Special:Contributions")

appendCSS("a { color:pink; }");

Well i did notice that wgPageName never includes the
user-name or anything else after the slash in the url
of a "Special:" page.

Surely this and the body-class ought, at a minimum, to
be mutually consistent...?


Version: unspecified
Severity: minor

Details

Reference
bz23315

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:00 PM
bzimport set Reference to bz23315.
bzimport added a subscriber: Unknown Object (MLST).

I agree that this is a bug, especially given the inconsistency between Special:Contributions/User and Special:Contributions?target=User.

On the other hand, I _can_ think of some few legitimate uses for having special page subpages in the class name, like [[Special:Watchlist/edit]], [[Special:UserLogin/signup]] or even [[Special:Contributions/newbies]]. I suppose we could always provide two class names, one with and one without subpages.

Alternatively, we could leave the page-Foo classes as they are, and add an extra class for special pages (maybe "special-Contributions"). This would also be a good opportunity to use the canonical instead of the localized name.

Fixed in r81604: special pages now have an extra "special-Whatever" body class based on the canonical special page name without subpages.

M8R-cyc3n3 wrote:

On the other hand, I _can_ think of some few legitimate uses for having
special page subpages in the class name, like [[Special:Watchlist/edit]],
[[Special:UserLogin/signup]] or even [[Special:Contributions/newbies]]. I
suppose we could always provide two class names, one with and one without
subpages.

would that apply to pages in namespaces where "real" sub-pages are allowed,
i.e. would [[Wikipedia:Arbitration/Requests/Enforcement/Archive71]] get the
following body-class names:

page-Wikipedia_Arbitration
page-Wikipedia_Arbitration_Requests
page-Wikipedia_Arbitration_Requests_Enforcement
page-Wikipedia_Arbitration_Requests_Enforcement_Archive71