Page MenuHomePhabricator

Hovercards should be able to show page fragments (sections of pages)
Open, LowestPublic


While toying around with a glossary (original is mw:Help:Spec/glossary, alternative is mw:Help:Spec/glossary test, my idea was to use Help:Spec/glossary/continuous integration) which didn't work as expected. (Fixing T65045: Don't extract <translate> tags would make this work) So I started to wonder how I would like this to work, and how it would be best done together with the translate extension. To make a whole lot of small pages isn't a really good solution, as such glossaries are used only on a few pages, and should be treated together.

Assume a that a link can be made to the page, and it contains a fragment identifier, like [[Help:Spec/glossary#continuous integration]]. The Hovercard solution would find the link includes a hash mark (#), will then try to find an element identified by the hash mark, and climb up the parent until a child for the content is found. It will then include all following children from the content up to the next one with a valid identifier at the same level. The set of elements is then pruned to form a set for the hovercard instance.

Note that some styles of glossaries use a dl list, where the fragment is put inside a span in the dt element. The proposed algorithm will work in this case if only following elements are included if they don't contain a valid identifier on the same level. A common way to make the glossary puts the identifier in a separate p element before the dt, and that will fail. (On second thought, it will not fail.)

This will make it possible to have a single glossary page, and still be able to reference it with fragment identifiers, and the hovercard functionality will still work as expected.

It should probably be possible to use this together with T136480: Help pages and hovercards, and especially note that it is a solution to the long glossary pages.

See also

Event Timeline

jeblad created this task.Jan 23 2017, 5:58 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 23 2017, 5:58 PM
jeblad updated the task description. (Show Details)Jan 23 2017, 6:01 PM
jeblad updated the task description. (Show Details)Jan 23 2017, 6:08 PM
jeblad updated the task description. (Show Details)Jan 23 2017, 6:32 PM
jeblad updated the task description. (Show Details)Jan 23 2017, 8:14 PM

See also T65792: #section-links should preview the correct subsection, but note that this task is about a specific use case.

jeblad updated the task description. (Show Details)Jan 23 2017, 8:36 PM
Jdlrobson added subscribers: ovasileva, Nirzar, Jdlrobson.

Support for displaying hash fragments in this way would require pulling the entire page content down via the API. This would slow down the display of the hovercard. It's an interesting idea, provided we do it only for hashes but taken out of context information could be confusing.

@ovasileva @Nirzar over to you for thoughts.

Jdlrobson triaged this task as Low priority.Jan 25 2017, 7:24 PM

This is useful for glossaries, not for articles in general.

Extracting fragments can be done at the server, there are no need for pulling the whole page.

Yes, extracting fragments can be done at the server. Something like RESTBase would make this easier though as we only store the entire block of HTML in MediaWiki and would need to turn it into a DOM tree and parse it to determine the fragment. Although we'd only return the fragment we'd still need to parse the whole page.

Right now a link on a wiki page would have no knowledge of whether it was pointing to a glossary page. The help namespace might be enough but I don't know enough about how that is used.

Jdlrobson lowered the priority of this task from Low to Lowest.Jun 5 2017, 6:28 PM
jeblad added a comment.Jun 5 2017, 8:22 PM

Parsing the page and pulling a fragment are separate tasks, and pulling a specific fragment for hovercards should pose no real problem.

Jdlrobson moved this task from Backlog to Later on the Readers-Web-Backlog (Tracking) board.

(Since it's in Hovercards Pt2 moving to later)

Stas added a subscriber: Stas.May 22 2018, 3:44 PM
Jdlrobson renamed this task from Hovercards should be able to show page fragments to Hovercards should be able to show page fragments (sections of pages).Oct 28 2018, 7:51 PM
Jdlrobson added a subscriber: nyemini.

Isn't it possible to get the wikicode of specific section and render just it?
like when you edit a specific section.

@nyemini the difficulty here is that summaries need to be html and not wiki code.

I agree that previewing sections would be awesome to see but given the non trivial work involved in creating an API to support this (touched on in my blog post) this isn't so straightforward.

If such an api existed the result of this would be a little bit more trivial to do but an api endpoint would be the next logical step.

nyemini added a comment.EditedOct 30 2018, 8:50 PM

I'm sorry, I'm new here, but how things are usually going here?
I mean, how the decisions are made and who does the work of writing/fixing the code of mediawiki extensions?

@nyemini: Decisions are made by whoever maintainers a project. Whoever feels like writing code or whoever gets paid for writing code writes the code. See for more information and better venues to discuss this. Thanks! :)

bearND added a subscriber: bearND.Jan 2 2019, 5:55 PM

The links in the task description point to empty pages. Anyone know some good examples of links to glossary pages?
What API is needed here?

Jdlrobson added a comment.EditedJan 2 2019, 6:53 PM

@bearND while the task talks about help pages, what it is essentially asking for is being able to generate summaries of sections e.g.
would summarise as:

Iberia enters written records as a land populated largely by the Iberians, Basques and Celts. Early on its coastal areas were settled by Phoenicians who founded Western Europe's most ancient cities Cadiz and Malaga. Phoenician influence expanded as much of the Peninsula was eventually incorporated into the Carthaginian Empire, becoming a major theatre of the Punic Wars against the expanding Roman Empire. After an arduous conquest, the peninsula came fully under Roman Rule. During the early Middle Ages it came under Germanic rule but later, much of it was conquered by Moorish invaders from North Africa. In a process that took centuries, the small Christian kingdoms in the north gradually regained control of the peninsula. The last Moorish kingdom fell in the same year Columbus reached the Americas.

If such a capability existed, hovercards could show previews in this fashion.

bearND added a comment.EditedJan 2 2019, 6:57 PM

If this is for all pages then that could turn out quite expensive on the server side, at least if we pre-generated the API responses. Maybe a specific API is in order?

If this is for all pages then that could turn out quite expensive on the server side.

Agreed and not trivial ( T156041#4707501).

Quiddity updated the task description. (Show Details)Jul 17 2019, 6:15 PM
Quiddity added a subscriber: Quiddity.
Jmviz added a subscriber: Jmviz.Sep 14 2019, 4:53 PM