not_found_catcher 0.1.1 → 0.1.2
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 +4 -4
- data/app/assets/stylesheets/not_found_catcher/scaffold.css +43 -0
- data/app/controllers/not_found_catcher/roles_controller.rb +4 -1
- data/app/lib/not_found_catcher/request_store.rb +10 -0
- data/app/models/not_found_catcher/role.rb +12 -1
- data/app/views/layouts/not_found_catcher/application.html.erb +2 -2
- data/lib/not_found_catcher/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be729cb9d47f23ef15271fa995c3df3d4715ce66
|
4
|
+
data.tar.gz: c98e3a14011a8b2f4a01ed69be9aef1d694867f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad9568bab8851ad595f17b0d7f5631ee040cd10e555a5a3b312cb317666103240180ddad49c02c27234e460e2ee028e80030b4ad809b47824f0bebbef81e563f
|
7
|
+
data.tar.gz: 165c2abf4a01399a2661263d9055e81066ced355260f17e92318c1a6bde1364e44a14cad8cca424ed6c8924be480901cacc2f266b20441b162b36ad2aa040326
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
.not_found_catcher div.field,
|
3
|
+
.n.not_found_catcher ot_found_catcher div.actions {
|
4
|
+
margin-bottom: 10px;
|
5
|
+
}
|
6
|
+
|
7
|
+
.not_found_catcher #notice {
|
8
|
+
color: green;
|
9
|
+
}
|
10
|
+
|
11
|
+
.not_found_catcher .field_with_errors {
|
12
|
+
padding: 2px;
|
13
|
+
background-color: red;
|
14
|
+
display: table;
|
15
|
+
}
|
16
|
+
|
17
|
+
.not_found_catcher #error_explanation {
|
18
|
+
width: 450px;
|
19
|
+
border: 2px solid red;
|
20
|
+
padding: 7px 7px 0;
|
21
|
+
margin-bottom: 20px;
|
22
|
+
background-color: #f0f0f0;
|
23
|
+
}
|
24
|
+
|
25
|
+
.not_found_catcher #error_explanation h2 {
|
26
|
+
text-align: left;
|
27
|
+
font-weight: bold;
|
28
|
+
padding: 5px 5px 5px 15px;
|
29
|
+
font-size: 12px;
|
30
|
+
margin: -7px -7px 0;
|
31
|
+
background-color: #c00;
|
32
|
+
color: #fff;
|
33
|
+
}
|
34
|
+
|
35
|
+
.not_found_catcher #error_explanation ul li {
|
36
|
+
font-size: 12px;
|
37
|
+
list-style: square;
|
38
|
+
}
|
39
|
+
|
40
|
+
.not_found_catcher label {
|
41
|
+
display: block;
|
42
|
+
}
|
43
|
+
|
@@ -21,7 +21,9 @@ module NotFoundCatcher
|
|
21
21
|
@obj.save
|
22
22
|
f.html {redirect_to root_path}
|
23
23
|
else
|
24
|
-
|
24
|
+
f.html {
|
25
|
+
render :edit
|
26
|
+
}
|
25
27
|
end
|
26
28
|
|
27
29
|
end
|
@@ -41,6 +43,7 @@ module NotFoundCatcher
|
|
41
43
|
end
|
42
44
|
|
43
45
|
private
|
46
|
+
|
44
47
|
def load_object
|
45
48
|
@obj = NotFoundCatcher.request_store.find(params[:id]).model
|
46
49
|
end
|
@@ -68,6 +68,16 @@ class NotFoundCatcher::RequestStore
|
|
68
68
|
rule
|
69
69
|
end
|
70
70
|
|
71
|
+
def find_by_redirect(key)
|
72
|
+
rule = nil
|
73
|
+
store.transaction(true) do
|
74
|
+
store.roots.each do |k|
|
75
|
+
rule = store[k] if store[k].redirect == key
|
76
|
+
end
|
77
|
+
end
|
78
|
+
rule
|
79
|
+
end
|
80
|
+
|
71
81
|
##
|
72
82
|
# Store yaml
|
73
83
|
def store
|
@@ -7,6 +7,8 @@ module NotFoundCatcher
|
|
7
7
|
attribute :http_method, :string
|
8
8
|
attribute :redirect, :string
|
9
9
|
|
10
|
+
validate :check_redirect_uniqueness
|
11
|
+
|
10
12
|
|
11
13
|
def persisted?
|
12
14
|
true
|
@@ -26,7 +28,16 @@ module NotFoundCatcher
|
|
26
28
|
|
27
29
|
end
|
28
30
|
|
29
|
-
|
31
|
+
delegate :destroy, to: :request_parser
|
32
|
+
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def check_redirect_uniqueness
|
37
|
+
unless self.redirect.blank?
|
38
|
+
self.errors.add(:redirect, :not_unique) if NotFoundCatcher.request_store.find_by_redirect(self.redirect)
|
39
|
+
end
|
40
|
+
end
|
30
41
|
|
31
42
|
end
|
32
43
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Not found catcher</title>
|
5
|
-
<%= stylesheet_link_tag
|
5
|
+
<%= stylesheet_link_tag "not_found_catcher/application", media: "all" %>
|
6
6
|
<%= javascript_include_tag "not_found_catcher/application" %>
|
7
7
|
<%= csrf_meta_tags %>
|
8
8
|
</head>
|
9
|
-
<body>
|
9
|
+
<body class="not_found_catcher">
|
10
10
|
|
11
11
|
<%= yield %>
|
12
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: not_found_catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marino Bonetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: sqlite3
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
47
|
description: 'Mountable Engine to catch not_found_errors and to administrate redirects '
|
62
48
|
email:
|
63
49
|
- marinobonetti@gmail.com
|
@@ -71,6 +57,7 @@ files:
|
|
71
57
|
- app/assets/config/not_found_catcher_manifest.js
|
72
58
|
- app/assets/javascripts/not_found_catcher/application.js
|
73
59
|
- app/assets/stylesheets/not_found_catcher/application.css
|
60
|
+
- app/assets/stylesheets/not_found_catcher/scaffold.css
|
74
61
|
- app/controllers/not_found_catcher/application_controller.rb
|
75
62
|
- app/controllers/not_found_catcher/exceptions_controller.rb
|
76
63
|
- app/controllers/not_found_catcher/roles_controller.rb
|