From 9f53096051639c08cba43f9b72650ef5adee1df0 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Thu, 16 Mar 2017 15:19:36 -0700 Subject: [PATCH] Linker: Render selflinks as href-less classed s, not s Self-links are still semantically links, and representing them as s is inelegant and more important a real pain to work with, especially in contexts where they may change state (like inside an editor). Instead, render them as , with no href to avoid user agent style over- rides and with a class to style them as before, named 'mw-selflink' to go with 'mw-redirect'. This allows much easier adjustment later. The old CSS class 'selflink' is retained for backwards compatibility, but deprecated. Bug: T160480 Change-Id: If058843924c3b30c116df2520aef93a004d98a5d --- RELEASE-NOTES-1.29 | 3 +++ includes/Linker.php | 12 ++++++------ resources/src/mediawiki.legacy/shared.css | 11 +++++++++++ tests/parser/parserTests.txt | 14 +++++++------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29 index 793769ff1c..2ced8a5fa0 100644 --- a/RELEASE-NOTES-1.29 +++ b/RELEASE-NOTES-1.29 @@ -276,6 +276,9 @@ changes to languages because of Phabricator reports. 'EditPageGetCheckboxesDefinition', or 'EditPage::showStandardInputs:options' if you don't actually care about checkboxes and just want to add some HTML to the page. +* Selflinks are now rendered as href-less tags with the class mw-selflink + rather than tags. The old class name, "selflink", was deprecated + and will be removed in a future release. (T160480) == Compatibility == diff --git a/includes/Linker.php b/includes/Linker.php index 0c8d1c6646..816271f483 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -164,10 +164,10 @@ class Linker { } /** - * Make appropriate markup for a link to the current article. This is - * currently rendered as the bold link text. The calling sequence is the - * same as the other make*LinkObj static functions, despite $query not - * being used. + * Make appropriate markup for a link to the current article. This is since + * MediaWiki 1.29.0 rendered as an tag without an href and with a class + * showing the link text. The calling sequence is the same as for the other + * make*LinkObj static functions, but $query is not used. * * @since 1.16.3 * @param Title $nt @@ -179,7 +179,7 @@ class Linker { * @return string */ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) { - $ret = "{$prefix}{$html}{$trail}"; + $ret = "{$prefix}{$html}{$trail}"; if ( !Hooks::run( 'SelfLinkBegin', [ $nt, &$html, &$trail, &$prefix, &$ret ] ) ) { return $ret; } @@ -188,7 +188,7 @@ class Linker { $html = htmlspecialchars( $nt->getPrefixedText() ); } list( $inside, $trail ) = self::splitTrail( $trail ); - return "{$prefix}{$html}{$inside}{$trail}"; + return "{$prefix}{$html}{$inside}{$trail}"; } /** diff --git a/resources/src/mediawiki.legacy/shared.css b/resources/src/mediawiki.legacy/shared.css index ff0c0e3625..6ced6dce1d 100644 --- a/resources/src/mediawiki.legacy/shared.css +++ b/resources/src/mediawiki.legacy/shared.css @@ -322,6 +322,17 @@ a.new { color: #ba0000; } +/* self links */ +a.mw-selflink { + color: inherit; + font-weight: bold; + text-decoration: inherit; +} +a.mw-selflink:hover { + cursor: inherit; + text-decoration: inherit; +} + /* Plainlinks - this can be used to switch * off special external link styling */ .plainlinks a.external { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index be6e3a8996..2def8751ee 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -8015,10 +8015,10 @@ title=[[Bug462]] !! wikitext [[Bug462]] [[Bug462]] !! html/php -

Bug462 Bug462 +

Bug462 Bug462

!! html/php+tidy -

Bug462 Bug462

+

Bug462 Bug462

!! html/parsoid

Bug462 Bug462

!! end @@ -8047,7 +8047,7 @@ title=[[0]] !! wikitext [[0]] !! html -

0 +

0

!!end @@ -8503,7 +8503,7 @@ parsoid=wt2html,wt2wt,html2html !! wikitext [[local:Main Page]] !! html/php -

local:Main Page +

local:Main Page

!! html/parsoid

local:Main Page

@@ -20327,7 +20327,7 @@ title=[[Dunav]] language=sr !! wikitext Both [[Dunav]] and [[Дунав]] are names for this river. !! html -

Both Dunav and Дунав are names for this river. +

Both Dunav and Дунав are names for this river.

!!end @@ -20344,7 +20344,7 @@ title=[[Duna]] language=sr !! wikitext [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links. !! html -

Дуна is not a self-link while Duna and Dуна are still self-links. +

Дуна is not a self-link while Duna and Dуна are still self-links.

!! end @@ -20355,7 +20355,7 @@ title=[[Duna]] language=sr !! wikitext [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links. !! html -

Dуна is a self-link while Dunа#Foo and Dуна#Foo are not self-links. +

Dуна is a self-link while Dunа#Foo and Dуна#Foo are not self-links.

!! end -- 2.20.1