kiwix / kiwix-js-pwa

Kiwix JS Offline Browser implemented as a Progressive Web App (PWA), and packaged as Electron, NWJS and UWP apps for Windows and Linux.
https://pwa.kiwix.org
GNU General Public License v3.0
168 stars 26 forks source link

Add Wikipedia preview function #595

Closed Jaifroid closed 2 months ago

Jaifroid commented 3 months ago

Fixes #278.

This is currently specific to Wikimedia ZIMs (i.e. those scraped by mwOffliner) because the HTML has to be parsed based on certain tags provided by mwOffliner.

@kelson42 has suggested that a more generic way could be to snapshot a rendered (but hidden) view of the article and display a png. This would be more generic, although we need to think whether users would expect or even appreciate a generic preview. It's certainly the case that Wikipedia users expect such a feature (and this is the easiest case to cater for).

This feature should be ported upstream to Kiwix JS, but currently the click "infrastructure" is missing there in ServiceWorker mode (or rather, it is done differently), so the code would need to be adapted. See https://github.com/kiwix/kiwix-js/issues/719.

Jaifroid commented 3 months ago

Some to-do items:

Jaifroid commented 2 months ago

Feature is tested and working on Chromium and Firefox for desktop: mouseover is best method, but long-press also works for touchscreen users, and keyboard (tabbing into links) also evokes the popover. Also tested on UWP app, all working fine with mouseover and touch.

On Android, an installed PWA can use the feature with long-press, and I've included different sizes for portrait and landscape orientation when there is a narrow screen. However, in Firefox for Android long-press seems to be hard-wired to the context menu and is not overridden. However, Firefox for Android cannot load large ZIM archives due to https://bugzilla.mozilla.org/show_bug.cgi?id=1807360, so I doubt anyone uses the PWA in that browser on Android.

I have yet to test Safari / iOS in simulator.

Jaifroid commented 2 months ago

OK, iOS at least on an iPad has its own "hard-wired" preview feature which my code doesn't interfere with, so I think that's acceptable. See screenshot.

image

EDIT: Same on iPhone.

Jaifroid commented 2 months ago

Feature is working great on Safari desktop on macOS. Both mouseover and keyboard (macOS doesn't have touch).

image

Jaifroid commented 2 months ago

At least on Android, the icons top right are not consistently attached.

Jaifroid commented 2 months ago

Now working in Firefox for Android (with long-press), but close icons are not registering, despite some tweaks. Needs debugging.

Jaifroid commented 2 months ago

Finally icons are working on Firefox!

Jaifroid commented 2 months ago

All tested and working in Chrome (>=49), Firefox (>=68 - earlier versions work but don't support WebP), UWP (Edge Legacy), Safari on macOS. Ready to merge.