Last modified: 2012-01-08 01:49:37 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T6438, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 4438 - Add CSS hook for current WikiPage action
Add CSS hook for current WikiPage action
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.6.x
All All
: Low enhancement with 5 votes (vote)
: 1.19.0 release
Assigned To: Krinkle
:
: 9758 24895 25657 27370 (view as bug list)
Depends on: 27930
Blocks: css
  Show dependency treegraph
 
Reported: 2006-01-01 00:28 UTC by Colin Pitts
Modified: 2012-01-08 01:49 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Colin Pitts 2006-01-01 00:28:03 UTC
No CSS hook exists for distinguishing between content/history/etc actions for a
given page title. This obviously prevents CSS from changing the appearance based
on the action being performed.

This limitation appears to be inherent to all SkinTemplate.php derived skins, as
I can see nothing in that code that references the action.

Context:
I was implementing a link highlighting suggestion made by Timwi in this WikiEN-l
post: http://mail.wikimedia.org/pipermail/wikien-l/2005-October/031082.html

With the <body class="ns-0">, I was able to restrict the behavior to only the
article namespace. However, I found no way to prevent the behavior from
appearing on edit, history, protection, deletion, move, and watch/unwatch pages
for a given title.

A javascript workaround may exist.
Comment 1 Splarka 2007-04-27 00:51:16 UTC
An existing problem this could fix:
http://en.wikipedia.org/wiki/Main_Page?action=history The "View logs for this
page" link is in #contentSub which is hidden on the [[Main Page]] in css. It
would be nice to restore it.

Here is an experimental js for per-action CSS (should not be used except for
demonstration):
http://test.wikipedia.org/w/index.php?title=User:Splarka/monobook.js&oldid=21972

It first appends a class "action-actionname" to the body according to the
&action parameter value, such as: 'watch unwatch delete revert rollback protect
unprotect info markpatrolled purge credits submit edit history'. Note that 'raw'
and 'render' do not have a <body> tag.

It then overwrites this with "action-diff" if a 'diff' parameter is used
(because the actions above have almost no effect on diffs).

It then appends "action-oldid" if 'oldid' is defined (as oldid does affect diffs).

So for example:

Main_Page == class="mediawiki ns-0 ltr page-Main_Page action-view"

Main_Page?action=unwatch == class="mediawiki ns-0 ltr page-Main_Page action-unwatch"

Main_Page?action=edit&oldid=11112 == class="mediawiki ns-0 ltr page-Main_Page
action-edit action-oldid"

Main_Page?diff=14912&oldid=11112 == class="mediawiki ns-0 ltr page-Main_Page
action-diff action-oldid"

Possibly also useful would be classes for 'direction', 'curid', 'redirect',
'diffonly', 'rdfrom', 'from', 'until' (the pecking order would have to be worked
out).
Comment 2 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-05-02 00:04:41 UTC
*** Bug 9758 has been marked as a duplicate of this bug. ***
Comment 3 Mike Dillon 2007-05-02 00:38:15 UTC
I created a patch that is attached to #9758, but it simply takes the value of
the "action" parameter and creates a class with "action-" prepended (defaulting
to "action-view"). If I can get some guidance as to whether that simple behavior
or the more complex behavior outlined by Sparkla is desired, I can adjust the
patch and attach it here. Since a release candidate of 1.10 has already been
cut, I guess this will have to target 1.11-svn, not 1.10-svn as I put in #9758.
Comment 4 Brion Vibber 2007-05-02 15:02:24 UTC
That sounds a bit fragile to me. I don't like relying on pulling a literal GET
param there either, we want to be more general in handling the action parameters
and in validating. Might work ok though, as long as there's not a problem with
whitespace/invalid chars/etc.
Comment 5 Mike Dillon 2007-05-02 17:37:32 UTC
My patch was using Sanitizer::escapeClass to avoid potential problems with bad
characters. I agree that it is slightly fragile if people are hacking URLs, but
it will work all normal use cases (there is a fallback to "view" when "action"
is not provided). People who put in an action that isn't recognized get an error
page anyways.

I was hoping that there would be a $wgAction global that contained the validated
action name to avoid having to default to "view" in multiple places in the code,
but I couldn't find it. I ended up using the same code that populated the
"wgAction" JavaScript variable.
Comment 6 entlinkt 2010-08-23 20:43:47 UTC
*** Bug 24895 has been marked as a duplicate of this bug. ***
Comment 7 db [inactive,noenotif] 2010-10-27 14:09:19 UTC
*** Bug 25657 has been marked as a duplicate of this bug. ***
Comment 8 Chad H. 2011-02-12 21:31:38 UTC
*** Bug 27370 has been marked as a duplicate of this bug. ***
Comment 9 Subfader 2011-02-12 21:42:24 UTC
What's so complicated about adding these useful classes? :(
Comment 10 Subfader 2011-02-13 12:51:48 UTC
Can't get Sparkla's JS solution working http://test.wikipedia.org/w/index.php?title=User:Splarka/monobook.js&oldid=21972

For those who want to hardcode a solution: includes/Skin.php:

	function getPageClasses( $title ) {
		global $wgRequest;
		$numeric = 'ns-'.$title->getNamespace();
		if( $title->getNamespace() == NS_SPECIAL ) {
			$type = 'ns-special';
		} elseif( $title->isTalkPage() ) {
			$type = 'ns-talk';
		} else {
			$type = 'ns-subject';
		}
		$name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
	  if (!$wgRequest->getVal('action')) {
	  	  $actionValue='view';
	  	  } else {
	  	  $actionValue = $wgRequest->getVal('action');
	  	  }
		$action = 'action-'. $actionValue;
		return "$numeric $type $name $action";
	}

This will add " action-edit" to the body class when you edit a page etc. and action-view when there is no action.
Comment 11 Subfader 2011-02-13 12:57:29 UTC
A slightly improved version will also add action-yes to catch all pages that have an action.

	  if (!$wgRequest->getVal('action')) {
	  	  $actionValue = 'action-no action-view';
	  	  } else {
	  	  $actionValue = 'action-yes action-'.$wgRequest->getVal('action');
	  	  }
		$action = $actionValue;
Comment 12 Subfader 2011-02-13 17:30:03 UTC
Now also considering diffs which don't use the action parameter.

	  if (!$wgRequest->getVal('action')) {
	  	  $actionValue = 'action-no action-view';
	  	  } else {
	  	  $actionValue = 'action-yes action-'.$wgRequest->getVal('action');
	  	  }
	  if ($wgRequest->getVal('diff')) {
	  	  $actionValue = 'action-yes action-diff';
	  	  }
		$action = $actionValue;
Comment 13 Krinkle 2011-03-08 09:41:57 UTC
See also bug 25800
Comment 14 DieBuche 2011-07-11 10:57:56 UTC
Fixed in r91871 (w/o action-no, just use body:not(.action-view) )
Comment 15 Krinkle 2011-07-12 11:04:35 UTC
Please don't fix this locally, there is enough ad-hoc "what action" implementations already. Instead focus on bug 27930. Once that is fixed we can insert it into various places (mw.config wgAction and body-class "action-$1").

That way action=yes%20I%know will not end up with wgAction="yes i know" or <body class="action-yes I know" (3 classes).

Just escaping it to action-yes_i_know isn't acceptable either imho, bug 27930 :-)
Comment 16 DieBuche 2011-07-12 11:08:08 UTC
action=yes%20I%know returns wgAction="nosuchaction" since r91870 . That rev needs some polish per CR, though
Comment 17 DieBuche 2011-07-12 12:32:57 UTC
Edit: I meant r91949
Comment 18 Subfader 2011-07-12 17:30:17 UTC
The fixes don't consider diffs.

 if ($wgRequest->getVal('diff')) {
           $actionValue = 'action-yes action-diff';
    }
Comment 19 Krinkle 2012-01-08 01:37:42 UTC
Reopening as r94131 reverted this, didn't anyone notice ?
Comment 20 Krinkle 2012-01-08 01:49:37 UTC
Fixed in r108345.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links