padrino-admin 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-admin/access_control.rb +11 -1
- data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +1 -1
- data/lib/padrino-admin/generators/templates/haml/app/layouts/application.haml.tt +2 -2
- data/lib/padrino-admin/generators/templates/slim/app/layouts/application.slim.tt +3 -2
- data/test/fixtures/sequel.rb +6 -6
- data/test/generators/test_admin_page_generator.rb +44 -44
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c7b4aeb0ecf5580414ca88d95d7258d72328762
|
4
|
+
data.tar.gz: a6618a7e7a657783f753f7576fdbe1fbb692d020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abefef201e4f889d2cda36a6adba3ec6e2b5a92c4f678e14fe08eb72e5cfe52d7ab39a56acbba80504e321575eb0b9c5284a29aff79fa7a0db8ba5205f0796eb
|
7
|
+
data.tar.gz: da782d5502ad38427a099d256d79d9e1138c9a3fd7001e9021f76c51b3063a407a9d5f343d40e64ad626442d3c84c472b408e48265aa7354aadbb81c47e3e5be
|
@@ -19,7 +19,17 @@ module Padrino
|
|
19
19
|
app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
|
20
20
|
app.helpers Padrino::Admin::Helpers::ViewHelpers
|
21
21
|
app.before { login_required }
|
22
|
-
app.
|
22
|
+
app.class_eval do
|
23
|
+
def access_control
|
24
|
+
@@access_control
|
25
|
+
end
|
26
|
+
def self.access_control
|
27
|
+
@@access_control
|
28
|
+
end
|
29
|
+
def self.access_control=(control)
|
30
|
+
@@access_control = control
|
31
|
+
end
|
32
|
+
end
|
23
33
|
app.send(:access_control=, Padrino::Admin::AccessControl::Base.new)
|
24
34
|
end
|
25
35
|
alias :included :registered
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<ul class="nav navbar-nav pull-right">
|
21
21
|
<li class=navbar-edit-account><%%= link_to tag_icon(:user), url(:<%= @model_plural %>, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link' %></li>
|
22
22
|
<li class=navbar-logout>
|
23
|
-
<%%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form'
|
23
|
+
<%%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' }) { tag_icon(:'power-off') } %>
|
24
24
|
</li>
|
25
25
|
</ul>
|
26
26
|
|
@@ -20,8 +20,8 @@
|
|
20
20
|
%ul.nav.navbar-nav.pull-right
|
21
21
|
%li.navbar-edit-account=link_to tag_icon(:user), url(:accounts, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link'
|
22
22
|
%li.navbar-logout
|
23
|
-
=button_to :logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form' do
|
24
|
-
=
|
23
|
+
= button_to :logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } do
|
24
|
+
= tag_icon('power-off')
|
25
25
|
|
26
26
|
%ul.nav.navbar-nav.pull-left
|
27
27
|
- project_modules.each do |project_module|
|
@@ -20,8 +20,9 @@ html lang='en'
|
|
20
20
|
|
21
21
|
ul class='nav navbar-nav pull-right'
|
22
22
|
li class='navbar-edit-account' = link_to tag_icon(:user), url(:<%= @model_plural %>, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link'
|
23
|
-
li class='navbar-logout'
|
24
|
-
=
|
23
|
+
li class='navbar-logout'
|
24
|
+
= button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } do
|
25
|
+
= tag_icon(:'power-off')
|
25
26
|
|
26
27
|
ul class='nav navbar-nav pull-left'
|
27
28
|
- project_modules.each do |project_module|
|
data/test/fixtures/sequel.rb
CHANGED
@@ -24,7 +24,7 @@ migration = Sequel.migration do
|
|
24
24
|
String :role
|
25
25
|
end
|
26
26
|
|
27
|
-
create_table :
|
27
|
+
create_table :sections do
|
28
28
|
primary_key :id
|
29
29
|
foreign_key :account_id
|
30
30
|
String :name
|
@@ -38,8 +38,8 @@ end
|
|
38
38
|
|
39
39
|
migration.apply(Sequel::Model.db, :up)
|
40
40
|
|
41
|
-
# Fake
|
42
|
-
class
|
41
|
+
# Fake Section Model
|
42
|
+
class Section < Sequel::Model
|
43
43
|
many_to_one :account
|
44
44
|
end
|
45
45
|
|
@@ -47,7 +47,7 @@ end
|
|
47
47
|
class Account < Sequel::Model
|
48
48
|
attr_accessor :password, :password_confirmation
|
49
49
|
|
50
|
-
one_to_many :
|
50
|
+
one_to_many :sections
|
51
51
|
|
52
52
|
def self.admin; first(:role => "admin"); end
|
53
53
|
def self.editor; first(:role => "editor"); end
|
@@ -67,6 +67,6 @@ editor = Account.create(:name => "Dexter", :role => "editor", :email => "editor@
|
|
67
67
|
:password => "some", :password_confirmation => "some")
|
68
68
|
|
69
69
|
%w(News Press HowTo).each do |c|
|
70
|
-
admin.
|
71
|
-
editor.
|
70
|
+
admin.add_section(:name => c)
|
71
|
+
editor.add_section(:name => c)
|
72
72
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../helper')
|
2
2
|
|
3
|
-
class
|
3
|
+
class Friend
|
4
4
|
def self.properties
|
5
5
|
[:id, :name, :age, :email].map { |c| OpenStruct.new(:name => c) }
|
6
6
|
end
|
@@ -38,11 +38,11 @@ describe "AdminPageGenerator" do
|
|
38
38
|
it 'should correctly generate a new page' do
|
39
39
|
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
40
40
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
41
|
-
capture_io { generate(:model, '
|
42
|
-
capture_io { generate(:admin_page, '
|
43
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/
|
44
|
-
assert_match_in_file "SampleProject::Admin.controllers :
|
45
|
-
assert_match_in_file "role.project_module :
|
41
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
42
|
+
capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
|
43
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/friends.rb"
|
44
|
+
assert_match_in_file "SampleProject::Admin.controllers :friends do", "#{@apptmp}/sample_project/admin/controllers/friends.rb"
|
45
|
+
assert_match_in_file "role.project_module :friends, '/friends'", "#{@apptmp}/sample_project/admin/app.rb"
|
46
46
|
assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
|
47
47
|
end
|
48
48
|
|
@@ -52,24 +52,24 @@ describe "AdminPageGenerator" do
|
|
52
52
|
custom_template_path = "#{@apptmp}/sample_project/generators/templates/haml/page/"
|
53
53
|
`mkdir -p #{custom_template_path} && echo "%h1= 'Hello, custom generator' " > #{custom_template_path}index.haml.tt`
|
54
54
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
55
|
-
capture_io { generate(:model, '
|
56
|
-
capture_io { generate(:admin_page, '
|
57
|
-
assert_match_in_file(/Hello, custom generator/, "#{@apptmp}/sample_project/admin/views/
|
55
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
56
|
+
capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
|
57
|
+
assert_match_in_file(/Hello, custom generator/, "#{@apptmp}/sample_project/admin/views/friends/index.haml")
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "renderers" do
|
61
61
|
it 'should correctly generate a new page with haml' do
|
62
62
|
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
63
63
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
64
|
-
capture_io { generate(:model, '
|
65
|
-
capture_io { generate(:admin_page, '
|
66
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
67
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
68
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
69
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
64
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
65
|
+
capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
|
66
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
67
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.haml"
|
68
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.haml"
|
69
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.haml"
|
70
70
|
%w(name age email).each do |field|
|
71
|
-
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/
|
72
|
-
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/
|
71
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
72
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
73
73
|
end
|
74
74
|
assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.haml"
|
75
75
|
end
|
@@ -77,15 +77,15 @@ describe "AdminPageGenerator" do
|
|
77
77
|
it 'should correctly generate a new page with erb' do
|
78
78
|
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=erb') }
|
79
79
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
80
|
-
capture_io { generate(:model, '
|
81
|
-
capture_io { generate(:admin_page, '
|
82
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
83
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
84
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
85
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
80
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
81
|
+
capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
|
82
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
|
83
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.erb"
|
84
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.erb"
|
85
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.erb"
|
86
86
|
%w(name age email).each do |field|
|
87
|
-
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/
|
88
|
-
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/
|
87
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
|
88
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
|
89
89
|
end
|
90
90
|
assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.erb"
|
91
91
|
end
|
@@ -93,15 +93,15 @@ describe "AdminPageGenerator" do
|
|
93
93
|
it 'should correctly generate a new page with slim' do
|
94
94
|
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=slim') }
|
95
95
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
96
|
-
capture_io { generate(:model, '
|
97
|
-
capture_io { generate(:admin_page, '
|
98
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
99
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
100
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
101
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
96
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
97
|
+
capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
|
98
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
|
99
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.slim"
|
100
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.slim"
|
101
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.slim"
|
102
102
|
%w(name age email).each do |field|
|
103
|
-
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/
|
104
|
-
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/
|
103
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
|
104
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
|
105
105
|
end
|
106
106
|
assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.slim"
|
107
107
|
end
|
@@ -110,20 +110,20 @@ describe "AdminPageGenerator" do
|
|
110
110
|
it 'should correctly generate a new padrino admin application with multiple models at the same time' do
|
111
111
|
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
112
112
|
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
113
|
-
capture_io { generate(:model, '
|
113
|
+
capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
114
114
|
capture_io { generate(:model, 'page', "name:string", "body:string", "-root=#{@apptmp}/sample_project") }
|
115
|
-
capture_io { generate(:admin_page, '
|
116
|
-
# For
|
117
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/
|
118
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
119
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
120
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
121
|
-
assert_file_exists "#{@apptmp}/sample_project/admin/views/
|
115
|
+
capture_io { generate(:admin_page, 'friend', 'page', "--root=#{@apptmp}/sample_project") }
|
116
|
+
# For Friend
|
117
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/friends.rb"
|
118
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
119
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.haml"
|
120
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.haml"
|
121
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.haml"
|
122
122
|
%w(name age email).each do |field|
|
123
|
-
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/
|
124
|
-
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/
|
123
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
124
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
|
125
125
|
end
|
126
|
-
assert_match_in_file "role.project_module :
|
126
|
+
assert_match_in_file "role.project_module :friends, '/friends'", "#{@apptmp}/sample_project/admin/app.rb"
|
127
127
|
# For Page
|
128
128
|
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/pages.rb"
|
129
129
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/_form.haml"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-core
|
@@ -19,54 +19,54 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.13.
|
22
|
+
version: 0.13.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.13.
|
29
|
+
version: 0.13.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: padrino-helpers
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.13.
|
36
|
+
version: 0.13.2
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.13.
|
43
|
+
version: 0.13.2
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: therubyracer
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- - ~>
|
48
|
+
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 0.11.1
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - ~>
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: 0.11.1
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: less
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- - ~>
|
62
|
+
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 2.2.2
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - ~>
|
69
|
+
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 2.2.2
|
72
72
|
description: Admin View for Padrino applications
|
@@ -76,9 +76,9 @@ extensions: []
|
|
76
76
|
extra_rdoc_files:
|
77
77
|
- README.rdoc
|
78
78
|
files:
|
79
|
-
- .document
|
80
|
-
- .gitignore
|
81
|
-
- .yardopts
|
79
|
+
- ".document"
|
80
|
+
- ".gitignore"
|
81
|
+
- ".yardopts"
|
82
82
|
- LICENSE.txt
|
83
83
|
- README.rdoc
|
84
84
|
- Rakefile
|
@@ -276,17 +276,17 @@ licenses:
|
|
276
276
|
metadata: {}
|
277
277
|
post_install_message:
|
278
278
|
rdoc_options:
|
279
|
-
- --charset=UTF-8
|
279
|
+
- "--charset=UTF-8"
|
280
280
|
require_paths:
|
281
281
|
- lib
|
282
282
|
required_ruby_version: !ruby/object:Gem::Requirement
|
283
283
|
requirements:
|
284
|
-
- -
|
284
|
+
- - ">="
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: '0'
|
287
287
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
288
|
requirements:
|
289
|
-
- -
|
289
|
+
- - ">="
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: 1.3.6
|
292
292
|
requirements: []
|