My phone’s data plan is 500/MB per month. This low cap makes me think very conservatively about what gets sent across the modem as I’m going about my day.

While a good source of information, the OpenStreetMap Wiki is not viewable offline. There is no native app nor a PWA to use. The ZIM files from Kiwix are very outdated (at the time of writing).

A clever solution is to retrofit the existing Wikipedia App for Android, which already has a “Save page offline” feature and a very nice interface. It might even be as simple as changing the urls. After all, most Wiki sites share a similar backend and API, called Mediawiki, and I was hoping to hook into this feature.

Progress

The primary reason for this retrofit’s difficulty is Wikipedia’s different (slightly proprietary) rest API. It isn’t shared with the mediawiki suite. This is outlined very clearly in the API comparison table.

OK, so a lot more needs to change for OSM to wriggle its way into this app.

‘Simply’ Changing the URLs

I had some promising results after changing the base rest_api URL to the ‘old’ Mediawiki target. Search now works immediately.

Wikipedia app screenshot of search working

However, internal pages didn’t work. Each wiki page in the app expects a well formatted summary from the API.

I could get around this by changing the request for a /summary to the full /html of that article, and now we’re getting closer.

Wikipedia app screenshot 1, working as a browser with inner html

Wikipedia app screenshot 2, working as a browser with inner html

Of course there were some other bugs that needed to be ironed out, but those didn’t seem critical. Mainly CSS and indexing issues.

Wikipedia app ugly inner HTML and missing table of contents

Save to Offline did not work, I’m not sure why yet.

What do

At this point I’m unsure if retrofitting the Wikipedia app is worth it. Rigging the app enough to do what I want would entail only a few more things:

  1. Custom CSS injection to fix the worst of the /html responses.
  2. Figure out why Save Offline doesn’t work.

I’m working on this now in my little free time.

100% by-the-booke correct

To do this properly, and not rigged just enough for Quinn’s phone, we would need way more. All the following:

  1. A well-formatted response (or converted response) from the Mediawiki API that is not in a Wiki format nor the ugly HTML. Markdown with inline images would be great.
  2. The remainder of the rest_v1 endpoints converted in the App’s RestService.kt and subsequent serializers.
  3. Reworking the Save to Offline feature, adapting the new (old) responses to the underlying SQLite schema.

I’m not jazzed at those prospects, even less so when you consider keeping up to date with upstream.

I’ll continue to try rigging it.

My Other Idea for Offline OSM Wiki

I’d like to investigate .zim files.

  1. How Kiwix packages wikis into openZIM format.
  2. If I can do this for OpenStreetMap on a more regular basis.
  3. If I can build a slightly nicer app to parse custom .zims.
  4. What do .zims know, do they know things? Let’s find out.