Page MenuHomePhabricator

Backlinks should be objects with href and the link text
Closed, ResolvedPublic

Description

Some wikis can customize the text shown for the backlinks. Instead of just having a simple href string for a backlink in the references output, let's make it an object with href and text so clients could use that for displaying any wiki-specific text.

OLD:

"back_links": [
    "./PageTitle#cite_ref-ref1_1-0",
    "./PageTitle#cite_ref-ref1_1-1"
],

NEW:

"back_links": [{
    "href": "./PageTitle#cite_ref-ref1_1-0",
    "text": "a"
}, {
    "href": "./PageTitle#cite_ref-ref1_1-1"
    "text": "b"
}],

Event Timeline

bearND triaged this task as Medium priority.Dec 12 2017, 1:35 AM
bearND created this task.

Hi @subbu, it looks like Parsoid provides the backlink text as integers on enwiki in the DOM structure, but the actual wiki page shows lower-case letter.

<li id="cite_note-wozencraft2005-1">
  <span rel="mw:referencedBy">
    <a href="./Dog#cite_ref-wozencraft2005_1-0"><span class="mw-linkback-text">1 </span></a>
<li id="cite_note-wozencraft2005-1">
  <span class="mw-cite-backlink">
    ^ <a href="#cite_ref-wozencraft2005_1-0"><sup><i><b>a</b></i></sup></a>

Why does Parsoid not show the lower case letters as well? (It gets overridden by CSS but I'm parsing the DOM here and would like to keep things simple.)

Do you happen to have a list of wikis which have customized the back links handy? So far I know if viwiki and arwiki. At least on the two latter wikis I do see Parsoid using the right characters in the DOM.

  • arwiki example:
<span class="mw-cite-backlink"><b>^</b> <a href="#cite_ref-freedman2000_3-0"><span class="cite-accessibility-label">تعدى إلى الأعلى ل: </span><sup><i><b>أ</b></i></sup></a> <a href="#cite_ref-freedman2000_3-1"><sup><i><b>ب</b></i></sup></a> <a href="#cite_ref-freedman2000_3-2"><sup><i><b>ت</b></i></sup></a></span>
  • viwiki example:
<a href="#cite_ref-plottwists_41-1"><sup><i><b>ă</b></i></sup></a>

Change 397737 had a related patch set uploaded (by BearND; owner: BearND):
[mediawiki/services/mobileapps@master] References: back_link as object

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

Quick late night response to one part of your query .. See https://github.com/wikimedia/integration-visualdiff/blob/master/lib/parsoid.custom_styles.yaml for a list of custom CSS for parsoid html. That is not exhaustive, but probably covers most of the ones that need custom CSS.

Change 397737 merged by jenkins-bot:
[mediawiki/services/mobileapps@master] References: back_link as object

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

Quick late night response to one part of your query .. See https://github.com/wikimedia/integration-visualdiff/blob/master/lib/parsoid.custom_styles.yaml for a list of custom CSS for parsoid html. That is not exhaustive, but probably covers most of the ones that need custom CSS.

Are those styles not used by Parsoid? Is it planned that VE is supposed to use them? VE does not used them either at this time.

Example: When I go to https://es.wikipedia.org/api/rest_v1/page/html/Universidad_de_Viena
I see the backlinks of the 2nd reference have a very different text than the regular wiki page
Parsoid + VE: 2.0 2.1 2.2
Parsoid DOM: 1 2 3
wiki: a b c

The wiki page has the correct text (a, b, c) while Parsoid uses (DOM texts: 1, 2, 3) and adds CSS rules to hide then, then uses the own counters (2.0 2.1 2.2). I think it would be much easier for clients if Parsoid were to do the same as the regular wiki page (I assume MW Core Parser).

The output format change is deployed so we can close this one. To be continued in T184316.