Figure out what it would take to migrate to mobile-html
Would it help with rendering of tables, maps, etc?
SBisson | |
Jan 14 2021, 9:08 PM |
F34183388: image.png | |
Mar 23 2021, 8:51 PM |
Figure out what it would take to migrate to mobile-html
Would it help with rendering of tables, maps, etc?
Of course loading a 11MB image would be a blocker. I would prefer to stick with the lead image determined by MW and not pull a random image from the infobox. We could consider querying the summary endpoint and merging it with everything else in useArticle(). In many cases this API will already be cached.
So far the only missing piece is the property languagecount
I think it's fine to always show the language action button on the first page and allow the user open the language setting, even the article has only one language
or another solution we prefetch the langlinks to determine showing the language action button, but I think this takes user bandwidth which is not nice.
PR https://github.com/wikimedia/wikipedia-kaios/pull/334
Do not merge this until the final confirm and there are still some need to be fixed.
This spike has been done, to answer the question (✔️better;⭕ no better or difference),
Would it help with rendering of tables, maps, etc?
⭕ Nope to the maps, same as mobile-section
✔️ partially help in table - in the table markup, there is already existing ready to use template instead of building our own; but some legacy table still exist in older markup, i would recommend hiding them .wikitable to avoid ugly table shown.
Would it help in image?
⭕ In mobile-html the image has lazy load, therefore the script need to parse the lazy load image tag then insert them into the content manually.
Would it help with the hyperlink?
⭕ the hyperlink has several things - article preview / reference preview / image preview / subcontent / external link / interwiki link
it does have slightly difference but we still handle these one by one
Other things :
⭕ Lead image problem see here https://phabricator.wikimedia.org/T272091#6895468
⭕ languagecount problem see here https://phabricator.wikimedia.org/T272091#6928161
After discussion with @SBisson , there are few more steps to try
These are the endpoints requested during the article loading (Article Cat as the example)
Here's the summary of how the app parses the mobile-html endpoint and show it on the page
Item | which element |
Article Title | <h1> text from the <header>; or <title> text |
Article description | <p> text from the <header> |
Article direction | dir attribute from <body> |
Article id, namespace, contentLang | from <head><meta/></head> |
infobox | <infobox> from the first <section> found |
section *(see more below) | from each <section> |
External Hyperlink | has attribute rel=mw:ExtLink from <a> |
Article Preview | has attribute title from <a> |
Table | the element has pcs-collapse-table-container class name |
Image | Convert every span.pcs-lazy-load-placeholder into <img> tag, source from the data-src attribute |
Reference | query selector all 'li[id^="cite_"]' |
each section | which element in the <section> |
Section Title | one of <h1> ... <h5> |
Section Anchor | id attribute from the title node <h1> ... <h5> |
Testing:
General regression testing did not show any functional issues. Will move this for sign off.