We should pull out categories of a page into an array as part of the new /page/metadata/{title} endpoint.
If we can use a MW API for this, we can make a call directly. Otherwise we should parse the HTML to get at these.
We should pull out categories of a page into an array as part of the new /page/metadata/{title} endpoint.
If we can use a MW API for this, we can make a call directly. Otherwise we should parse the HTML to get at these.
Project | Branch | Lines +/- | Subject | |
---|---|---|---|---|
mediawiki/services/mobileapps | master | +47 -13 | Metadata: Add page categories |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | None | T169242 Develop Page Content Service for Reading Clients | |||
Resolved | None | T177425 Develop General Layer of PCS | |||
Resolved | • Jhernandez | T177426 Develop structured JSON APIs for general consumption | |||
Resolved | • Mholloway | T177428 Develop Metadata JSON API | |||
Resolved | • Mholloway | T172005 Extract categories as a structured array in the metadata endpoint |
Please no... categories should remain out of the payload of the MCS endpoint. In mobile we only need to show them with a categories button. The HTML for categories can be quite large and is not necessary for an initial view and arguably not needed even for a below the fold view. I'd recommend the creation of a new endpoint for categories if needed for scalability...
Is anything needed here beyond a simple list of categories?
It would be trivially easy to get these directly from the Parsoid HTML with something like
const categoryLinks = doc.querySelectorAll('link[rel="mw:PageProp/Category"]'); return [].map.call(categoryLinks, link => link.getAttribute('href'));
In mobile web, we currently need to know which categories are hidden
We render like so: https://en.m.wikipedia.org/wiki/Barack_Obama?mobileaction=beta#/categories
https://en.m.wikipedia.org/w/api.php?action=query&format=json&prop=categories&titles=Barack%20Obama&clprop=hidden&cllimit=50&formatversion=2
Can we get that information from Parsoid HTML?
Interesting. Parsoid HTML currently doesn't expose hidden categories. I wonder how @ssastry would feel about adding those.
Change 410627 had a related patch set uploaded (by Mholloway; owner: Mholloway):
[mediawiki/services/mobileapps@master] Metadata: Add page categories
Change 410627 merged by Mholloway:
[mediawiki/services/mobileapps@master] Metadata: Add page categories