th_simple_admin_panel 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/app/assets/stylesheets/admin/layout.css.scss +15 -0
- data/app/helpers/simple_admin_panel/breadcrumb_helper.rb +33 -5
- data/app/views/layouts/simple_admin_panel/_alert.html.erb +1 -1
- data/app/views/layouts/simple_admin_panel/_breadcrumb.html.erb +35 -35
- data/app/views/layouts/simple_admin_panel/_navbar.html.erb +1 -1
- data/lib/simple_admin_panel/controller_extensions.rb +37 -27
- data/lib/simple_admin_panel/version.rb +1 -1
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NTVkYjk5ZjFlMWQxMmNjODcyOWZjYTJiYWVkODdjODgyZTBlZGFkYzA1ZTBi
|
10
|
-
Y2M1Y2Y4NjAwOWVjNjVjM2ViNWY1ZmU1MzZjNTQ5NzU5Nzc5NzMxOWIzZWU1
|
11
|
-
ZjQyOWUyNTQwMDBkYzAyYTA3Y2EzMjMyMzBkYzQ2OWRmNmY2NTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZGQ3ZGY1MmI5NTU1ODc0NWViMTQ0MTFiZjExNTcxZmUwYTI4OTc1OWI1ZDAz
|
14
|
-
Mzc1ODgyNjA5MmZkOGIwNGE3OWQ0ODAwODc2ODQzODkyNWRiZTBiMjhjODE5
|
15
|
-
OTk3OWNhMGZmNzRkMDIyNGYwYWQxMTI0MDAwOGQxODFkOWVhZWU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ece1d61dc67786f55d4307143c5825e031f85033
|
4
|
+
data.tar.gz: 40253b257fa616d6fa9bc3c0f6fa4fd33e892a44
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 51cea21e9d4abb12cde75543a460f53837436f24cb297124de238697ddc54cd75fb2fa27642aaf7d514c58bbde85fe1b51024a12be2344f20e401d2e2ef63052
|
7
|
+
data.tar.gz: e96f006a932d8b332467eca652028e8aad8be750f3ec5a17d5f2bbda73696b3784d7904ee9835be62e228b706b2c2afd22573c468dcfc064c397c2d3d32208bc
|
@@ -15,3 +15,18 @@
|
|
15
15
|
ul.breadcrumb li.pull-right {
|
16
16
|
margin-left: 3px;
|
17
17
|
}
|
18
|
+
|
19
|
+
.breadcrumb-search-form {
|
20
|
+
margin: 1px 0 0 0;
|
21
|
+
|
22
|
+
&.with-accesskey-text:before, &.with-initkey-text:before {
|
23
|
+
margin: 3px;
|
24
|
+
}
|
25
|
+
|
26
|
+
input[type="text"].breadcrumb-search-input {
|
27
|
+
font-size: 10.5px;
|
28
|
+
padding: 0px 6px;
|
29
|
+
@include border-radius(3px);
|
30
|
+
line-height: 12px;
|
31
|
+
}
|
32
|
+
}
|
@@ -1,9 +1,37 @@
|
|
1
1
|
module SimpleAdminPanel
|
2
2
|
module BreadcrumbHelper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def label_for_resource resource
|
4
|
+
%w(label name title to_s).each do |attr|
|
5
|
+
return resource.public_send attr if resource.respond_to? attr
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def should_render_new_resource_button?
|
10
|
+
controller.respond_to?(:new) && can?(:create, resource_class) && (new_resource_path rescue nil).present?
|
11
|
+
end
|
12
|
+
|
13
|
+
def should_render_delete_resource_button?
|
14
|
+
controller.respond_to?(:destroy) && can?(:destroy, resource)
|
15
|
+
end
|
16
|
+
|
17
|
+
def should_render_edit_resource_button?
|
18
|
+
controller.respond_to?(:edit) && can?(:edit, resource)
|
19
|
+
end
|
20
|
+
|
21
|
+
def divider
|
22
|
+
"<span class=divider>/</span>".html_safe
|
23
|
+
end
|
24
|
+
|
25
|
+
def translated_resource_name
|
26
|
+
label_for_resource association_item
|
27
|
+
end
|
28
|
+
|
29
|
+
def translated_collection_name
|
30
|
+
resource_class.model_name.human count: 2
|
31
|
+
end
|
32
|
+
|
33
|
+
def translated_resource_action
|
34
|
+
t ".actions.#{resource_class.model_name.to_s.underscore}.#{params[:action]}", default: t(".actions.#{params[:action]}")
|
35
|
+
end
|
8
36
|
end
|
9
37
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
<ul class="breadcrumb">
|
2
|
-
|
3
|
-
|
2
|
+
<% if respond_to?(:association_chain) %>
|
3
|
+
<li><%= link_to "Home", admin_root_path %> <%= divider %></li>
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
<% association_chain.each do |association_item| %>
|
6
|
+
<li><%= link_to association_item.class.model_name.human(count: 2), url_for(controller: association_item.class.model_name.to_s.underscore.pluralize, action: :index) %> <%= divider %></li>
|
7
|
+
<li><%= link_to label_for_resource(association_item), url_for(controller: association_item.class.model_name.to_s.underscore.pluralize, action: :show, id: association_item.id) %> <%= divider %></li>
|
8
|
+
<% end %>
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
<% if %w(new create).include?(params[:action]) %>
|
11
|
+
<li><%= link_to translated_collection_name, collection_path %> <%= divider %></li>
|
12
|
+
<li class="active"><%= translated_resource_action %></li>
|
13
|
+
<% elsif params[:action] == "index" %>
|
14
|
+
<li class="active"><%= translated_collection_name %></li>
|
15
|
+
<% if should_render_new_resource_button? %>
|
16
|
+
<li class="pull-right"><%= link_to icon("plus") + " Aanmaken", new_resource_path, class: "btn btn-mini" %></li>
|
17
|
+
<% end %>
|
18
18
|
|
19
19
|
<% if respond_to?(:keyword_search_key) && keyword_search_key.present? %>
|
20
20
|
<li class="pull-right">
|
@@ -26,25 +26,25 @@
|
|
26
26
|
</li>
|
27
27
|
<% end %>
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
29
|
+
<% elsif params[:action] == "show" %>
|
30
|
+
<li><%= link_to translated_collection_name, collection_path %> <%= divider %></li>
|
31
|
+
<li class="active"><%= label_for_resource resource %></li>
|
32
|
+
<% if should_render_delete_resource_button? %>
|
33
|
+
<li class="pull-right"><%= link_to icon("trash icon-white") + " Verwijderen", resource_path, class: "btn btn-mini btn-danger", method: :delete, data: { confirm: "Are you sure to delete #{resource_class.model_name.human(count: 1)} '#{label_for_resource resource}'?" } %></li>
|
34
|
+
<% end %>
|
35
|
+
<% if should_render_edit_resource_button? %>
|
36
|
+
<li class="pull-right"><%= link_to icon("edit icon-white") + " Wijzigen", edit_resource_path, class: "btn btn-mini btn-info" %></li>
|
37
|
+
<% end %>
|
38
|
+
<% else %>
|
39
|
+
<li><%= link_to translated_collection_name, collection_path %> <%= divider %></li>
|
40
|
+
<% if params[:id].present? %>
|
41
|
+
<li><%= link_to_if controller.respond_to?(:show) && can?(:show, resource), label_for_resource(resource), resource_path %> <%= divider %></li>
|
42
|
+
<% end %>
|
43
|
+
<li class="active"><%= translated_resource_action %></li>
|
44
|
+
<% end %>
|
45
|
+
<% else %>
|
46
|
+
<li class="active">Home</li>
|
47
|
+
<% end %>
|
48
48
|
|
49
|
-
|
50
|
-
</ul>
|
49
|
+
<%= content_for :actions %>
|
50
|
+
</ul>
|
@@ -1,36 +1,46 @@
|
|
1
1
|
module SimpleAdminPanel::ControllerExtensions
|
2
|
-
|
2
|
+
extend ActiveSupport::Concern
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
before_filter :apply_keyword_search_key
|
12
|
-
end
|
4
|
+
included do
|
5
|
+
layout "simple_admin_panel/application"
|
6
|
+
helper SimpleAdminPanel::BreadcrumbHelper
|
7
|
+
before_filter :authenticate_user!
|
8
|
+
before_filter :require_admin
|
9
|
+
before_filter :require_active
|
10
|
+
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
protected
|
13
|
+
def require_active
|
14
|
+
return if current_user.active
|
15
|
+
flash["error"] = "Deze pagina is alleen toegankelijk voor actieve gebruikers."
|
16
|
+
redirect_to root_path
|
17
|
+
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
def require_admin
|
20
|
+
return if current_user.admin
|
21
|
+
flash["error"] = "Deze pagina is alleen toegankelijk voor admins."
|
22
|
+
redirect_to root_path
|
23
|
+
end
|
26
24
|
|
27
25
|
def apply_keyword_search_key
|
28
|
-
|
29
|
-
|
30
|
-
params[:search][keyword_search_key] = params[:qs] if keyword_search_key.present? && params[:qs].present?
|
31
|
-
end
|
26
|
+
params[:q] ||= {}
|
27
|
+
params[:q][keyword_search_key] = params[:qs] if keyword_search_key && params[:qs].present?
|
32
28
|
end
|
33
29
|
|
34
|
-
|
35
|
-
|
30
|
+
module ClassMethods
|
31
|
+
def keyword_search_key search_key
|
32
|
+
self.send :define_method, :keyword_search_key do
|
33
|
+
search_key
|
34
|
+
end
|
35
|
+
self.send :helper_method, :keyword_search_key
|
36
|
+
self.send :before_filter, :apply_keyword_search_key
|
37
|
+
end
|
38
|
+
|
39
|
+
def permit *args
|
40
|
+
permitted_params = *args
|
41
|
+
self.send :define_method, :permitted_params do
|
42
|
+
params.permit resource_instance_name => permitted_params
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
36
46
|
end
|
metadata
CHANGED
@@ -1,78 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: th_simple_admin_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Hinloopen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jquery-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: inherited_resources
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: kaminari
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Base admin panel.
|
70
70
|
email:
|
71
|
-
- toby@
|
71
|
+
- toby@zisoo.nl
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.rdoc
|
78
|
+
- Rakefile
|
76
79
|
- app/assets/javascripts/simple_admin_panel.js
|
77
80
|
- app/assets/stylesheets/admin/layout.css.scss
|
78
81
|
- app/controllers/simple_admin_panel/application_controller.rb
|
@@ -82,19 +85,19 @@ files:
|
|
82
85
|
- app/views/layouts/simple_admin_panel/_navbar.html.erb
|
83
86
|
- app/views/layouts/simple_admin_panel/application.html.erb
|
84
87
|
- config/routes.rb
|
88
|
+
- lib/simple_admin_panel.rb
|
85
89
|
- lib/simple_admin_panel/controller_extensions.rb
|
86
90
|
- lib/simple_admin_panel/engine.rb
|
87
91
|
- lib/simple_admin_panel/version.rb
|
88
|
-
- lib/simple_admin_panel.rb
|
89
92
|
- lib/tasks/simple_admin_panel_tasks.rake
|
90
|
-
-
|
91
|
-
- Rakefile
|
92
|
-
- README.rdoc
|
93
|
+
- test/dummy/README.rdoc
|
94
|
+
- test/dummy/Rakefile
|
93
95
|
- test/dummy/app/assets/javascripts/application.js
|
94
96
|
- test/dummy/app/assets/stylesheets/application.css
|
95
97
|
- test/dummy/app/controllers/application_controller.rb
|
96
98
|
- test/dummy/app/helpers/application_helper.rb
|
97
99
|
- test/dummy/app/views/layouts/application.html.erb
|
100
|
+
- test/dummy/config.ru
|
98
101
|
- test/dummy/config/application.rb
|
99
102
|
- test/dummy/config/boot.rb
|
100
103
|
- test/dummy/config/database.yml
|
@@ -110,13 +113,10 @@ files:
|
|
110
113
|
- test/dummy/config/initializers/wrap_parameters.rb
|
111
114
|
- test/dummy/config/locales/en.yml
|
112
115
|
- test/dummy/config/routes.rb
|
113
|
-
- test/dummy/config.ru
|
114
116
|
- test/dummy/public/404.html
|
115
117
|
- test/dummy/public/422.html
|
116
118
|
- test/dummy/public/500.html
|
117
119
|
- test/dummy/public/favicon.ico
|
118
|
-
- test/dummy/Rakefile
|
119
|
-
- test/dummy/README.rdoc
|
120
120
|
- test/dummy/script/rails
|
121
121
|
- test/integration/navigation_test.rb
|
122
122
|
- test/simple_admin_panel_test.rb
|
@@ -130,17 +130,17 @@ require_paths:
|
|
130
130
|
- lib
|
131
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
132
|
requirements:
|
133
|
-
- -
|
133
|
+
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.2.2
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Base admin panel.
|