Page MenuHomePhabricator

Add a CSS class to target IP user pages
Closed, DeclinedPublic

Description

Author: rememberthedot

Description:
Please add a CSS class that targets IP user pages. This would be useful for applying custom CSS rules to IP user pages. For example, a user could choose to set "visibility:hidden" on all IP user page links, because IP addresses generally do not use user pages. The CSS to do that could be:

.ns-3.ip-userpage #ca-nstab-user a {

visibility: hidden;

}

Or the following could be used to make gray, but not remove, links to nonexistant user pages:
.ns-3.ip-userpage #ca-nstab-user.new a {

color: #7D7D7D;

}

I've created a patch, based on MediaWiki 1.11.0, that provides this behavior. It adds "ip-userpage" to <body>'s class attribute.

Since this isn't a major change, hopefully you developers will be more willing to implement it ;-)


Version: unspecified
Severity: enhancement

Details

Reference
bz12509

Event Timeline

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

rememberthedot wrote:

SkinTemplate patch

attachment SkinTemplate patch.txt ignored as obsolete

rememberthedot wrote:

MonoBook.php patch

attachment MonoBook patch.txt ignored as obsolete

rememberthedot wrote:

SkinTemplate.php patch

Fixed patch to prevent ip-userpage class from appearing outside the User and User_talk namespaces

attachment SkinTemplate patch.txt ignored as obsolete

That would hide or gray out links that are *on* an IP user page, not links *to an IP user page.

rememberthedot wrote:

Look again. It does nothing of the kind.

rememberthedot wrote:

It could be used to gray out all links on an IP user page, but I doubt anyone will want to do that, and that's not what I intended this code to be used for. I intend to use it to gray out the "user page" tab for IP editors, rather than having it appear in glaring red.

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Adding the "design" keyword since this is partly a visual design change.

These patches don't apply at all, marking them as obsolete.

pageclass et al seem to have disappeared in one of the recent skin system refactorings, so I don't really know how to apply this to trunk.

Removing design keyword, it's not really needed IMO because the default design isn't changed at all, this'll just enable people to do certain things in their own CSS more conveniently.

sumanah wrote:

rememberthedot, are you interested in revising this patch to work with current trunk? Thanks!

The proper way to do this now in current code:

  • Use userpage-anon and userpage-user for classes, they fit in better with the ns-* page-* pattern that we already have going with classes. ip-userpage is an odd break from that. (note don't use something like page-anonuser since that would conflict with a page titled [[Anonuser]])
  • Code would go in OutputPage::headElement, likely right after the $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() ); line.
  • You'd probably move the $this->getTitle() from that to a $title variable and use it in getPageClasses as well.

if ( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) {

// Don't show the class on subpages
if ( !$title->isSubpage() ) {
  $bodyAttrs['class'] .= ' ' . ( User::isIP( $this->getTitle() ) ? 'userpage-anon' : 'userpage-user' );
}

}

Jdlrobson subscribed.

And oldy, but doesn't seem unreasonable.
My understanding is we want to add a class to the body tag of https://en.wikipedia.org/wiki/User:156.34.142.110

Can be done inside OutputPage::headElement

That said, since nobody has done it, I'm guessing this is not actually needed.

Anyone should feel free to reopen this, if the class would be useful, with some additional context and I can prioritize this.