Page MenuHomePhabricator

Add class="ns-talk" / "ns-subject" to <body>
Closed, ResolvedPublic


Author: happy_melon

Per DavidGothberg's suggestion at it would be sensible to add another class to the attributes of <body> in all pages: "ns-talk" for all odd namespaces, and something like "ns-subject" for all even namespaces. I expect this would be trivial in both performance and coding time.

Version: unspecified
Severity: enhancement



Event Timeline

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

I suggest WONTFIX. The rationale for adding this is rather limited, as .ns-1, .ns-3, etc is perfectly valid CSS. Unlike bug 15052 which is at least arguably useful. The body class has _quite_ a few classes on it already, and tacking another one (esp. one with such limited actual use) seems like a waste.

The data is already there, use it.

The set of namespaces is potentially open-ended; new custom (and new standard!) namespaces could be added at any time, requiring an infinite list of all odd numbers to cover your bases. ;)

Much simpler to have a distinct marker.

ayg wrote:

Not infinite, just 2^30 or so. ;) I guess it's simpler to have this if a lot of user CSS relies on it, since that can't be so easily tracked down and updated, but it seems excessive. Then again, there's technically no cost to having loads of extra classes, I suppose.

alexsm333 wrote:

Note that the existence of multipurpose ns-4 "Project" namespace (used for discussions, guides, essays, etc) makes the "ns-talk" proposal a lot less useful.

happy_melon wrote:

I don't remember putting that in the user manual... :D

It's only tradition that results in multipurpose use of ns-4; it's rather counterintuitive given the rigidity with which we control the use of other namespaces. In an ideal world ns-4 and ns-5 would be as clearly delimited as the others. But that's besides the point.

For a real example, I have an inkling that what DavidGothberg wants to do is unite all the messagebox templates on ([[Template:Ambox]], [[Template:Imbox]], [[Template:Tmbox]], etc), and present one template with a display switched by CSS, not by parser functions. [[Template:Tmbox]] is intended to be used in *all* our even namespaces (for reference, [[Template:Ombox]] is the style prescribed for ns-4). This would instantly give namespace-switching capabilities to all our messageboxes, which is something we've been struggling to do without creating a monster of a metatemplate. So in this example, the presence of the "multipurpose" ns-4 is of no relevance.

happy_melon wrote:

If anyone does want to do this, I think it's as easy as adding:

($wgTitle->getNamespace() % 2 ? "ns-talk" : "ns-subject").' '.

to the end of line 549 in /trunk/phase3/includes/Skin.php (one day I'm going to have to learn how to write proper patches!)

ayg wrote:

MWNamespace::isTalk( $wgTitle->getNamespace ) ? 'ns-talk' : 'ns-subject' would be more correct, although they might be functionally similar at the moment. Anyway, yes, it's trivial to do, the question is whether we want it.

$wgTitle->isTalkPage() would be even better. :)

And yes, we want it. There's no other reliable way to apply CSS to all talk pages or all subject pages. (Listing every possible talk namespace is not an option, as that's an open-ended set.)

sxwiki wrote:

Patch to add ns-talk or ns-subject to body

This patch should do what you guys want. Ended up having to modify a couple other files as well to get it to appear on all skins.