adminsite 2.1.2 → 3.0.0

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
  SHA1:
3
- metadata.gz: 19d396b76029c39ad67a1f2d2ef6257eaad32cf6
4
- data.tar.gz: f3fb9c4f7ef39c13d17caf8550c8d98890da3d69
3
+ metadata.gz: 11c32678a8ab293d0703a6fdc62aa286020c03d6
4
+ data.tar.gz: c35eeb7d4e9826bff2a4abae767b43c489b279d4
5
5
  SHA512:
6
- metadata.gz: c9918c79e62f8c32bbaf4a7d8ae51049180ac3812e04a3adc7e0d13c315d540e0d1b934f7343dc226402b6b06baf04a943fdd3a6cde5103ee3a760082df4b421
7
- data.tar.gz: 3027a002d44c0e842ba0c1792046054078925536316564a1539a82eacc02aa38282759a4878dee8e55675f9405c8763c0ca09648f088d59fc521cf4d82cdc901
6
+ metadata.gz: 90ce2e5e69b13b7cbcdbd112a64c23b06af461e76d98fd661349c0053c2110f485e9534869cb7e6e3ce20bd51adccf11f1d8eebcf4f35c915c5c5bd39980d49d
7
+ data.tar.gz: db55ffd765b8f17913496be694d79a9c87a94667037775e9b45f0069e4949861198e7549f8f143c062af49e91cba2fed98f45e5bababe7ced1e7919ab474dc69
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adminsite (2.1.2)
4
+ adminsite (3.0.0)
5
5
  actionpack-page_caching
6
+ cancancan (~> 1.10)
6
7
  codemirror-rails (>= 4.8)
7
8
  devise (~> 3.4)
8
9
  domainatrix
@@ -56,17 +57,19 @@ GEM
56
57
  minitest (~> 5.1)
57
58
  thread_safe (~> 0.3, >= 0.3.4)
58
59
  tzinfo (~> 1.1)
59
- addressable (2.3.8)
60
+ addressable (2.4.0)
60
61
  arel (6.0.3)
61
- bcrypt (3.1.10)
62
+ bcrypt (3.1.11)
62
63
  builder (3.2.2)
64
+ cancancan (1.13.1)
63
65
  climate_control (0.0.3)
64
66
  activesupport (>= 3.0)
65
- cocaine (0.5.7)
67
+ cocaine (0.5.8)
66
68
  climate_control (>= 0.0.3, < 1.0)
67
- codemirror-rails (5.6)
69
+ codemirror-rails (5.11)
68
70
  railties (>= 3.0, < 5)
69
- devise (3.5.2)
71
+ concurrent-ruby (1.0.1)
72
+ devise (3.5.6)
70
73
  bcrypt (~> 3.0)
71
74
  orm_adapter (~> 0.1)
72
75
  railties (>= 3.2.6, < 5)
@@ -78,15 +81,15 @@ GEM
78
81
  domainatrix (0.0.11)
79
82
  addressable
80
83
  erubis (2.7.0)
81
- formtastic (3.1.3)
84
+ formtastic (3.1.4)
82
85
  actionpack (>= 3.2.13)
83
86
  globalid (0.3.6)
84
87
  activesupport (>= 4.1.0)
85
88
  haml (4.0.7)
86
89
  tilt
87
90
  i18n (0.7.0)
88
- jquery-rails (4.0.5)
89
- rails-dom-testing (~> 1.0)
91
+ jquery-rails (4.1.1)
92
+ rails-dom-testing (>= 1, < 3)
90
93
  railties (>= 4.2.0)
91
94
  thor (>= 0.14, < 2.0)
92
95
  json (1.8.3)
@@ -96,22 +99,24 @@ GEM
96
99
  liquid (3.0.6)
97
100
  loofah (2.0.3)
98
101
  nokogiri (>= 1.5.9)
99
- mail (2.6.3)
100
- mime-types (>= 1.16, < 3)
101
- mime-types (2.6.2)
102
+ mail (2.6.4)
103
+ mime-types (>= 1.16, < 4)
104
+ mime-types (3.0)
105
+ mime-types-data (~> 3.2015)
106
+ mime-types-data (3.2016.0221)
102
107
  mimemagic (0.3.0)
103
- mini_portile (0.6.2)
108
+ mini_portile2 (2.0.0)
104
109
  minitest (5.7.0)
105
- nokogiri (1.6.6.2)
106
- mini_portile (~> 0.6.0)
110
+ nokogiri (1.6.7.2)
111
+ mini_portile2 (~> 2.0.0.rc2)
107
112
  orm_adapter (0.5.0)
108
- paperclip (4.3.1)
113
+ paperclip (4.3.6)
109
114
  activemodel (>= 3.2.0)
110
115
  activesupport (>= 3.2.0)
111
116
  cocaine (~> 0.5.5)
112
117
  mime-types
113
118
  mimemagic (= 0.3.0)
114
- polyamorous (1.2.0)
119
+ polyamorous (1.3.0)
115
120
  activerecord (>= 3.0)
116
121
  rack (1.6.4)
117
122
  rack-test (0.6.3)
@@ -133,7 +138,7 @@ GEM
133
138
  activesupport (>= 4.2.0.beta, < 5.0)
134
139
  nokogiri (~> 1.6.0)
135
140
  rails-deprecated_sanitizer (>= 1.0.1)
136
- rails-html-sanitizer (1.0.2)
141
+ rails-html-sanitizer (1.0.3)
137
142
  loofah (~> 2.0)
138
143
  railties (4.2.3)
139
144
  actionpack (= 4.2.3)
@@ -149,8 +154,8 @@ GEM
149
154
  polyamorous (~> 1.2)
150
155
  rdoc (4.2.0)
151
156
  json (~> 1.4)
152
- responders (2.1.0)
153
- railties (>= 4.2.0, < 5)
157
+ responders (2.1.2)
158
+ railties (>= 4.2.0, < 5.1)
154
159
  rspec (3.3.0)
155
160
  rspec-core (~> 3.3.0)
156
161
  rspec-expectations (~> 3.3.0)
@@ -164,7 +169,7 @@ GEM
164
169
  diff-lcs (>= 1.2.0, < 2.0)
165
170
  rspec-support (~> 3.3.0)
166
171
  rspec-support (3.3.0)
167
- sass (3.4.19)
172
+ sass (3.4.22)
168
173
  sass-rails (5.0.4)
169
174
  railties (>= 4.0.0, < 5.0)
170
175
  sass (~> 3.1)
@@ -182,18 +187,19 @@ GEM
182
187
  json (~> 1.8)
183
188
  simplecov-html (~> 0.10.0)
184
189
  simplecov-html (0.10.0)
185
- sprockets (3.4.0)
190
+ sprockets (3.6.0)
191
+ concurrent-ruby (~> 1.0)
186
192
  rack (> 1, < 3)
187
- sprockets-rails (2.3.3)
188
- actionpack (>= 3.0)
189
- activesupport (>= 3.0)
190
- sprockets (>= 2.8, < 4.0)
193
+ sprockets-rails (3.0.4)
194
+ actionpack (>= 4.0)
195
+ activesupport (>= 4.0)
196
+ sprockets (>= 3.0.0)
191
197
  thor (0.19.1)
192
198
  thread_safe (0.3.5)
193
- tilt (2.0.1)
199
+ tilt (2.0.2)
194
200
  tzinfo (1.2.2)
195
201
  thread_safe (~> 0.1)
196
- warden (1.2.3)
202
+ warden (1.2.6)
197
203
  rack (>= 1.0)
198
204
 
199
205
  PLATFORMS
@@ -207,3 +213,6 @@ DEPENDENCIES
207
213
  rspec
208
214
  shoulda
209
215
  simplecov (>= 0.10.0)
216
+
217
+ BUNDLED WITH
218
+ 1.10.6
data/adminsite.gemspec ADDED
@@ -0,0 +1,50 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "adminsite/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "adminsite"
8
+ s.version = Adminsite::VERSION
9
+ s.authors = ["Robin Wunderlin"]
10
+ s.email = "robin@wunderlin.dk"
11
+ s.homepage = "http://www.rhg.dk"
12
+ s.summary = "Basic Admin Backend interface for Ruby on Rails"
13
+ s.description = "Basic Admin Backend interface for Ruby on Rails"
14
+
15
+ s.files = Dir["[A-Z]*", "{app,config,db,public,lib,generators}/**/*"]+ ["LICENSE", "Rakefile", "README.markdown"]
16
+ s.extra_rdoc_files = [
17
+ "README.markdown"
18
+ ]
19
+
20
+ s.required_ruby_version = '>= 2.0.0'
21
+ s.require_paths = ["lib"]
22
+
23
+ # s.date = "#{Time.now.to_date}"
24
+ s.post_install_message = File.open('USAGE').read
25
+
26
+ s.add_runtime_dependency(%q<rails>, [">= 4.1"])
27
+ s.add_runtime_dependency(%q<actionpack-page_caching>, [">= 0"])
28
+ s.add_runtime_dependency(%q<jquery-rails>, [">= 0"])
29
+
30
+ s.add_runtime_dependency(%q<domainatrix>, [">= 0"])
31
+
32
+ s.add_runtime_dependency(%q<devise>, ["~> 3.4"])
33
+ s.add_runtime_dependency(%q<cancancan>, ["~> 1.10"])
34
+ s.add_runtime_dependency(%q<kaminari>, [">= 0.15.0"])
35
+ s.add_runtime_dependency(%q<ransack>, [">= 1.3"])
36
+
37
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
38
+ s.add_runtime_dependency(%q<formtastic>, [">= 3.1.3"])
39
+
40
+ s.add_runtime_dependency(%q<sass-rails>, [">= 0"])
41
+
42
+ s.add_dependency "codemirror-rails", '>= 4.8'
43
+ s.add_runtime_dependency(%q<liquid>, [">= 0"])
44
+
45
+ s.add_runtime_dependency(%q<paperclip>, [">= 0"])
46
+
47
+ s.add_development_dependency("bundler", ">= 1.5")
48
+ s.add_development_dependency("rake")
49
+ end
50
+
@@ -4,6 +4,7 @@ module Adminsite
4
4
  def attributes_index
5
5
  [ :name,
6
6
  :email,
7
+ :admin_user_roles,
7
8
  :updated_at
8
9
  ]
9
10
  end
@@ -12,7 +13,8 @@ module Adminsite
12
13
  [ :name,
13
14
  :email,
14
15
  :password,
15
- :password_confirmation
16
+ :password_confirmation,
17
+ :admin_user_roles
16
18
  ]
17
19
  end
18
20
 
@@ -0,0 +1,10 @@
1
+ module Adminsite
2
+ class AdminsiteAdminUserRoleAdminConfig < Adminsite::AdminConfig::Base
3
+
4
+
5
+ def label_attribute(resource = nil)
6
+ :name
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142 142">
4
+ <rect fill="#1D9DD9" width="142" height="142"/>
5
+ <polygon opacity="0.2" fill="#FFFFFF" points="142,142 0,142 142,0 "/>
6
+ <g fill="#FFFFFF">
7
+ <path d="M38,86.9h-3c-0.5,0-0.8-0.3-0.8-0.8V56.7c0-0.5,0.3-0.8,0.8-0.8h11.3c2.3,0,4.2,0.7,5.5,2
8
+ c1.3,1.3,2,3.2,2,5.5v4.1c0,3.7-1.5,6-4.6,7v0.2L54.5,86c0.4,0.6,0.1,1-0.6,1h-3c-0.8,0-1.3-0.3-1.5-0.8L44.3,75h-4.9
9
+ c-0.4,0-0.6,0.2-0.6,0.5v10.6C38.8,86.7,38.5,86.9,38,86.9z M39.3,71.1h6.1c2.4,0,3.6-1.2,3.6-3.5v-4.1c0-2.4-1.2-3.6-3.6-3.6h-6.1
10
+ c-0.4,0-0.5,0.2-0.5,0.5v10.2C38.8,71,39,71.1,39.3,71.1z"/>
11
+ <path d="M64.2,86.9h-3c-0.5,0-0.8-0.3-0.8-0.8V56.7c0-0.5,0.3-0.8,0.8-0.8h3c0.5,0,0.8,0.3,0.8,0.8v12.1
12
+ c0,0.3,0.2,0.5,0.6,0.5h10.2c0.3,0,0.5-0.2,0.5-0.5V56.7c0-0.5,0.3-0.8,0.8-0.8h3.1c0.5,0,0.8,0.3,0.8,0.8v29.4
13
+ c0,0.5-0.3,0.8-0.8,0.8h-3.1c-0.5,0-0.8-0.3-0.8-0.8V73.9c0-0.3-0.2-0.5-0.5-0.5H65.6c-0.4,0-0.6,0.2-0.6,0.5v12.2
14
+ C65.1,86.7,64.8,86.9,64.2,86.9z"/>
15
+ <path d="M100.3,86.9h-5.2c-2.4,0-4.2-0.7-5.5-2c-1.3-1.3-2-3.2-2-5.5V63.4c0-2.4,0.7-4.2,2-5.5c1.3-1.3,3.1-2,5.5-2
16
+ h5.2c2.4,0,4.2,0.7,5.5,2c1.3,1.3,2,3.1,2,5.5v1.7c0,0.6-0.3,0.9-0.8,0.9h-3c-0.5,0-0.8-0.3-0.8-0.9v-1.5c0-2.4-1.2-3.6-3.5-3.6
17
+ h-3.8c-2.3,0-3.5,1.2-3.5,3.6v15.7c0,2.4,1.2,3.6,3.5,3.6h3.8c2.3,0,3.5-1.2,3.5-3.6v-4.3c0-0.3-0.2-0.5-0.5-0.5h-3.9
18
+ c-0.5,0-0.8-0.3-0.8-0.8v-2.5c0-0.5,0.3-0.8,0.8-0.8h8.1c0.7,0,1,0.3,1,1v8.1c0,2.3-0.7,4.2-2,5.5
19
+ C104.5,86.3,102.7,86.9,100.3,86.9z"/>
20
+ </g>
21
+ </svg>
@@ -60,7 +60,6 @@ body.adminsite {
60
60
  margin-bottom: 8px;
61
61
  }
62
62
  #wrapper {
63
- overflow: auto;
64
63
  margin-left: 20px;
65
64
  margin-right: 20px;
66
65
  }
@@ -323,7 +322,7 @@ body.adminsite {
323
322
  margin-bottom: 10px;
324
323
  }
325
324
  h1 {
326
- background: asset-url("adminsite/admin/logo.png") no-repeat;
325
+ background: asset-url("adminsite/admin/logo.svg") no-repeat;
327
326
  font-size: 135%;
328
327
  font-weight: normal;
329
328
  padding-left: 124px;
@@ -350,12 +349,14 @@ body.adminsite {
350
349
  padding: 0.2em 0.4em;
351
350
  font-weight: bold;
352
351
  }
353
- tr:nth-child(even) {background: #FFF}
354
- tr:nth-child(odd) {background: #f4f5f5}
355
-
352
+ tbody {
353
+ tr:nth-child(even) {background: #FFF}
354
+ tr:nth-child(odd) {background: #f4f5f5}
355
+ }
356
356
  th, td {
357
357
  border: 1px solid #cccccc;
358
358
  padding: 0.2em 0.4em;
359
+ vertical-align: top;
359
360
  }
360
361
  th {
361
362
  background: #cccccc;
@@ -363,6 +364,7 @@ body.adminsite {
363
364
  text-align: left;
364
365
  font-weight: normal;
365
366
  font-variant: small-caps;
367
+ white-space: nowrap;
366
368
  }
367
369
  tr.old td {
368
370
  opacity: 0.5;
@@ -1,28 +1,30 @@
1
1
  $position : left ;
2
2
  $primary-color: #efefef;
3
3
  $secondary-color: #BBB;
4
- .pagination
5
- {
4
+ .pagination {
6
5
  text-align: $position ;
7
6
  color: #666;
8
- }
9
- .pagination a {
10
- border-radius: 2px;
11
- padding: 0.5em 0.7em;
12
- border-color: #aaa;
13
- border-style: solid;
14
- background-color: #efefef;
15
- background-color: $primary-color;
16
- border-top: 2px solid $secondary-color ;
17
- border: 1px solid $secondary-color ;
18
- text-decoration: none;
7
+ margin:1em 0;
19
8
  font-size: smaller;
9
+ a {
10
+ border-radius: 2px;
11
+ padding: 0.5em 0.7em;
12
+ background-color: $primary-color;
13
+ border-color: #aaa;
14
+ border-style: solid;
15
+ border-top: 2px solid $secondary-color ;
16
+ border: 1px solid $secondary-color ;
17
+ text-decoration: none;
18
+ &:hover, &:focus {
19
+ background-image: -webkit-linear-gradient(to top, #cfcfcf, #cfcfcf);
20
+ background-image: linear-gradient(to top, #cfcfcf, #cfcfcf);
21
+ }
22
+ &.more {
23
+ box-shadow: 0 0 0 0 transparent;
24
+ background: transparent;
25
+ }
20
26
  }
21
- .pagination a:hover , .pagination a:focus
22
- {
23
- background-image: -webkit-linear-gradient(top, #cfcfcf, #cfcfcf);
24
- }
25
- .pagination a.more {
26
- box-shadow: 0 0 0 0 transparent;
27
- background: transparent;
27
+ .current {
28
+ padding: 0.5em 0.7em;
28
29
  }
30
+ }
@@ -1,8 +1,19 @@
1
1
  module Adminsite
2
2
  class Admin::AdminsiteAdminUsersController < Adminsite::Admin::ResourcesController
3
3
 
4
+ def update
5
+ remove_empty_pw
6
+ super
7
+ end
8
+
4
9
  protected
5
10
 
11
+ def remove_empty_pw
12
+ [:password, :password_confirmation].each do |p|
13
+ params[:adminsite_admin_user][p] = nil if params[:adminsite_admin_user][p].blank?
14
+ end
15
+ end
16
+
6
17
  def self.resource_class
7
18
  Adminsite::AdminUser
8
19
  end
@@ -1,6 +1,4 @@
1
1
  class Adminsite::Admin::BaseController < Adminsite::AdminApplicationController
2
- layout 'adminsite/admin'
3
-
4
2
  newrelic_ignore if defined?(NewRelic)
5
3
 
6
4
  protected
@@ -85,6 +85,10 @@ class Adminsite::Admin::ResourcesController < Adminsite::Admin::CrudController
85
85
 
86
86
  protected
87
87
 
88
+ def resource_class_with_parent
89
+ resource_class
90
+ end
91
+
88
92
  def api_call?
89
93
  request.xhr? || request.format.to_sym == :json
90
94
  end
@@ -4,6 +4,31 @@
4
4
  class Adminsite::AdminApplicationController < ActionController::Base
5
5
  helper :all, "admin/adminsite_application"
6
6
  layout 'adminsite/admin'
7
+
7
8
  before_filter :authenticate_adminsite_admin_user!
8
9
 
10
+ include ::CanCan::ControllerAdditions
11
+ authorize_resource class: lambda { |context| context.resource_class }
12
+ # check_authorization
13
+
14
+ rescue_from CanCan::AccessDenied do |exception|
15
+ render text: exception.message
16
+ end
17
+
18
+ def authorize!(action, subject, *args)
19
+ subject = subject.call(self) if subject.is_a?(Proc)
20
+ puts "#{self}#authorize!(#{action}, #{subject}, #{args.inspect})" if Rails.env.development?
21
+ super(action, subject, *args)
22
+ end
23
+
24
+ def resource_class
25
+ self
26
+ end
27
+
28
+ protected
29
+
30
+ def current_ability
31
+ @current_ability ||= ::Adminsite::Ability.new(current_adminsite_admin_user)
32
+ end
33
+
9
34
  end
@@ -36,16 +36,21 @@ module Admin::AdminsiteApplicationHelper
36
36
  end
37
37
  end
38
38
 
39
- def format_response_value(value)
39
+ def format_response_value(value, add_td_wrappers = true)
40
40
  value = value.url if defined?(PictureUploader) && value.is_a?(PictureUploader)
41
- response = '<td>'
41
+ response = ''
42
+ response = '<td>' if add_td_wrappers
42
43
  if is_url?(value)
43
- response += link_to(value,value, target: :blank)
44
- response += "<br/>#{image_tag(value)}" if is_image?(value)
44
+ response += link_to(value,value, target: '_blank')
45
+ response += "<br>#{image_tag(value)}" if is_image?(value)
45
46
  else
46
47
  response += h value
47
48
  end
48
- response + '</td>'
49
+ if add_td_wrappers
50
+ response + '</td>'
51
+ else
52
+ response
53
+ end
49
54
  end
50
55
 
51
56
  def is_url?(value)
@@ -149,7 +154,7 @@ module Admin::AdminsiteApplicationHelper
149
154
  end
150
155
 
151
156
  def link_to_show(resource)
152
- link_to image_tag('adminsite/admin/magnifier.png', :size => '16x16'), admin_resource_path(resource.id), target: :blank
157
+ link_to image_tag('adminsite/admin/magnifier.png', :size => '16x16'), admin_resource_path(resource.id), target: '_blank'
153
158
  end
154
159
 
155
160
  def link_to_edit(resource)
@@ -160,11 +165,17 @@ module Admin::AdminsiteApplicationHelper
160
165
  link_to image_tag('adminsite/admin/cross.png', :size => '16x16'), admin_resource_path(resource.id), data: { :confirm => 'Are you sure?'} , :method => :delete
161
166
  end
162
167
 
163
- def display_resource_value(resource, attr)
168
+ def display_resource_value(resource, attr, add_td_wrappers = true)
164
169
  value = nil
165
170
  attr.to_s.split('.').each{|a| value = (value || resource).send(a) }
166
171
  value = display_referenced_resource(value) if value.is_a?(ActiveRecord::Base)
167
- format_response_value(value).html_safe
172
+ if value.is_a?(ActiveRecord::Associations::CollectionProxy)
173
+ value = value.collect do |r|
174
+ label = Adminsite::AdminConfig::Base.admin_config_of_class(r.class, nil, current_adminsite_admin_user).label_attribute(r)
175
+ display_resource_value(r, label, false)
176
+ end.join(', ')
177
+ end
178
+ format_response_value(value, add_td_wrappers).html_safe
168
179
  end
169
180
 
170
181
  def display_referenced_resource(resource)
@@ -0,0 +1,25 @@
1
+ module Adminsite
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user)
6
+ user ||= AdminUser.new
7
+ user.admin_user_roles.each do |role|
8
+ case role.name.to_sym
9
+ when :admin
10
+ can :manage, :all
11
+ when :editor
12
+ can :read, Adminsite::Page
13
+ can :read, Adminsite::PageLayout
14
+ can :read, Adminsite::FileAsset
15
+ can :read, Adminsite::AdminUser
16
+ can :read, Adminsite::AdminUserRole
17
+ when :customer
18
+ # can :read, Adminsite::Page
19
+ # can :read, Adminsite::PageLayout
20
+ # can :read, Adminsite::FileAsset
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -80,6 +80,10 @@ module Adminsite
80
80
  [ :new ]
81
81
  end
82
82
 
83
+ def actions_placement
84
+ :right
85
+ end
86
+
83
87
  def label_attribute(resource = nil)
84
88
  :title
85
89
  end
@@ -5,6 +5,8 @@ module Adminsite
5
5
  devise :database_authenticatable, :registerable,
6
6
  :recoverable, :rememberable, :trackable, :validatable
7
7
 
8
+ has_and_belongs_to_many :admin_user_roles
9
+
8
10
  end
9
11
 
10
12
  end
@@ -0,0 +1,17 @@
1
+ module Adminsite
2
+ class AdminUserRole < ActiveRecord::Base
3
+
4
+ has_and_belongs_to_many :admin_users
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+
8
+ before_validation :downcase_name
9
+
10
+ protected
11
+
12
+ def downcase_name
13
+ self.name = name.try(:downcase)
14
+ end
15
+
16
+ end
17
+ end
@@ -1,19 +1,31 @@
1
+ = paginate(@resources, :window => 2)
2
+
1
3
  %table
2
- %tr
3
- %th
4
- - resource_admin_config.attributes_index.each do |attr|
5
- %th= sort_link(@q, attr)
6
- %th Actions
7
- - @resources.each do |resource|
8
- %tr{onClick: 'Adminsite.selectedRow(this);'}
9
- %td.resource_selection_cell
10
- = check_box_tag 'collection_selection[]', resource.id, false, :class => 'collection_selection'
4
+ %thead
5
+ %tr
6
+ - if resource_admin_config.actions_placement == :left
7
+ %th Actions
8
+ %th
11
9
  - resource_admin_config.attributes_index.each do |attr|
12
- = display_resource_value(resource, attr)
13
- %td.actions
14
- %ul
15
- - resource_admin_config.default_member_actions(resource).each do |action|
16
- %li= send("link_to_#{action}", resource)
10
+ %th= sort_link(@q, attr)
11
+ - if resource_admin_config.actions_placement == :right
12
+ %th Actions
13
+ %tbody
14
+ - @resources.each do |resource|
15
+ %tr{onclick: 'Adminsite.selectedRow(this);'}
16
+ - if resource_admin_config.actions_placement == :left
17
+ %td.actions
18
+ %ul
19
+ - resource_admin_config.default_member_actions(resource).each do |action|
20
+ %li= send("link_to_#{action}", resource)
21
+ %td.resource_selection_cell
22
+ = check_box_tag 'collection_selection[]', resource.id, false, :class => 'collection_selection'
23
+ - resource_admin_config.attributes_index.each do |attr|
24
+ = display_resource_value(resource, attr)
25
+ - if resource_admin_config.actions_placement == :right
26
+ %td.actions
27
+ %ul
28
+ - resource_admin_config.default_member_actions(resource).each do |action|
29
+ %li= send("link_to_#{action}", resource)
17
30
 
18
31
  = paginate(@resources, :window => 2)
19
- %br
@@ -1,7 +1,7 @@
1
1
  - if resource_admin_config.attributes_search.any?
2
2
  .search_form
3
- %a#show{onClick: 'Adminsite.showSearchForm();', style: "#{'display:none' if @show_search_form}" } Show Filters
4
- %a#hide{onClick: 'Adminsite.hideSearchForm();', style: "#{'display:none' unless @show_search_form}" } Hide Filters
3
+ %a#show{onclick: 'Adminsite.showSearchForm();', style: "#{'display:none' if @show_search_form}" } Show Filters
4
+ %a#hide{onclick: 'Adminsite.hideSearchForm();', style: "#{'display:none' unless @show_search_form}" } Hide Filters
5
5
  = search_form_for(@q, :url => admin_resource_path(nil), method: :get, html: { style: "#{'display:none' unless @show_search_form}"} ) do |f|
6
6
  = hidden_field_tag :admin_menu, params[:admin_menu]
7
7
  %div{id: "#{controller_name}-search"}
@@ -30,11 +30,6 @@
30
30
  predicate_obj.onchange();
31
31
  - else
32
32
  = f.search_field("#{search_attr}_#{predicates.first}", value: field_value )
33
-
34
-
35
-
36
33
  .actions
37
34
  = f.submit "Search"
38
35
  = link_to "Reset" , admin_resource_path(nil)
39
-
40
-
@@ -0,0 +1,20 @@
1
+ class CreateAdminUserRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :adminsite_admin_user_roles do |t|
4
+ t.string :name, null: false
5
+ t.timestamps
6
+ end
7
+ add_index :adminsite_admin_user_roles, :name, unique: true
8
+
9
+ create_table :adminsite_admin_user_roles_users, id: false do |t|
10
+ t.references :admin_user, null: false
11
+ t.references :admin_user_role, null: false
12
+ end
13
+ add_index :adminsite_admin_user_roles_users, :admin_user_id
14
+ add_index :adminsite_admin_user_roles_users, :admin_user_role_id
15
+
16
+ Adminsite::AdminUserRole.create [{name: 'admin'}, {name: 'editor'},{name: 'customer'}]
17
+ end
18
+ end
19
+
20
+
@@ -1,6 +1,6 @@
1
1
  %w(rails action_controller/page_caching).each{|f| require f }
2
2
  %w(paperclip liquid adminsite/liquid/tags/asset).each{|f| require f }
3
- %w(devise haml formtastic codemirror-rails kaminari ransack).each{|f| require f }
3
+ %w(devise cancancan haml formtastic codemirror-rails kaminari ransack).each{|f| require f }
4
4
 
5
5
  module Adminsite
6
6
  class Engine < Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module Adminsite
2
- VERSION = "2.1.2" unless defined?(Adminsite::VERSION)
2
+ VERSION = "3.0.0" unless defined?(Adminsite::VERSION)
3
3
  end
@@ -32,6 +32,9 @@ module Adminsite
32
32
  "\n get '/:page_url(.:format)' => 'adminsite/contents#render_404'\n"
33
33
  end
34
34
 
35
+ puts "Setting up CanCan"
36
+ copy_file 'app/models/adminsite/ability.rb', 'app/models/adminsite/ability.rb'
37
+
35
38
  # Locales
36
39
  copy_file "config/locales/adminsite.da.yml", 'config/locales/adminsite.da.yml'
37
40
  copy_file "config/locales/adminsite.en.yml", 'config/locales/adminsite.en.yml'
@@ -13,10 +13,11 @@ namespace :adminsite do
13
13
  password = Digest::MD5.hexdigest(Time.now.to_s)[0..9]
14
14
  end
15
15
 
16
- Adminsite::AdminUser.create!( :name => name,
16
+ admin_user = Adminsite::AdminUser.create!( :name => name,
17
17
  :email => email,
18
18
  :password => password,
19
19
  :password_confirmation => password)
20
+ admin_user.admin_user_roles << Adminsite::AdminUserRole.find_by_name('admin')
20
21
  puts "#{'*'*70}"
21
22
  puts "Done! You can access the admin interface at http://yourapp_url/admin"
22
23
  puts "I have created an administrator with these credentials:"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminsite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Wunderlin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cancancan
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.10'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.10'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: kaminari
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -233,7 +247,9 @@ files:
233
247
  - README.markdown
234
248
  - Rakefile
235
249
  - USAGE
250
+ - adminsite.gemspec
236
251
  - app/admin_configs/adminsite/adminsite_admin_user_admin_config.rb
252
+ - app/admin_configs/adminsite/adminsite_admin_user_role_admin_config.rb
237
253
  - app/admin_configs/adminsite/adminsite_file_asset_admin_config.rb
238
254
  - app/admin_configs/adminsite/adminsite_page_admin_config.rb
239
255
  - app/admin_configs/adminsite/adminsite_page_layout_admin_config.rb
@@ -245,6 +261,7 @@ files:
245
261
  - app/assets/images/adminsite/admin/cross.png
246
262
  - app/assets/images/adminsite/admin/logo.gif
247
263
  - app/assets/images/adminsite/admin/logo.png
264
+ - app/assets/images/adminsite/admin/logo.svg
248
265
  - app/assets/images/adminsite/admin/magnifier.png
249
266
  - app/assets/images/adminsite/admin/newspaper_add.png
250
267
  - app/assets/images/adminsite/admin/newspaper_delete.png
@@ -277,8 +294,10 @@ files:
277
294
  - app/helpers/admin/adminsite_application_helper.rb
278
295
  - app/helpers/admin_application_helper.rb
279
296
  - app/inputs/adminsite/multi_select_box_input.rb
297
+ - app/models/adminsite/ability.rb
280
298
  - app/models/adminsite/admin_config/base.rb
281
299
  - app/models/adminsite/admin_user.rb
300
+ - app/models/adminsite/admin_user_role.rb
282
301
  - app/models/adminsite/file_asset.rb
283
302
  - app/models/adminsite/page.rb
284
303
  - app/models/adminsite/page_layout.rb
@@ -318,6 +337,7 @@ files:
318
337
  - config/routes.rb
319
338
  - db/migrate/20101007000000_create_admin.rb
320
339
  - db/migrate/20101007000001_create_cms_tables.rb
340
+ - db/migrate/20101007000002_create_admin_user_roles.rb
321
341
  - lib/adminsite.rb
322
342
  - lib/adminsite/configuration.rb
323
343
  - lib/adminsite/engine.rb
@@ -376,7 +396,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
396
  version: '0'
377
397
  requirements: []
378
398
  rubyforge_project:
379
- rubygems_version: 2.2.2
399
+ rubygems_version: 2.4.5.1
380
400
  signing_key:
381
401
  specification_version: 4
382
402
  summary: Basic Admin Backend interface for Ruby on Rails