Skip to content

Add support for redirect with fragments #1001

@benoit74

Description

@benoit74

Currently, libzim API allows to add a redirect from one path to another path.

In multiple scrapers (mwoffliner, freecodecamp, mindtouch, youtube ...), we need to add redirects so that we have proper entries in the title search index, but these redirects target must be a path and a fragment.

For instance in mwoffliner, when user search for "Geography of Nairobi" in WPEN, we need to redirect to "Nairobi#Geography" so that user is redirected to the "Geography" section of "Nairobi" article.

This is not supported by libzim which only supports redirect to a path.

For now, the workaround consists in adding a real ZIM item instead of the redirect, with minimal HTML content using a meta tag to immediately redirect:

<html>
  <head>
    <title>Geography of Nairobi</title>
    <meta http-equiv="refresh" content="0;URL='./Nairobi#Geography'" />
  </head>
  <body></body>
</html>

libzim should probably add support for these redirects with fragments natively.

The downside would be the impact on readers. If one needs to adapt readers to benefit from this new functionality (which I suspect might be the case), this would be a huge downside. For scrapers like freecodecamp, mindtouch and youtube, we use a Vue.JS UI so all redirects go to index.html and the fragment indicate which resource must be loaded. This is hence mandatory for proper operation of title search on these ZIMs. Should an old reader not be capable to "find" the fragment of the newer ZIM, then title search would not work anymore.

But we probably still must move this forward, and maybe wait few months / years to have sufficient updated readers in the wild before starting using this in ZIMs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions