Skip to content

Commit

Permalink
Implement PWA for mobile experience (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpaulso authored Apr 25, 2024
1 parent 2b5f6f8 commit 4a7aad9
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 12 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/assets/images/favicon.png
Binary file not shown.
13 changes: 13 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,17 @@ def div_tag(content_or_options_with_block = nil, options = nil, &block)
content_tag(:div, content_or_options_with_block, options)
end
end

def meta_tag(name, content)
tag.meta(name: name, content: content)
end

def charset_tag(charset)
tag.meta(charset: charset)
end

def viewport_tag(content)
tag.meta(name: 'viewport', content: content)
end

end
24 changes: 18 additions & 6 deletions app/views/application/_head.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<head>
<title>HostedGPT</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= charset_tag('utf-8') %>
<%= viewport_tag('width=device-width,initial-scale=1') %>

<title><%= yield(:title) %></title>

<%= capybara_lockstep if defined?(Capybara::Lockstep) %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
Expand All @@ -11,9 +14,18 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
<%= favicon_link_tag asset_path("favicon.png") %>
<% %w(76 120 152 167 180).each do |size| %>
<%= favicon_link_tag asset_path("apple_touch_icons/logo_apple-touch-icon-#{size}x#{size}.png"), rel: 'apple-touch-icon', type: 'image/png', sizes: "#{size}x#{size}" %>

<!-- PWA -->
<link rel="manifest" href="/manifest.json">
<!-- ios-pwa-splash screen: from https://github.com/avadhesh18/iosPWASplash -->
<%= javascript_include_tag "https://unpkg.com/[email protected]/cdn.min.js" %>
<%= javascript_tag do %>
iosPWASplash('/apple-touch-icon.png', '#ffffff')
<% end %>
<!-- /ios-pwa-splash screen-->
<!-- /PWA -->

<%= render 'application/head/favicons' %>
<%= render 'application/head/meta_tags' %>
<%= content_for :head %>
</head>
</head>
3 changes: 3 additions & 0 deletions app/views/application/head/_favicons.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= favicon_link_tag "/favicon.svg", rel: 'icon', type: 'image/svg+xml' %>
<%= favicon_link_tag "/favicon.png", rel: 'icon', type: 'image/png' %>
<%= favicon_link_tag "/apple-touch-icon.png", rel: 'apple-touch-icon' %>
8 changes: 8 additions & 0 deletions app/views/application/head/_meta_tags.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% content_for :meta_tags do %>
<%= charset_tag('utf-8') %>
<%= meta_tag('mobile-web-app-capable','yes') %>
<%= meta_tag('apple-mobile-web-app-capable','yes') %>
<%= meta_tag('apple-mobile-web-app-status-bar-style','default') %>
<%= meta_tag('apple-touch-fullscreen','yes') %>
<% end %>
<%= yield :meta_tags %>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% mobile = false %>
<% content_for :title, "HostedGPT" %>
<!DOCTYPE html>
<html>
<%= render "head" %>
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/settings.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% content_for :title, "Settings — HostedGPT" %>
<% content_for :nav_column do %>
<header class="pl-2 py-7 text-3xl relative">
<%= link_to root_path, class: "inline-block cursor-pointer py-1 pt-0 align-middle" do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/settings/assistants/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
font-medium
|
%>
<%= link_to "Cancel", root_path, class: "float-right inline-block ml-5 mt-2 py-3" %>
<%= link_to "Cancel", root_path, class: "float-right inline-block ml-5 py-3" %>
</div>
4 changes: 2 additions & 2 deletions app/views/settings/people/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
data-transition-target="transitionable"
class="
list-decimal
my-3 p-2 pl-7
my-3 p-2 pl-8
border border-gray-200
bg-gray-50 dark:bg-transparent
hidden
Expand Down Expand Up @@ -97,7 +97,7 @@
data-transition-target="transitionable"
class="
list-decimal
my-3 p-2 pl-7
my-3 p-2 pl-8
border border-gray-200
bg-gray-50 dark:bg-transparent
hidden
Expand Down
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

config.hosts << /[a-z0-9\-]+\.ngrok-free\.app/
end
Binary file added public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-touch-icon-precomposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed public/favicon.ico
Empty file.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/google.svg

This file was deleted.

25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "HostedGPT",
"short_name": "HostedGPT",
"start_url": "/",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#fff",
"icons": [
{
"src": "/apple-touch-icon.png",
"type": "image/png",
"sizes": "180x180"
},
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
1 change: 0 additions & 1 deletion public/microsoft.svg

This file was deleted.

0 comments on commit 4a7aad9

Please sign in to comment.