padrino-admin 0.11.3 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +3 -3
- data/lib/padrino-admin/access_control.rb +46 -47
- data/lib/padrino-admin/bootstrap-less/alerts.less +29 -55
- data/lib/padrino-admin/bootstrap-less/badges.less +13 -15
- data/lib/padrino-admin/bootstrap-less/bootstrap.less +17 -21
- data/lib/padrino-admin/bootstrap-less/breadcrumbs.less +6 -11
- data/lib/padrino-admin/bootstrap-less/button-groups.less +114 -32
- data/lib/padrino-admin/bootstrap-less/buttons.less +41 -41
- data/lib/padrino-admin/bootstrap-less/carousel.less +43 -18
- data/lib/padrino-admin/bootstrap-less/close.less +4 -4
- data/lib/padrino-admin/bootstrap-less/code.less +8 -10
- data/lib/padrino-admin/bootstrap-less/component-animations.less +10 -4
- data/lib/padrino-admin/bootstrap-less/dropdowns.less +78 -51
- data/lib/padrino-admin/bootstrap-less/forms.less +183 -274
- data/lib/padrino-admin/bootstrap-less/glyphicons.less +232 -0
- data/lib/padrino-admin/bootstrap-less/grid.less +230 -88
- data/lib/padrino-admin/bootstrap-less/input-groups.less +127 -0
- data/lib/padrino-admin/bootstrap-less/jumbotron.less +16 -8
- data/lib/padrino-admin/bootstrap-less/labels.less +25 -37
- data/lib/padrino-admin/bootstrap-less/list-group.less +34 -35
- data/lib/padrino-admin/bootstrap-less/media.less +7 -5
- data/lib/padrino-admin/bootstrap-less/mixins.less +321 -108
- data/lib/padrino-admin/bootstrap-less/modals.less +24 -20
- data/lib/padrino-admin/bootstrap-less/navbar.less +474 -216
- data/lib/padrino-admin/bootstrap-less/navs.less +67 -85
- data/lib/padrino-admin/bootstrap-less/pager.less +4 -4
- data/lib/padrino-admin/bootstrap-less/pagination.less +64 -69
- data/lib/padrino-admin/bootstrap-less/panels.less +114 -62
- data/lib/padrino-admin/bootstrap-less/popovers.less +18 -18
- data/lib/padrino-admin/bootstrap-less/print.less +22 -7
- data/lib/padrino-admin/bootstrap-less/progress-bars.less +10 -33
- data/lib/padrino-admin/bootstrap-less/responsive-utilities.less +141 -40
- data/lib/padrino-admin/bootstrap-less/scaffolding.less +66 -19
- data/lib/padrino-admin/bootstrap-less/tables.less +154 -158
- data/lib/padrino-admin/bootstrap-less/theme.less +232 -0
- data/lib/padrino-admin/bootstrap-less/thumbnails.less +9 -20
- data/lib/padrino-admin/bootstrap-less/tooltip.less +3 -3
- data/lib/padrino-admin/bootstrap-less/type.less +47 -55
- data/lib/padrino-admin/bootstrap-less/utilities.less +2 -2
- data/lib/padrino-admin/bootstrap-less/variables.less +289 -93
- data/lib/padrino-admin/bootstrap-less/wells.less +2 -2
- data/lib/padrino-admin/generators/actions.rb +11 -10
- data/lib/padrino-admin/generators/admin_app.rb +11 -11
- data/lib/padrino-admin/generators/admin_page.rb +9 -9
- data/lib/padrino-admin/generators/orm.rb +6 -7
- data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +7 -7
- data/lib/padrino-admin/generators/templates/account/couchrest.rb.tt +16 -16
- data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +7 -7
- data/lib/padrino-admin/generators/templates/account/minirecord.rb.tt +7 -7
- data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +8 -8
- data/lib/padrino-admin/generators/templates/account/mongomapper.rb.tt +7 -7
- data/lib/padrino-admin/generators/templates/account/ohm.rb.tt +9 -9
- data/lib/padrino-admin/generators/templates/account/sequel.rb.tt +8 -8
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/affix.js +9 -3
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/alert.js +4 -2
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap.min.js +4 -4
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/button.js +9 -5
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/carousel.js +19 -12
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/collapse.js +68 -45
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/dropdown.js +6 -7
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/modal.js +43 -40
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/popover.js +16 -10
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/scrollspy.js +6 -4
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tab.js +4 -2
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js +78 -48
- data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/transition.js +10 -1
- data/lib/padrino-admin/generators/templates/assets/stylesheets/application.css +1 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/bootstrap.css +622 -334
- data/lib/padrino-admin/generators/templates/erb/app/layouts/error.erb.tt +2 -2
- data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +9 -9
- data/lib/padrino-admin/generators/templates/erb/page/_form.erb.tt +3 -3
- data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +3 -3
- data/lib/padrino-admin/generators/templates/haml/app/layouts/error.haml.tt +1 -1
- data/lib/padrino-admin/generators/templates/haml/app/sessions/new.haml.tt +9 -7
- data/lib/padrino-admin/generators/templates/haml/page/_form.haml.tt +2 -2
- data/lib/padrino-admin/generators/templates/haml/page/index.haml.tt +2 -2
- data/lib/padrino-admin/generators/templates/page/controller.rb.tt +3 -3
- data/lib/padrino-admin/generators/templates/slim/app/layouts/error.slim.tt +1 -1
- data/lib/padrino-admin/generators/templates/slim/app/sessions/new.slim.tt +9 -7
- data/lib/padrino-admin/generators/templates/slim/page/_form.slim.tt +2 -2
- data/lib/padrino-admin/generators/templates/slim/page/index.slim.tt +2 -2
- data/lib/padrino-admin/helpers/authentication_helpers.rb +35 -35
- data/lib/padrino-admin/helpers/view_helpers.rb +12 -19
- data/lib/padrino-admin/utils/crypt.rb +10 -9
- data/lib/padrino-admin.rb +4 -5
- data/test/fixtures/data_mapper.rb +10 -9
- data/test/generators/test_account_model_generator.rb +2 -2
- metadata +14 -21
@@ -16,8 +16,8 @@
|
|
16
16
|
<div class="custom-error text-center">
|
17
17
|
<div class="custom-error-body muted"><%%= yield %></div>
|
18
18
|
<div class="custom-error-footer">
|
19
|
-
<%%= link_to tag_icon('arrow-left'),"#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn pull-left", :title => "Go back" %>
|
19
|
+
<%%= link_to tag_icon('arrow-left'),"#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn btn-default pull-left", :title => "Go back" %>
|
20
20
|
</div>
|
21
21
|
</div>
|
22
22
|
</body>
|
23
|
-
</html>
|
23
|
+
</html>
|
@@ -20,15 +20,15 @@
|
|
20
20
|
|
21
21
|
<%%= [:error, :warning, :success, :notice].map { |type| flash_tag(type, :class => "alert alert-#{type} fade in", :bootstrap => true) }.join.html_safe %>
|
22
22
|
|
23
|
-
<
|
24
|
-
<label for="email" class="
|
25
|
-
<div class="
|
26
|
-
</
|
23
|
+
<div class="form-group">
|
24
|
+
<label for="email" class="col-lg-2 control-label"><%%= pat('login.email') %></label>
|
25
|
+
<div class="col-lg-10"><%%= email_field_tag :email, :value => params[:email], :autofocus => true, :class => 'form-control' %></div>
|
26
|
+
</div>
|
27
27
|
|
28
|
-
<
|
29
|
-
<label for="password" class="
|
30
|
-
<div class="
|
31
|
-
</
|
28
|
+
<div class="form-group">
|
29
|
+
<label for="password" class="col-lg-2 control-label"><%%= pat('login.password') %></label>
|
30
|
+
<div class="col-lg-10"><%%= password_field_tag :password, :value => params[:password], :class => 'form-control' %></div>
|
31
|
+
</div>
|
32
32
|
|
33
33
|
<fieldset class="login-control-group-last control-group">
|
34
34
|
<div class="login-controls controls">
|
@@ -41,4 +41,4 @@
|
|
41
41
|
<%% end %>
|
42
42
|
<%%= javascript_include_tag 'jquery-1.9.0.min', (Padrino.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application %>
|
43
43
|
</body>
|
44
|
-
</html>
|
44
|
+
</html>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<fieldset class='control-group <%%= error ? 'has-error' : ''%>'>
|
4
4
|
<%%= f.label :<%= column[:name] %>, :class => 'control-label' %>
|
5
5
|
<div class='controls'>
|
6
|
-
<%%= f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'input-xlarge input-with-feedback'<%- if (index == 0) -%>, :autofocus => true<%- end -%> %>
|
6
|
+
<%%= f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'form-control input-xlarge input-with-feedback'<%- if (index == 0) -%>, :autofocus => true<%- end -%> %>
|
7
7
|
<span class='help-inline'><%%= error ? f.error_message_on(:<%= column[:name] %>) : "Ex: a simple text" %></span>
|
8
8
|
</div>
|
9
9
|
</fieldset>
|
@@ -14,5 +14,5 @@
|
|
14
14
|
|
15
15
|
<%%= f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue' %>
|
16
16
|
|
17
|
-
<%%= link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn' %>
|
18
|
-
</div>
|
17
|
+
<%%= link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn btn-default' %>
|
18
|
+
</div>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<%% form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do %>
|
29
29
|
<%%=hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true %>
|
30
30
|
<%%=submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small' %>
|
31
|
-
<div class='btn btn-small cancel'><%%= pat(:cancel) %></div>
|
31
|
+
<div class='btn btn-default btn-small cancel'><%%= pat(:cancel) %></div>
|
32
32
|
<%% end %>
|
33
33
|
</div>
|
34
34
|
</div>
|
@@ -67,7 +67,7 @@
|
|
67
67
|
<div class=popover-content>
|
68
68
|
<%%- form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do %>
|
69
69
|
<%%= submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small' %>
|
70
|
-
<div class="btn btn-small cancel"><%%= pat(:cancel) %></div>
|
70
|
+
<div class="btn btn-default btn-small cancel"><%%= pat(:cancel) %></div>
|
71
71
|
<%% end %>
|
72
72
|
</div>
|
73
73
|
</div>
|
@@ -75,4 +75,4 @@
|
|
75
75
|
<%% end %>
|
76
76
|
</tbody>
|
77
77
|
</table>
|
78
|
-
</div>
|
78
|
+
</div>
|
@@ -15,4 +15,4 @@
|
|
15
15
|
.custom-error.text-center
|
16
16
|
.custom-error-body.muted= yield
|
17
17
|
.custom-error-footer
|
18
|
-
=link_to tag_icon('arrow-left'), "#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn pull-left", :title => "Go back"
|
18
|
+
=link_to tag_icon('arrow-left'), "#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn btn-default pull-left", :title => "Go back"
|
@@ -17,12 +17,14 @@
|
|
17
17
|
.login-body.modal-body
|
18
18
|
= [:error, :warning, :notice].map { |type| flash_tag(type, :class => "alert alert-#{type} fade in", :bootstrap => true) }.join.html_safe
|
19
19
|
|
20
|
-
|
21
|
-
%label.
|
22
|
-
.
|
23
|
-
|
24
|
-
|
25
|
-
.
|
20
|
+
.form-group
|
21
|
+
%label.col-lg-2.control-label{:for => :email}= pat('login.email')
|
22
|
+
.col-lg-10=email_field_tag :email, :value => params[:email], :autofocus => true, :class =>'form-control'
|
23
|
+
|
24
|
+
.form-group
|
25
|
+
%label.col-lg-2.control-label{:for => :password}= pat('login.password')
|
26
|
+
.col-lg-10=password_field_tag :password, :value => params[:password], :class =>'form-control'
|
27
|
+
|
26
28
|
%fieldset.login-control-group-last.control-group
|
27
29
|
.login-controls.controls
|
28
30
|
%label.login-bypass-label.checkbox
|
@@ -32,4 +34,4 @@
|
|
32
34
|
.login-footer.modal-footer
|
33
35
|
=submit_tag(pat('login.sign_in'), :class => 'btn btn-primary pull-right')
|
34
36
|
|
35
|
-
=javascript_include_tag 'jquery-1.9.0.min', (Padrino.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
|
37
|
+
=javascript_include_tag 'jquery-1.9.0.min', (Padrino.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
|
@@ -3,7 +3,7 @@
|
|
3
3
|
%fieldset.control-group{:class => error ? 'has-error' : ''}
|
4
4
|
=f.label :<%= column[:name] %>, :class => 'control-label'
|
5
5
|
.controls
|
6
|
-
<% if column[:field_type] == :text_area %>~<% else %>=<% end %>f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'input-
|
6
|
+
<% if column[:field_type] == :text_area %>~<% else %>=<% end %>f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'form-control input-large input-with-feedback'<%- if (index == 0) -%>, :autofocus => true<%- end -%>
|
7
7
|
|
8
8
|
%span.help-inline=error ? f.error_message_on(:<%= column[:name] %>, :class => 'text-error') : pat(:example)
|
9
9
|
<%- end -%>
|
@@ -13,4 +13,4 @@
|
|
13
13
|
|
14
14
|
=f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue'
|
15
15
|
|
16
|
-
=link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn'
|
16
|
+
=link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn btn-default'
|
@@ -25,7 +25,7 @@
|
|
25
25
|
-form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do
|
26
26
|
=hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true
|
27
27
|
=submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small'
|
28
|
-
.btn.btn-small.cancel=pat(:cancel)
|
28
|
+
.btn.btn-default.btn-small.cancel=pat(:cancel)
|
29
29
|
<%- @orm.columns.each_with_index do |column, i| -%>
|
30
30
|
%th.header= mat(:<%= @orm.name_singular %>, :<%= column.name %>)
|
31
31
|
<%- end -%>
|
@@ -55,4 +55,4 @@
|
|
55
55
|
.popover-content
|
56
56
|
-form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do
|
57
57
|
=submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small'
|
58
|
-
.btn.btn-small.cancel=pat(:cancel)
|
58
|
+
.btn.btn-default.btn-small.cancel=pat(:cancel)
|
@@ -12,7 +12,7 @@
|
|
12
12
|
end
|
13
13
|
|
14
14
|
post :create do
|
15
|
-
@<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.
|
15
|
+
@<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_param}]") %>
|
16
16
|
if <%= @orm.save %>
|
17
17
|
@title = pat(:create_title, :model => "<%= @orm.name_singular %> #{@<%= @orm.name_singular %>.id}")
|
18
18
|
flash[:success] = pat(:create_success, :model => '<%= @orm.klass_name %>')
|
@@ -39,7 +39,7 @@
|
|
39
39
|
@title = pat(:update_title, :model => "<%= @orm.name_singular %> #{params[:id]}")
|
40
40
|
@<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
|
41
41
|
if @<%= @orm.name_singular %>
|
42
|
-
if <%= @orm.update_attributes("params[:#{@orm.
|
42
|
+
if <%= @orm.update_attributes("params[:#{@orm.name_param}]") %>
|
43
43
|
flash[:success] = pat(:update_success, :model => '<%= @orm.name_singular.capitalize %>', :id => "#{params[:id]}")
|
44
44
|
params[:save_and_continue] ?
|
45
45
|
redirect(url(:<%= @orm.name_plural %>, :index)) :
|
@@ -76,7 +76,7 @@
|
|
76
76
|
flash[:error] = pat(:destroy_many_error, :model => '<%= @orm.name_singular %>')
|
77
77
|
redirect(url(:<%= @orm.name_plural %>, :index))
|
78
78
|
end
|
79
|
-
ids = params[:<%= @orm.
|
79
|
+
ids = params[:<%= @orm.name_param %>_ids].split(',').map(&:strip)
|
80
80
|
<%= @orm.name_plural %> = <%= @orm.find_by_ids("ids") %>
|
81
81
|
<% if @orm.name_singular == @admin_model %>
|
82
82
|
if <%= @orm.name_plural %>.include? current_account
|
@@ -16,4 +16,4 @@ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
|
16
16
|
div class="custom-error text-center"
|
17
17
|
div class="custom-error-body muted" = yield
|
18
18
|
div class="custom-error-footer"
|
19
|
-
= link_to tag_icon('arrow-left'),"#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn pull-left", :title => "Go Back"
|
19
|
+
= link_to tag_icon('arrow-left'),"#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn btn-default pull-left", :title => "Go Back"
|
@@ -18,12 +18,14 @@ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
|
18
18
|
div class="login-body modal-body"
|
19
19
|
= [:error, :warning, :notice].map { |type| flash_tag(type, :class => "alert alert-#{type} fade in", :bootstrap => true) }.join.html_safe
|
20
20
|
|
21
|
-
|
22
|
-
label for="email" class='
|
23
|
-
div class='
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
div class='form-group'
|
22
|
+
label for="email" class='col-lg-2 control-label' = pat('login.email')
|
23
|
+
div class='col-lg-10' = email_field_tag :email, :value => params[:email], :autofocus => true, :class => 'form-control'
|
24
|
+
|
25
|
+
div class='form-group'
|
26
|
+
label for="password" class='col-lg-2 control-label' = pat('login.password')
|
27
|
+
div class='col-lg-10' = password_field_tag :password, :value => params[:password], :class => 'form-control'
|
28
|
+
|
27
29
|
fieldset class='login-control-group-last control-group'
|
28
30
|
div class='login-controls controls'
|
29
31
|
label class="login-bypass-label checkbox"
|
@@ -32,4 +34,4 @@ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
|
32
34
|
|
33
35
|
div class="login-footer modal-footer"
|
34
36
|
= submit_tag(pat('login.sign_in'), :class => 'btn btn-primary pull-right')
|
35
|
-
= javascript_include_tag 'jquery-1.9.0.min', (Padrino.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
|
37
|
+
= javascript_include_tag 'jquery-1.9.0.min', (Padrino.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
|
@@ -3,7 +3,7 @@
|
|
3
3
|
fieldset class='control-group#{error ? ' has-error' : ''}'
|
4
4
|
= f.label :<%= column[:name] %>, :class => 'control-label'
|
5
5
|
div class='controls'
|
6
|
-
= f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'input-
|
6
|
+
= f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'form-control input-large input-with-feedback'<%- if (index == 0) -%>, :autofocus => true<%- end -%>
|
7
7
|
|
8
8
|
span class='help-inline' = error ? f.error_message_on(:<%= column[:name] %>, :class => 'text-error') : pat(:example)
|
9
9
|
<%- end -%>
|
@@ -13,4 +13,4 @@ div class="form-actions"
|
|
13
13
|
|
|
14
14
|
= f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue'
|
15
15
|
|
|
16
|
-
= link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn'
|
16
|
+
= link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn btn-default'
|
@@ -24,7 +24,7 @@ div class="tabs-content"
|
|
24
24
|
- form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do
|
25
25
|
= hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true
|
26
26
|
= submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small'
|
27
|
-
div class='btn btn-small cancel' = pat(:cancel)
|
27
|
+
div class='btn btn-default btn-small cancel' = pat(:cancel)
|
28
28
|
<%- @orm.columns.each_with_index do |column, i| -%>
|
29
29
|
th class='header' = mat(:<%= @orm.name_singular %>, :<%= column.name %>)
|
30
30
|
<%- end -%>
|
@@ -53,4 +53,4 @@ div class="tabs-content"
|
|
53
53
|
div class='popover-content'
|
54
54
|
- form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do
|
55
55
|
= submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small'
|
56
|
-
div class='btn btn-small cancel' = pat(:cancel)
|
56
|
+
div class='btn btn-default btn-small cancel' = pat(:cancel)
|
@@ -13,14 +13,14 @@ module Padrino
|
|
13
13
|
end
|
14
14
|
|
15
15
|
##
|
16
|
-
# Returns the current_account, it's an instance of
|
16
|
+
# Returns the current_account, it's an instance of Account model.
|
17
17
|
#
|
18
18
|
def current_account
|
19
19
|
@current_account ||= login_from_session
|
20
20
|
end
|
21
21
|
|
22
22
|
##
|
23
|
-
# Override the current_account, you must provide an instance of Account
|
23
|
+
# Override the current_account, you must provide an instance of Account model.
|
24
24
|
#
|
25
25
|
# @example
|
26
26
|
# set_current_account(Account.authenticate(params[:email], params[:password])
|
@@ -31,7 +31,7 @@ module Padrino
|
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
34
|
-
# Returns true if the +current_account+ is allowed to see the requested path
|
34
|
+
# Returns true if the +current_account+ is allowed to see the requested path.
|
35
35
|
#
|
36
36
|
# For configure this role please refer to: +Padrino::Admin::AccessControl::Base+
|
37
37
|
#
|
@@ -40,7 +40,7 @@ module Padrino
|
|
40
40
|
end
|
41
41
|
|
42
42
|
##
|
43
|
-
# Returns project modules for the current account
|
43
|
+
# Returns project modules for the current account.
|
44
44
|
#
|
45
45
|
def project_modules
|
46
46
|
access_control.project_modules(current_account)
|
@@ -60,7 +60,7 @@ module Padrino
|
|
60
60
|
end
|
61
61
|
|
62
62
|
##
|
63
|
-
# Store in session[:return_to] the env['REQUEST_URI']
|
63
|
+
# Store in session[:return_to] the env['REQUEST_URI'].
|
64
64
|
#
|
65
65
|
def store_location!
|
66
66
|
session[:return_to] = env['REQUEST_URI']
|
@@ -68,7 +68,7 @@ module Padrino
|
|
68
68
|
|
69
69
|
##
|
70
70
|
# Redirect the account to the page that requested an authentication or
|
71
|
-
# if the account is not allowed/logged return it to a default page
|
71
|
+
# if the account is not allowed/logged return it to a default page.
|
72
72
|
#
|
73
73
|
def redirect_back_or_default(default)
|
74
74
|
return_to = session.delete(:return_to)
|
@@ -76,37 +76,37 @@ module Padrino
|
|
76
76
|
end
|
77
77
|
|
78
78
|
private
|
79
|
-
def access_denied
|
80
|
-
# If we have a login_page we redirect the user
|
81
|
-
if login_page
|
82
|
-
redirect(login_page)
|
83
|
-
# If no match we halt with 401
|
84
|
-
else
|
85
|
-
halt 401, "You don't have permission for this resource"
|
86
|
-
end
|
87
|
-
end
|
88
79
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
80
|
+
def access_denied
|
81
|
+
# If we have a login_page we redirect the user
|
82
|
+
if login_page
|
83
|
+
redirect(login_page)
|
84
|
+
else
|
85
|
+
halt 401, "You don't have permission for this resource"
|
94
86
|
end
|
87
|
+
end
|
95
88
|
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
def login_page
|
90
|
+
login_page ||= settings.login_page rescue nil
|
91
|
+
return unless login_page
|
92
|
+
login_page = File.join(ENV['RACK_BASE_URI'].to_s, login_page) if ENV['RACK_BASE_URI']
|
93
|
+
login_page
|
94
|
+
end
|
99
95
|
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
def store_location
|
97
|
+
settings.store_location rescue nil
|
98
|
+
end
|
103
99
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
100
|
+
def login_from_session
|
101
|
+
admin_model_obj.find_by_id(session[settings.session_id]) if admin_model_obj
|
102
|
+
end
|
103
|
+
|
104
|
+
def admin_model_obj
|
105
|
+
@_admin_model_obj ||= settings.admin_model.constantize
|
106
|
+
rescue NameError
|
107
|
+
raise Padrino::Admin::AccessControlError, "You must define an #{settings.admin_model} Model!"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -1,34 +1,28 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Admin
|
3
|
-
##
|
4
|
-
# Contains all admin related helpers.
|
5
|
-
#
|
6
3
|
module Helpers
|
7
|
-
##
|
8
|
-
# Admin helpers
|
9
|
-
#
|
10
4
|
module ViewHelpers
|
11
5
|
##
|
12
|
-
# Icon's Bootstrap helper
|
6
|
+
# Icon's Bootstrap helper.
|
13
7
|
#
|
14
8
|
# @param [Symbol] icon
|
15
|
-
# The specified icon type
|
9
|
+
# The specified icon type.
|
16
10
|
#
|
17
11
|
# @param [Symbol] tag
|
18
12
|
# The HTML tag.
|
19
13
|
#
|
20
|
-
# @return [String]
|
14
|
+
# @return [String] HTML tag with prepend icon
|
21
15
|
#
|
22
16
|
# @example
|
23
17
|
# tag_icon(:edit, :list)
|
24
18
|
#
|
25
19
|
def tag_icon(icon, tag = nil)
|
26
|
-
content = content_tag(:i, '', :class=> "icon-#{icon
|
27
|
-
content << " #{tag
|
20
|
+
content = content_tag(:i, '', :class=> "icon-#{icon}")
|
21
|
+
content << " #{tag}"
|
28
22
|
end
|
29
23
|
|
30
24
|
##
|
31
|
-
# Translates a given word for padrino admin
|
25
|
+
# Translates a given word for padrino admin.
|
32
26
|
#
|
33
27
|
# @param [String] word
|
34
28
|
# The specified word to admin translate.
|
@@ -44,7 +38,7 @@ module Padrino
|
|
44
38
|
# # => t("padrino.admin.profile", :default => "My Profile")
|
45
39
|
# pat(:profile, "My Profile")
|
46
40
|
#
|
47
|
-
def padrino_admin_translate(word
|
41
|
+
def padrino_admin_translate(word, *args)
|
48
42
|
options = args.extract_options!
|
49
43
|
options[:default] ||= word.to_s.humanize
|
50
44
|
t("padrino.admin.#{word}", options)
|
@@ -72,7 +66,7 @@ module Padrino
|
|
72
66
|
alias :mat :t_attr
|
73
67
|
|
74
68
|
##
|
75
|
-
# Translates model name
|
69
|
+
# Translates model name.
|
76
70
|
#
|
77
71
|
# @param [Symbol] attribute
|
78
72
|
# The attribute name in the model to translate.
|
@@ -87,8 +81,7 @@ module Padrino
|
|
87
81
|
t("models.#{model}.name", :default => model.to_s.humanize)
|
88
82
|
end
|
89
83
|
alias :mt :model_translate
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end # Padrino
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -7,13 +7,13 @@ module Padrino
|
|
7
7
|
#
|
8
8
|
module Utils
|
9
9
|
##
|
10
|
-
# This
|
10
|
+
# This Util it's used for encrypt/decrypt password.
|
11
11
|
# We want password decryptable because generally for our sites we have: password_lost.
|
12
12
|
# We prefer send original password instead reset them.
|
13
13
|
#
|
14
14
|
module Crypt
|
15
15
|
##
|
16
|
-
# Decrypts the current string using the current key specified
|
16
|
+
# Decrypts the current string using the current key specified.
|
17
17
|
#
|
18
18
|
def decrypt(password)
|
19
19
|
cipher = build_cipher(:decrypt, password)
|
@@ -21,20 +21,21 @@ module Padrino
|
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
24
|
-
# Encrypts the current string using the current key and algorithm specified
|
24
|
+
# Encrypts the current string using the current key and algorithm specified.
|
25
25
|
#
|
26
26
|
def encrypt(password)
|
27
27
|
cipher = build_cipher(:encrypt, password)
|
28
28
|
[cipher.update(self) + cipher.final].pack('m').chomp
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
private
|
32
|
+
|
33
|
+
def build_cipher(type, password)
|
33
34
|
cipher = OpenSSL::Cipher::Cipher.new("DES-EDE3-CBC").send(type)
|
34
35
|
cipher.pkcs5_keyivgen(password)
|
35
36
|
cipher
|
36
37
|
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/padrino-admin.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
+
require 'active_support/core_ext/array/conversions'
|
1
2
|
require 'padrino-core'
|
2
3
|
require 'padrino-helpers'
|
3
|
-
require 'active_support/core_ext/array/conversions'
|
4
4
|
|
5
5
|
FileSet.glob_require('padrino-admin/*.rb', __FILE__)
|
6
6
|
FileSet.glob_require('padrino-admin/{helpers,utils}/*.rb', __FILE__)
|
7
7
|
|
8
8
|
|
9
9
|
##
|
10
|
-
# Load our Padrino::Admin locales
|
10
|
+
# Load our Padrino::Admin locales.
|
11
11
|
#
|
12
12
|
# I18n.load_path = Dir["#{File.dirname(__FILE__)}/padrino-admin/locale/*.yml"]
|
13
13
|
|
14
14
|
module Padrino
|
15
15
|
##
|
16
|
-
# Padrino::Admin is beautiful Ajax Admin, with these
|
16
|
+
# Padrino::Admin is beautiful Ajax Admin, with these features:
|
17
17
|
#
|
18
18
|
# Orm Agnostic:: Adapters for datamapper, activerecord, mongomapper, couchdb (now only: datamapper and activerecord), ohm
|
19
|
-
# Authentication:: Support for Account authentication, Account Permission
|
19
|
+
# Authentication:: Support for Account authentication, Account Permission management
|
20
20
|
# Scaffold:: You can simply create a new "admin interface" simply providing a Model
|
21
21
|
# Ajax Uploads:: You can upload file, manage them and attach them to any model in a quick and simple way (coming soon)
|
22
22
|
#
|
@@ -40,5 +40,4 @@ begin
|
|
40
40
|
require 'padrino-gen'
|
41
41
|
Padrino::Generators.load_paths << Dir[File.dirname(__FILE__) + '/padrino-admin/generators/{actions,orm,admin_app,admin_page}.rb']
|
42
42
|
rescue LoadError
|
43
|
-
# Fail silently
|
44
43
|
end
|
@@ -67,15 +67,16 @@ class Account
|
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
|
71
|
+
def generate_password
|
72
|
+
return if password.blank?
|
73
|
+
self.salt = Digest::SHA1.hexdigest("--#{Time.now}--#{email}--") if new?
|
74
|
+
self.crypted_password = password.encrypt(self.salt)
|
75
|
+
end
|
76
|
+
|
77
|
+
def password_required
|
78
|
+
crypted_password.blank? || !password.blank?
|
79
|
+
end
|
79
80
|
end
|
80
81
|
|
81
82
|
DataMapper.auto_migrate!
|
@@ -17,7 +17,7 @@ describe "AccountModelGenerator" do
|
|
17
17
|
@model = "#{@apptmp}/sample_project/models/account.rb"
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should be
|
20
|
+
it 'should be an activerecord model instance' do
|
21
21
|
assert_match_in_file(/class Account < ActiveRecord::Base/m, @model)
|
22
22
|
end
|
23
23
|
end
|
@@ -29,7 +29,7 @@ describe "AccountModelGenerator" do
|
|
29
29
|
@model = "#{@apptmp}/sample_project/models/account.rb"
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'should be
|
32
|
+
it 'should be an activerecord model instance' do
|
33
33
|
assert_match_in_file(/class Account < ActiveRecord::Base/m, @model)
|
34
34
|
end
|
35
35
|
end
|