lato 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f43d6cefc6a6d28793af8e8e0f82496cfb75f48ab614decf2d58071e240c3230
4
- data.tar.gz: e536e7a7838ebb84ed3dc0c447abffea17c8d04f028ebc2eab8fda5cb0de14fa
3
+ metadata.gz: 1db687404de50caa57771e92de805873276c6c6c5ab0270f0b2c937c5a2c92a0
4
+ data.tar.gz: 7c33db6b23a3882e887b5b49487e1f5ce021a92fc25e375cda1969d546e381e5
5
5
  SHA512:
6
- metadata.gz: 67af3cb7886ec232c561a7a42e788b0c3b5c6bdada6255d5133f992369296fc5f3cf1ec100b6c70ca9e9ff906abab28e1d37af5807e58837701dfffd8197ed6e
7
- data.tar.gz: 2ff3e3e0f43070274e37497dfc494c4c227182113587004367543b40d7cd61d2d332ccb9d8e699e812adeb19d3a94b973b6aa63bf30622ce8dc6445b14a03dac
6
+ metadata.gz: 80b25b7e6839a24be9a5041a1dbcc854a8d9257defb4fa5c6d8fd0cf62524bc846e332933324701885be9d359384ae02b5ac00e45f3f7cb0fcbdd6eaedf189f4
7
+ data.tar.gz: 1c66a00b3a9bfc71cb471df3eaec398d668271094527c88a8e25b01e8af977843dceaea955916fa9d8d6191fa5432259ebda300d551e42c20d7c308d31941372
@@ -4,6 +4,8 @@ module Lato
4
4
  include Lato::Layoutable
5
5
  include Lato::Componentable
6
6
 
7
+ around_action :catch_exceptions
8
+
7
9
  before_action :override_request_remote_ip
8
10
  before_action :set_default_locale
9
11
 
@@ -12,6 +14,18 @@ module Lato
12
14
  redirect_to @session.valid? ? session_root_path : lato.authentication_signin_path
13
15
  end
14
16
 
17
+ def offline
18
+ respond_to_with_offline
19
+ end
20
+
21
+ def not_found
22
+ respond_to_with_not_found
23
+ end
24
+
25
+ def error
26
+ respond_to_with_error
27
+ end
28
+
15
29
  def switch_locale
16
30
  I18n.locale = params[:locale]
17
31
  @session.user.update(locale: params[:locale]) if @session.valid?
@@ -35,17 +49,49 @@ module Lato
35
49
  I18n.locale = @session.user.locale || I18n.default_locale
36
50
  end
37
51
 
52
+ def respond_to_redirect_same_page(notice = nil)
53
+ respond_to do |format|
54
+ format.html { redirect_to request.referer, notice: notice }
55
+ format.json { render json: {} }
56
+ end
57
+ end
58
+
59
+ def respond_to_with_offline
60
+ hide_sidebar
61
+ respond_to do |format|
62
+ format.html { render 'lato/errors/offline', status: :service_unavailable }
63
+ format.json { render json: { error: 'Network not available' }, status: :service_unavailable }
64
+ end
65
+ end
66
+
38
67
  def respond_to_with_not_found
68
+ hide_sidebar
39
69
  respond_to do |format|
40
- format.html { render plain: '', status: :not_found }
41
- format.json { render json: {}, status: :not_found }
70
+ format.html { render 'lato/errors/not_found', status: :not_found }
71
+ format.json { render json: { error: 'Resource not found' }, status: :not_found }
42
72
  end
43
73
  end
44
74
 
45
- def respond_to_redirect_same_page(notice = nil)
75
+ def respond_to_with_error(exception = nil)
76
+ @exception = Rails.env.production? ? nil : exception
77
+
78
+ hide_sidebar
46
79
  respond_to do |format|
47
- format.html { redirect_to request.referer, notice: notice }
48
- format.json { render json: {} }
80
+ format.html { render 'lato/errors/error', status: :internal_server_error }
81
+ format.json { render json: { error: @exception&.message || 'Internal server error' }, status: :internal_server_error }
82
+ end
83
+ end
84
+
85
+ def catch_exceptions
86
+ yield
87
+ rescue => exception
88
+ Rails.logger.error(exception.message)
89
+ Rails.logger.error(exception.backtrace.join("\n"))
90
+
91
+ if exception.is_a?(ActiveRecord::RecordNotFound)
92
+ respond_to_with_not_found
93
+ else
94
+ respond_to_with_error(exception)
49
95
  end
50
96
  end
51
97
  end
@@ -0,0 +1,16 @@
1
+ <div class="w-100 h-100 d-flex justify-content-center align-items-center" style="min-height: calc(100vh - 54px - 2rem)">
2
+ <div class="card w-100" style="max-width: 600px">
3
+ <div class="card-header">
4
+ <h1 class="fs-3 mb-0 text-center">Internal server error</h1>
5
+ </div>
6
+ <div class="card-body text-center">
7
+ <p class="lead">Please try again later or contact the administrator.</p>
8
+ <a href="<%= lato.root_path %>" class="btn btn-primary">Go to homepage</a>
9
+ </div>
10
+ <% if @exception %>
11
+ <div class="card-body bg-light text-center">
12
+ <%= @exception.message %>
13
+ </div>
14
+ <% end %>
15
+ </div>
16
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="w-100 h-100 d-flex justify-content-center align-items-center" style="min-height: calc(100vh - 54px - 2rem)">
2
+ <div class="card w-100" style="max-width: 600px">
3
+ <div class="card-header">
4
+ <h1 class="fs-3 mb-0 text-center">Page not found</h1>
5
+ </div>
6
+ <div class="card-body text-center">
7
+ <p class="lead">The page you are looking for does not exist.</p>
8
+ <p class="lead">You may have mistyped the address or the page may have moved.</p>
9
+ <a href="<%= lato.root_path %>" class="btn btn-primary">Go to homepage</a>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -0,0 +1,11 @@
1
+ <div class="w-100 h-100 d-flex justify-content-center align-items-center" style="min-height: calc(100vh - 54px - 2rem)">
2
+ <div class="card w-100" style="max-width: 600px">
3
+ <div class="card-header">
4
+ <h1 class="fs-3 mb-0 text-center">Network not available</h1>
5
+ </div>
6
+ <div class="card-body text-center">
7
+ <p class="lead">Seems like you are offline.</p>
8
+ <p class="lead">You need to be connected to the internet to use this app.</p>
9
+ </div>
10
+ </div>
11
+ </div>
data/config/routes.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  Lato::Engine.routes.draw do
2
2
  root 'application#index'
3
+ get 'offline', to: 'application#offline', as: :offline
4
+ get 'not_found', to: 'application#not_found', as: :not_found
5
+ get 'error', to: 'application#error', as: :error
3
6
 
4
7
  post '/switch_locale/:locale', to: 'application#switch_locale', as: 'switch_locale'
5
8
 
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
@@ -105,10 +105,6 @@ files:
105
105
  - README.md
106
106
  - Rakefile
107
107
  - app/assets/config/lato_manifest.js
108
- - app/assets/images/lato/user-150x150.jpg
109
- - app/assets/images/lato/user-300x300.jpg
110
- - app/assets/images/lato/user-600x600.jpg
111
- - app/assets/images/lato/user-900x900.jpg
112
108
  - app/assets/javascripts/lato/application.js
113
109
  - app/assets/javascripts/lato/controllers/application.js
114
110
  - app/assets/javascripts/lato/controllers/index.js
@@ -171,6 +167,9 @@ files:
171
167
  - app/views/lato/components/_operation.html.erb
172
168
  - app/views/lato/components/_page_head.html.erb
173
169
  - app/views/lato/components/_sidebar_nav_item.html.erb
170
+ - app/views/lato/errors/error.html.erb
171
+ - app/views/lato/errors/not_found.html.erb
172
+ - app/views/lato/errors/offline.html.erb
174
173
  - app/views/lato/mailer/invitation/invite_mail.html.erb
175
174
  - app/views/lato/mailer/user/email_verification_mail.html.erb
176
175
  - app/views/lato/mailer/user/password_update_mail.html.erb