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

Implement PWA for mobile experience #282

Merged
merged 37 commits into from
Apr 25, 2024
Merged

Conversation

jasonpaulso
Copy link
Contributor

Closes #205 (hopefully...)

  • adds and initializes serviceworker gem
  • adds tag helpers for head
  • implements tag helpers in head
  • adds PWA related tags and scripts for splash screen
  • adds manifest.json
  • adds new icons for PWA
  • adds <% content_for :title ... %> to home and settings views

Jason Schulz and others added 23 commits April 18, 2024 15:02
* chore: add serviceworker-rails gem to Gemfile
* chore: add .ruby-version file with version 3.2.3
* chore: add favicon.svg, android-chrome-192x192.png, android-chrome-512x512.png, apple-touch-icon.png, and manifest.json files
* chore: update application_helper.rb with meta_tag, charset_tag, and viewport_tag methods
* chore: update application/_head.html.erb with charset_tag and viewport_tag
* chore: update application/head/_meta_tags.html.erb with meta tags
* chore: update application/head/_favicons.html.erb with favicon links
* chore: update layouts/application.html.erb with title tag
* chore: update layouts/settings.html.erb with title tag
…ML-encoded entities to display and add tests for verification.
…de_proc implementation

* fix(redcarpet/custom_html_renderer.rb): remove unused block_code method
… block_code

* fix(messages_helper.rb): remove unnecessary empty line
* fix(custom_html_renderer.rb): remove unused initialize method
* fix(custom_html_renderer.rb): remove unnecessary empty line
Co-authored-by: Jason Schulz <jason@schulz.studio>
Co-authored-by: Jason Schulz <jason@schulz.studio>
…ML-encoded entities to display and add tests for verification.
… block_code

* fix(messages_helper.rb): remove unnecessary empty line
* fix(custom_html_renderer.rb): remove unused initialize method
* fix(custom_html_renderer.rb): remove unnecessary empty line
… block_code

* fix(messages_helper.rb): remove unnecessary empty line
* fix(custom_html_renderer.rb): remove unused initialize method
* fix(custom_html_renderer.rb): remove unnecessary empty line
… block_code

* fix(messages_helper.rb): remove unnecessary empty line
* fix(custom_html_renderer.rb): remove unused initialize method
* fix(custom_html_renderer.rb): remove unnecessary empty line
… block_code

* fix(messages_helper.rb): remove unnecessary empty line
* fix(custom_html_renderer.rb): remove unused initialize method
* fix(custom_html_renderer.rb): remove unnecessary empty line
@jasonpaulso
Copy link
Contributor Author

@krschacht what can you tell me about the The section #messages was able to move down so it was not at the bottom. error?

@krschacht
Copy link
Contributor

krschacht commented Apr 20, 2024 via email

@krschacht krschacht changed the title #205 Implement PWA for mobile experience Apr 21, 2024
// Perform install steps
event.waitUntil(
caches.open('static').then(function (cache) {
return cache.addAll(['/', '/index.html', '/css/style.css', '/js/app.js'])
Copy link
Contributor

Choose a reason for hiding this comment

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

@jasonpaulso I'm not super familiar with service workers, but it looks like this is caching some specific files. Will these files be properly reloaded when new versions are pushed? I'm noticing those don't have the usual rails asset pipeline cache busting stuff within the filenames.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for the confusion with that file—the service worker stuff is somewhat new to me as well, in particular with how it works in Rails. I got a bit overzealous and ultimately forgot to revisit that part when before I submitted the pull request. My mistake! It is safe to disregard that part for now. It's not strictly necessary (and isn't really doing anything yet). I should have time to properly flesh that out tomorrow.

Copy link
Contributor

@krschacht krschacht left a comment

Choose a reason for hiding this comment

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

@jasonpaulso I pulled this branch down and did a bunch of testing on my local machine. It's working really well, nice work on this. I basically think we should deploy it as-is and I used this opportunity to document a bunch of further improvements we can make to the mobile version of the app but that's stuff we should look at later.

However, take a look at a few comments I left just to make sure these things are okay.

@@ -0,0 +1,3 @@
<%= favicon_link_tag asset_path("/favicon.svg"), rel: 'icon', type: 'image/svg+xml' %>
<%= favicon_link_tag asset_path("/favicon.png"), rel: 'icon', type: 'image/png' %>
Copy link
Contributor

Choose a reason for hiding this comment

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

We were previously serving only the favicon.png but it was being done from the asset_path. I added that helper back in and moved PNG into that directory. Is that okay? I assume so.

I also updated the SVG so it would have a transparent background in order to match the PNG. But I did not know how to do this quickly from the ICO file so I simply deleted it. Do you think we need to have an ICO file as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was encountering a minor issue with regard to the favicon in the asset_path. When using Safari, if you click the "share" button and then look at the terminal output you should see routing errors like ActionController::RoutingError (No route matches [GET] "/favicon.png") and ActionController::RoutingError (No route matches [GET] "/favicon.svg") despite the files existing in the asset path.
I do not think we need the ico file. I used a figma plugin to generate the icons and it was included, so I dropped it in there.

@krschacht
Copy link
Contributor

krschacht commented Apr 24, 2024

@jasonpaulso I really appreciate how knowledgable you are about this PWA stuff! I just caught up on your comments and it sounds like you have an additional change to make to the serviceworker? I won't merge this in quite yet.

I'm about to update the asset_path() change that I made simply to undo it and clean up the old files. I'll push that small commit to this branch shortly.

Aside from those two things, there are two items on my "Future PWA improvements" list that I want to call your attention to. What do you think of these two?

#298

The first on that list is about the overall icon seeming a bit tight (favicon is good, I just mean app icon). What's your opinion on that? This is admittedly a bit nitpicky so maybe it's just me, and plus, I don't know how easy that is to fix.

The second is probably a bug with the ios-pwa-splash unpkg link? Again, I don't know how hard that might be to fix.

I'm okay leaving both those issues in this PR and we can fix going forward, but chime in and let me know what you think because if either is easy it may be worth fixing now.

@jasonpaulso
Copy link
Contributor Author

I'd say we can just remove the service worker file and gem for now. There isn't much use for it yet, considering the app has no push notifications and doesn't really work without network connection. As far as the rest, I cannot repro the iPad issue—on my iPad and simulator the splash screen dismisses too quickly to get a look at it. There are other options we can look into instead of ios-pwa-splash though. Regarding the icon, I agree that it's not so comfortable on the home screen or dock. I can make some quick changes to it and we can see how it feels.

Jason Schulz and others added 3 commits April 24, 2024 16:06
* chore(Gemfile.lock): remove 'serviceworker-rails' dependency
* chore(serviceworker.js): remove serviceworker.js file
* asset(apple-touch-icon.png): replacing icons with more padding
@krschacht
Copy link
Contributor

Merging in! I love that it's actually usable on mobile now. :) It was pretty painful to use the app before with the browser toolbar present.

@krschacht krschacht merged commit 4a7aad9 into AllYourBot:main Apr 25, 2024
4 checks passed
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.

Get the full PWA configuration done for mobile “installed”
2 participants