mwoffliner icon indicating copy to clipboard operation
mwoffliner copied to clipboard

Introduce the ZIM JS API

Open kelson42 opened this issue 6 years ago • 11 comments

This new JS API should provide the following features:

  • Night mode #1240
  • TOC
  • webm video reader (https://github.com/brion/ogv.js/) #1239

What needs to be done:

  • openZIM spec
  • standard implementation for all 3 things
  • Put the implementation in libzim (node-libzim?)
  • A demo case in iOS

See https://wiki.openzim.org/wiki/Javascript_API for more detail (but still a draft)

kelson42 avatar Feb 23 '19 13:02 kelson42

@kelson42 The 3 features here are a subset of the spec on the openzim wiki. Is this correct? Is this issue just for the 3 mentioned features?

ISNIT0 avatar Jun 05 '19 09:06 ISNIT0

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Aug 04 '19 10:08 stale[bot]

I would like to propose adopt prefers-color-scheme as an alternative to dark theme. The js API is still useful for extract table of content, etc.

csswg | Browser compatibility

automactic avatar May 08 '20 14:05 automactic

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Jul 07 '20 20:07 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Sep 24 '20 17:09 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 18:12 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar May 26 '23 18:05 stale[bot]

Like said @automactic, it's not foreseen (anymore) to use JS API for the dark/light mode, see https://github.com/openzim/overview/issues/53

kelson42 avatar Jun 20 '25 09:06 kelson42

Now that we only have TOC left in the JS API, are we really sure about the approach?

For the TOC, I feel like a very basic convention on a class to add to every TOC elements could be sufficient. E.g. zim_toc_h1, zim_toc_h2, ... Sufficiently unique to have mostly zero risk of collision with already existing classes. And the readers can then do whatever they want with these classes and elements.

To me it looks way more stable and easy to implement than the JS based approach. But maybe it has already been discussed somewhere and I just miss the downsides of this idea.

benoit74 avatar Nov 02 '25 20:11 benoit74

@benoit74 Kind of agree even if I don't fully understand the solution abou the TOC. We should:

  • Isolate the TOC issue
  • Close here the issue after a bit (to see if no new idea pops up)

kelson42 avatar Nov 12 '25 05:11 kelson42

There was already a previous PR to add the ToC API to mwOffliner and it got nearly to completion, but was never finalized..

But it's up to you. The JS API seemed like a good cross-app solution back in 2019. Not sure why it never gained traction. It seems a bit useless to have a whole API for one feature, when most apps have long-since added their own ToC. The JS apps construct a ToC just using any h1 h2 h3 elements in the document, and it works with Wikimedia, and with many other ZIMs too. No real need to add special classes.

Jaifroid avatar Nov 12 '25 07:11 Jaifroid