lato 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/lato/application_controller.rb +51 -5
- data/app/views/lato/errors/error.html.erb +16 -0
- data/app/views/lato/errors/not_found.html.erb +12 -0
- data/app/views/lato/errors/offline.html.erb +11 -0
- data/config/routes.rb +3 -0
- data/lib/lato/version.rb +1 -1
- metadata +4 -5
- data/app/assets/images/lato/user-150x150.jpg +0 -0
- data/app/assets/images/lato/user-300x300.jpg +0 -0
- data/app/assets/images/lato/user-600x600.jpg +0 -0
- data/app/assets/images/lato/user-900x900.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1db687404de50caa57771e92de805873276c6c6c5ab0270f0b2c937c5a2c92a0
|
4
|
+
data.tar.gz: 7c33db6b23a3882e887b5b49487e1f5ce021a92fc25e375cda1969d546e381e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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 {
|
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
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.
|
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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|