Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PWA manifest enabling installation on android #20

Merged
merged 4 commits into from
Sep 14, 2023
Merged

Conversation

hexylena
Copy link
Contributor

This PR adds a 'manifest.json' which enables PWA features, and mainly that the user has the ability to "Install" the application.

The "installation" works best on android when done via chrome, as firefox does the simpler "shortcut" method even for proper PWAs, Chrome will send the site to their server which turns it into a shim APK which will then show up in the user's app list. Which makes it easier to discover and nicer for users.

Additionally a logo is added as that is required, I opted for the simple "W from wikipedia poorly censored" but please replace it if you like, it took 60 seconds to make and I needed the placeholder :)

(Here a screenshot from an earlier draft where I used a shorter version of the name for short_name)
screenshot of android app drawer showing checkID, chrome, "Cnsrdl" and Company apps.

Additional changes includes:

  • A service worker for the PWA. This is described as mandatory for PWAs but I have evidence to the contrary. Nevertheless it is included as it also provides a completely transparent cache for requests going to wikipedia which is nice for us and them.
  • improving metadata which results in nicer link previews when shared on social media (again please feel free to update this description accordingly)
  • yeah that's pretty much it

service-worker.js Outdated Show resolved Hide resolved
self.addEventListener('fetch', event => {
// Skip cross-origin requests, like those for Google Analytics.
console.log(event.request.url);
if (true || event.request.url.startsWith(self.location.origin)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this means the Wikipedia requests are not cached?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I should have cleaned this up, in the original version of the code it does indeed check that the event.request.url is our origin, but here I added the true || explicitly to permit requests to wikipedia's domains. Which of course renders this if case useless, I'll remove it entirely.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh duh, I missed that somehow.

@larsgw
Copy link
Owner

larsgw commented Aug 31, 2023

There's probably no way to adapt the theme color to the user settings right? There's whatwg/html#6569 (which is cool) but that is for the system settings.

@hexylena
Copy link
Contributor Author

hexylena commented Sep 4, 2023

I don't think so, without a dynamic server component. I've seen PWAs use dark and light colors for the theme_color field, and generally they match the header/nav colour.

@larsgw
Copy link
Owner

larsgw commented Sep 13, 2023

Sorry for the delays? What do you think of this as a logo?

512

@hexylena
Copy link
Contributor Author

Oh, that's way better! Love it!

@larsgw larsgw merged commit 135f399 into larsgw:main Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants