lato 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f43d6cefc6a6d28793af8e8e0f82496cfb75f48ab614decf2d58071e240c3230
4
- data.tar.gz: e536e7a7838ebb84ed3dc0c447abffea17c8d04f028ebc2eab8fda5cb0de14fa
3
+ metadata.gz: 617a6a9833946efc6beec01f4727fc13341a2c1993e03e82dcc82a07b7971779
4
+ data.tar.gz: 16670fad7ed0c70aeb2458ff7a0f82e26ee989f4e53f4a1dbe873e8bfae5c897
5
5
  SHA512:
6
- metadata.gz: 67af3cb7886ec232c561a7a42e788b0c3b5c6bdada6255d5133f992369296fc5f3cf1ec100b6c70ca9e9ff906abab28e1d37af5807e58837701dfffd8197ed6e
7
- data.tar.gz: 2ff3e3e0f43070274e37497dfc494c4c227182113587004367543b40d7cd61d2d332ccb9d8e699e812adeb19d3a94b973b6aa63bf30622ce8dc6445b14a03dac
6
+ metadata.gz: 15b916ded489425afa8fed3d3af9160324dc2836a37a101e191c3fb5076940b960e7d1898ef7899690ac2a1e993bd39f8c799534f93e01819bf823f8ee3cfca0
7
+ data.tar.gz: e801ceb370f8bd980c2d95a8d57fe60064767c502e4745f20b5f458ddf10b5ea293fdad61d7b8d07609ade0378de9a51c21d70453246020202914cc7bc69eb0d
@@ -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,14 @@ module Lato
12
14
  redirect_to @session.valid? ? session_root_path : lato.authentication_signin_path
13
15
  end
14
16
 
17
+ def not_found
18
+ respond_to_with_not_found
19
+ end
20
+
21
+ def error
22
+ respond_to_with_error
23
+ end
24
+
15
25
  def switch_locale
16
26
  I18n.locale = params[:locale]
17
27
  @session.user.update(locale: params[:locale]) if @session.valid?
@@ -35,17 +45,41 @@ module Lato
35
45
  I18n.locale = @session.user.locale || I18n.default_locale
36
46
  end
37
47
 
48
+ def respond_to_redirect_same_page(notice = nil)
49
+ respond_to do |format|
50
+ format.html { redirect_to request.referer, notice: notice }
51
+ format.json { render json: {} }
52
+ end
53
+ end
54
+
38
55
  def respond_to_with_not_found
56
+ hide_sidebar
39
57
  respond_to do |format|
40
- format.html { render plain: '', status: :not_found }
58
+ format.html { render 'lato/errors/not_found', status: :not_found }
41
59
  format.json { render json: {}, status: :not_found }
42
60
  end
43
61
  end
44
62
 
45
- def respond_to_redirect_same_page(notice = nil)
63
+ def respond_to_with_error(exception = nil)
64
+ @exception = Rails.env.production? ? nil : exception
65
+
66
+ hide_sidebar
46
67
  respond_to do |format|
47
- format.html { redirect_to request.referer, notice: notice }
48
- format.json { render json: {} }
68
+ format.html { render 'lato/errors/error', status: :internal_server_error }
69
+ format.json { render json: { error: @exception&.message || 'Internal server error' }, status: :internal_server_error }
70
+ end
71
+ end
72
+
73
+ def catch_exceptions
74
+ yield
75
+ rescue => exception
76
+ Rails.logger.error(exception.message)
77
+ Rails.logger.error(exception.backtrace.join("\n"))
78
+
79
+ if exception.is_a?(ActiveRecord::RecordNotFound)
80
+ respond_to_with_not_found
81
+ else
82
+ respond_to_with_error(exception)
49
83
  end
50
84
  end
51
85
  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>
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  Lato::Engine.routes.draw do
2
2
  root 'application#index'
3
+ get 'not_found', to: 'application#not_found', as: :not_found
4
+ get 'error', to: 'application#error', as: :error
3
5
 
4
6
  post '/switch_locale/:locale', to: 'application#switch_locale', as: 'switch_locale'
5
7
 
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
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.7
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,8 @@ 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
174
172
  - app/views/lato/mailer/invitation/invite_mail.html.erb
175
173
  - app/views/lato/mailer/user/email_verification_mail.html.erb
176
174
  - app/views/lato/mailer/user/password_update_mail.html.erb