Page MenuHomePhabricator

HTML enhancement for some special pages' navigation links
Closed, ResolvedPublicFeature

Description

Feature summary:

NOTE: TLDR: Wrap history/Special:Log's mw-firstlink, mw-lastlink, mw-prevlink, mw-nextlink, mw-numlink in a parent element like Special:Contribs does and wrap pseudo-links (e.g. newest when you are already viewing the newest revisions/log entries) in span elements with semantic classes.

I was writing this userscript when I realized Special:Log and action=history's navigation links are not wrapped in any direct parent element. This makes it hard to select those links as a whole (i.e. the whole line). Here's how I see them via DevTools:

All public logs
<div><form>etc.</form></div>

(newest | <a href="..." class="mw-lastlink" title="...">oldest</a>) View (newer 100 |  <a href="..." class="mw-nextlink" title="..." rel="next">older 100</a>) (<a href="..." class="mw-numlink" title="...">20</a> | <a href="..." class="mw-numlink" title="...">50</a> | <a href="..." class="mw-numlink" title="...">100</a> | <a href="..." class="mw-numlink" title="...">250</a> | <a href="..." class="mw-numlink" title="...">500</a>)

<ul class="mw-logevent-loglines">
<li data-mw-logid="...">etc.</li>
...
<li data-mw-logid="...">etc.</li>
</ul>

(same links)

<div class="printfooter">etc.</div>

Comparing to Special:Contribs: Contribs's mw- links are wrapped into an easily selectable p element with an appropriate class:

User contributions for Example
<div><form>etc.</form></div>

<p class="mw-pager-navigation-bar">(newest | <a href="..." class="mw-lastlink" title="...">oldest</a>) View (newer 100 |  <a href="..." class="mw-nextlink" title="..." rel="next">older 100</a>) (<a href="..." class="mw-numlink" title="...">20</a> | <a href="..." class="mw-numlink" title="...">50</a> | <a href="..." class="mw-numlink" title="...">100</a> | <a href="..." class="mw-numlink" title="...">250</a> | <a href="..." class="mw-numlink" title="...">500</a>)</p>

<section class="mw-pager-body">
<h4>etc.</h4>
<ul>etc.</ul>
...
<h4>etc.</h4>
<ul>etc.</ul>
</section>

(same links)

<div class="mw-contributions-footer">etc.</div>
<div class="printfooter">etc.</div>

I would also like to see the pseudo-links (i.e. newest, newer 100 et. al.) be wrapped in, say, span elements with some semantic classes like mw-notlink or something like that.

Use case and benefits:
Making HTML content not look like a mess and helping me complete the script.

Addendum: Navigation links of the following pages are also not wrapped:

  • categories
  • Special:ProtectedTitles
  • Special:ActiveUsers
  • Special:GlobalUsers
  • Special:OAuthListConsumers
  • Special:GlobalBlockList

...and probably plenty others.

Event Timeline

NguoiDungKhongDinhDanh renamed this task from HTML enhancement for history/Special:Log's mw-firstlink, mw-lastlink, mw-prevlink, mw-nextlink, mw-numlink to HTML enhancement for some special pages' navigation links.May 13 2022, 10:34 PM
NguoiDungKhongDinhDanh updated the task description. (Show Details)

I've noticed this as well when I was working on T298638, I even started writing a patch but I never finished it. I'll put in the effort now that I know that someone else wants it :)

Change 794757 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Wrap navigation in <div class="mw-pager-navigation-bar"> in all pagers

https://gerrit.wikimedia.org/r/794757

Change 794758 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] IndexPager: Wrap inactive paging links in <span class="…">

https://gerrit.wikimedia.org/r/794758

Note that this doesn't add the wrappers in all special pages, but only those using AlphabeticPager and ReverseChronologicalPager. This covers most special pages, but there are a few exceptions, e.g. Special:WhatLinksHere.

@matmarex Thanks for looking into this. Is there a list of such pages, or will I have to go through every single special page again?

Change 794757 merged by jenkins-bot:

[mediawiki/core@master] Wrap navigation in <div class="mw-pager-navigation-bar"> in all pagers

https://gerrit.wikimedia.org/r/794757

Change 794758 merged by jenkins-bot:

[mediawiki/core@master] IndexPager: Wrap inactive paging links in <span class="…">

https://gerrit.wikimedia.org/r/794758

@matmarex Thanks for looking into this. Is there a list of such pages, or will I have to go through every single special page again?

There's no list; I tried to find everything using the 'viewprevnext' message, but this doesn't directly answer the question: https://codesearch.wmcloud.org/search/?q=viewprevnext&i=nope&files=%5C.php%24&excludeFiles=&repos=

So here we have:

  • includes/pager/AlphabeticPager.php and includes/pager/ReverseChronologicalPager.php – fixed!
  • includes/specials/SpecialWhatLinksHere.php – not fixed
  • includes/Navigation/PrevNextNavigationRenderer.php – not fixed – this is used by many special pages, e.g. Special:WantedPages and other stuff listed on Special:SpecialPages#Maintenance reports. I don't know if that's a complete list though.
  • GlobalUsage extension – not fixed

This is actually a small number of places to fix (I was worried that more special pages would be generating their paging links by hand, rather than using common code). I guess I'll try to fix the rest of them too (or I'd be happy to review patches, if you'd like to submit some).

Change 803620 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Introduce PagerNavigationBuilder for making pagination links

https://gerrit.wikimedia.org/r/803620

Test wiki created on Patch demo by DKinzler (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/d4396b72c3/w

Test wiki created on Patch demo by DKinzler (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/d4396b72c3/w

I can't find a way to import pages so I can try paging...

Change 803620 merged by jenkins-bot:

[mediawiki/core@master] Introduce PagerNavigationBuilder for making pagination links

https://gerrit.wikimedia.org/r/803620

All pagers I know of should now have <div class="mw-pager-navigation-bar">…</div> around the links, and class="mw-firstlink / mw-lastlink / mw-prevlink / mw-nextlink / mw-numlink" on each <a> link (or <span> inactive link placeholder).

If you find any special pages that don't, please file a separate task. There might be some in extensions.

(The change will be deployed to Wikimedia wikis this week, per the usual schedule.)

The latest commit broke Special:CheckUser's paging links by removing calls to getPagingLinks and other similar methods in IndexPager.php which are overriden in CheckUser. The annotation that this is "deprecated" is incorrect as this is instead fully broken and seemingly removed.