padrino-admin 0.10.6 → 0.10.7

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.
Files changed (29) hide show
  1. data/lib/padrino-admin/access_control.rb +5 -5
  2. data/lib/padrino-admin/generators/admin_app.rb +21 -15
  3. data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +7 -7
  4. data/lib/padrino-admin/generators/templates/account/couchrest.rb.tt +15 -15
  5. data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +7 -7
  6. data/lib/padrino-admin/generators/templates/account/mini_record.rb.tt +7 -7
  7. data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +7 -7
  8. data/lib/padrino-admin/generators/templates/account/mongomapper.rb.tt +7 -7
  9. data/lib/padrino-admin/generators/templates/account/seeds.rb.tt +2 -2
  10. data/lib/padrino-admin/generators/templates/account/sequel.rb.tt +8 -8
  11. data/lib/padrino-admin/generators/templates/app.rb.tt +1 -1
  12. data/lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt +2 -2
  13. data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +2 -2
  14. data/lib/padrino-admin/generators/templates/haml/app/layouts/application.haml.tt +2 -2
  15. data/lib/padrino-admin/generators/templates/slim/app/base/_sidebar.slim.tt +2 -2
  16. data/lib/padrino-admin/generators/templates/slim/app/base/index.slim.tt +1 -1
  17. data/lib/padrino-admin/generators/templates/slim/app/layouts/application.slim.tt +14 -13
  18. data/lib/padrino-admin/generators/templates/slim/app/sessions/new.slim.tt +10 -10
  19. data/lib/padrino-admin/generators/templates/slim/page/_form.slim.tt +6 -6
  20. data/lib/padrino-admin/generators/templates/slim/page/edit.slim.tt +9 -9
  21. data/lib/padrino-admin/generators/templates/slim/page/index.slim.tt +11 -11
  22. data/lib/padrino-admin/generators/templates/slim/page/new.slim.tt +8 -8
  23. data/lib/padrino-admin/locale/admin/ro.yml +16 -0
  24. data/lib/padrino-admin/locale/admin/sv.yml +16 -0
  25. data/lib/padrino-admin/locale/orm/ro.yml +26 -0
  26. data/lib/padrino-admin/locale/orm/sv.yml +26 -0
  27. data/test/fixtures/data_mapper.rb +1 -0
  28. data/test/generators/test_admin_app_generator.rb +39 -0
  29. metadata +52 -42
@@ -145,9 +145,9 @@ module Padrino
145
145
  ##
146
146
  # Create a project module
147
147
  #
148
- def project_module(name, path)
148
+ def project_module(name, path, options={})
149
149
  allow(path)
150
- @project_modules << ProjectModule.new(name, path)
150
+ @project_modules << ProjectModule.new(name, path, options)
151
151
  end
152
152
  end # Authorization
153
153
 
@@ -155,10 +155,10 @@ module Padrino
155
155
  # Project Module class
156
156
  #
157
157
  class ProjectModule
158
- attr_reader :name
158
+ attr_reader :name, :options
159
159
 
160
- def initialize(name, path) # @private
161
- @name, @path = name, path
160
+ def initialize(name, path, options={}) # @private
161
+ @name, @path, @options = name, path, options
162
162
  end
163
163
 
164
164
  ##
@@ -55,22 +55,27 @@ module Padrino
55
55
  self.behavior = :revoke if options[:destroy]
56
56
 
57
57
  empty_directory destination_root("admin")
58
+
59
+ # Setup Admin Model
60
+ @model_name = options[:admin_model].classify
61
+ @model_singular = @model_name.underscore
62
+ @model_plural = @model_singular.pluralize
63
+
58
64
  directory "templates/app", destination_root("admin")
59
65
  directory "templates/assets", destination_root("public", "admin")
60
66
  template "templates/app.rb.tt", destination_root("admin/app.rb")
61
67
  append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"Admin\").to(\"/admin\")"
62
68
  insert_middleware 'ActiveRecord::ConnectionAdapters::ConnectionManagement', 'admin' if [:mini_record, :activerecord].include?(orm)
63
69
 
64
- account_params = [
65
- options[:admin_model].underscore, "name:string", "surname:string", "email:string", "crypted_password:string", "role:string",
70
+ params = [
71
+ @model_singular, "name:string", "surname:string", "email:string", "crypted_password:string", "role:string",
66
72
  "-a=#{options[:app]}",
67
73
  "-r=#{options[:root]}"
68
74
  ]
75
+ params << "-s" if options[:skip_migration]
76
+ params << "-d" if options[:destroy]
69
77
 
70
- account_params << "-s" if options[:skip_migration]
71
- account_params << "-d" if options[:destroy]
72
-
73
- Padrino::Generators::Model.start(account_params)
78
+ Padrino::Generators::Model.start(params)
74
79
  column = Struct.new(:name, :type)
75
80
  columns = [:id, :name, :surname, :email].map { |col| column.new(col) }
76
81
  column_fields = [
@@ -82,11 +87,11 @@ module Padrino
82
87
  { :name => :role, :field_type => :text_field }
83
88
  ]
84
89
 
85
- admin_app = Padrino::Generators::AdminPage.new([options[:admin_model].underscore], :root => options[:root], :destroy => options[:destroy])
86
- admin_app.default_orm = Padrino::Admin::Generators::Orm.new(options[:admin_model].underscore, orm, columns, column_fields)
90
+ admin_app = Padrino::Generators::AdminPage.new([@model_singular], :root => options[:root], :destroy => options[:destroy])
91
+ admin_app.default_orm = Padrino::Admin::Generators::Orm.new(@model_singular, orm, columns, column_fields)
87
92
  admin_app.invoke_all
88
93
 
89
- template "templates/account/#{orm}.rb.tt", destination_root(options[:app], "models", "#{options[:admin_model].underscore}.rb"), :force => true
94
+ template "templates/account/#{orm}.rb.tt", destination_root(options[:app], "models", "#{@model_singular}.rb"), :force => true
90
95
 
91
96
  if File.exist?(destination_root("db/seeds.rb"))
92
97
  run "mv #{destination_root('db/seeds.rb')} #{destination_root('db/seeds.old')}"
@@ -104,13 +109,14 @@ module Padrino
104
109
  template "templates/#{ext}/app/layouts/application.#{ext}.tt", destination_root("admin/views/layouts/application.#{ext}")
105
110
  template "templates/#{ext}/app/sessions/new.#{ext}.tt", destination_root("admin/views/sessions/new.#{ext}")
106
111
 
107
- model_singular = options[:admin_model].underscore
108
- model_plural = model_singular.pluralize
109
-
110
- add_project_module model_plural
112
+ add_project_module @model_plural
111
113
  require_dependencies('bcrypt-ruby', :require => 'bcrypt')
112
- gsub_file destination_root("admin/views/#{model_plural}/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
113
- gsub_file destination_root("admin/controllers/#{model_plural}.rb"), "if #{model_singular}.destroy", "if #{model_singular} != current_account && #{model_singular}.destroy"
114
+
115
+ # A nicer select box
116
+ gsub_file destination_root("admin/views/#{@model_plural}/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
117
+
118
+ # Destroy account only if not logged in
119
+ gsub_file destination_root("admin/controllers/#{@model_plural}.rb"), "if #{@model_singular}.destroy", "if #{@model_singular} != current_account && #{@model_singular}.destroy"
114
120
  return if self.behavior == :revoke
115
121
 
116
122
  instructions = []
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %> < ActiveRecord::Base
1
+ class <%= @model_name %> < ActiveRecord::Base
2
2
  attr_accessor :password, :password_confirmation
3
3
 
4
4
  # Validations
@@ -28,11 +28,11 @@ class <%= options[:admin_model].underscore.camelize %> < ActiveRecord::Base
28
28
  end
29
29
 
30
30
  private
31
- def encrypt_password
32
- self.crypted_password = ::BCrypt::Password.create(password)
33
- end
31
+ def encrypt_password
32
+ self.crypted_password = ::BCrypt::Password.create(password)
33
+ end
34
34
 
35
- def password_required
36
- crypted_password.blank? || password.present?
37
- end
35
+ def password_required
36
+ crypted_password.blank? || password.present?
37
+ end
38
38
  end
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %> < CouchRest::Model::Base
1
+ class <%= @model_name %> < CouchRest::Model::Base
2
2
  attr_accessor :password, :password_confirmation
3
3
 
4
4
  # Properties
@@ -44,23 +44,23 @@ class <%= options[:admin_model].underscore.camelize %> < CouchRest::Model::Base
44
44
  end
45
45
 
46
46
  private
47
- def encrypt_password
48
- self.crypted_password = ::BCrypt::Password.create(password)
49
- end
47
+ def encrypt_password
48
+ self.crypted_password = ::BCrypt::Password.create(password)
49
+ end
50
50
 
51
- def password_required
52
- crypted_password.blank? || password.present?
53
- end
51
+ def password_required
52
+ crypted_password.blank? || password.present?
53
+ end
54
54
 
55
- def unique_email_validator
56
- account = Account.find_by_email(email)
55
+ def unique_email_validator
56
+ account = self.class.find_by_email(email)
57
57
 
58
- # didn't find email in the database
59
- return if account.nil?
58
+ # didn't find email in the database
59
+ return if account.nil?
60
60
 
61
- # account with same email in database is this account
62
- return if has_key?('_id') && self['_id'] == account['_id']
61
+ # account with same email in database is this account
62
+ return if has_key?('_id') && self['_id'] == account['_id']
63
63
 
64
- errors.add(:email, "is not unique")
65
- end
64
+ errors.add(:email, "is not unique")
65
+ end
66
66
  end
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %>
1
+ class <%= @model_name %>
2
2
  include DataMapper::Resource
3
3
  include DataMapper::Validate
4
4
  attr_accessor :password, :password_confirmation
@@ -45,11 +45,11 @@ class <%= options[:admin_model].underscore.camelize %>
45
45
  end
46
46
 
47
47
  private
48
- def password_required
49
- crypted_password.blank? || password.present?
50
- end
48
+ def password_required
49
+ crypted_password.blank? || password.present?
50
+ end
51
51
 
52
- def encrypt_password
53
- self.crypted_password = ::BCrypt::Password.create(password) if password.present?
54
- end
52
+ def encrypt_password
53
+ self.crypted_password = ::BCrypt::Password.create(password) if password.present?
54
+ end
55
55
  end
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %> < ActiveRecord::Base
1
+ class <%= @model_name %> < ActiveRecord::Base
2
2
  attr_accessor :password, :password_confirmation
3
3
 
4
4
  # Fields
@@ -31,11 +31,11 @@ class <%= options[:admin_model].underscore.camelize %> < ActiveRecord::Base
31
31
  end
32
32
 
33
33
  private
34
- def encrypt_password
35
- self.crypted_password = ::BCrypt::Password.create(password)
36
- end
34
+ def encrypt_password
35
+ self.crypted_password = ::BCrypt::Password.create(password)
36
+ end
37
37
 
38
- def password_required
39
- crypted_password.blank? || password.present?
40
- end
38
+ def password_required
39
+ crypted_password.blank? || password.present?
40
+ end
41
41
  end
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %>
1
+ class <%= @model_name %>
2
2
  include Mongoid::Document
3
3
  attr_accessor :password, :password_confirmation
4
4
 
@@ -43,11 +43,11 @@ class <%= options[:admin_model].underscore.camelize %>
43
43
  end
44
44
 
45
45
  private
46
- def encrypt_password
47
- self.crypted_password = ::BCrypt::Password.create(self.password)
48
- end
46
+ def encrypt_password
47
+ self.crypted_password = ::BCrypt::Password.create(self.password)
48
+ end
49
49
 
50
- def password_required
51
- crypted_password.blank? || self.password.present?
52
- end
50
+ def password_required
51
+ crypted_password.blank? || self.password.present?
52
+ end
53
53
  end
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %>
1
+ class <%= @model_name %>
2
2
  include MongoMapper::Document
3
3
  attr_accessor :password, :password_confirmation
4
4
 
@@ -36,11 +36,11 @@ class <%= options[:admin_model].underscore.camelize %>
36
36
  end
37
37
 
38
38
  private
39
- def encrypt_password
40
- self.crypted_password = ::BCrypt::Password.create(password)
41
- end
39
+ def encrypt_password
40
+ self.crypted_password = ::BCrypt::Password.create(password)
41
+ end
42
42
 
43
- def password_required
44
- crypted_password.blank? || password.present?
45
- end
43
+ def password_required
44
+ crypted_password.blank? || password.present?
45
+ end
46
46
  end
@@ -10,11 +10,11 @@ password = shell.ask "Tell me the password to use:"
10
10
 
11
11
  shell.say ""
12
12
 
13
- account = <%= options[:admin_model].underscore.camelize %>.create(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin")
13
+ account = <%= @model_name %>.create(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin")
14
14
 
15
15
  if account.valid?
16
16
  shell.say "================================================================="
17
- shell.say "<%= options[:admin_model].underscore.camelize %> has been successfully created, now you can login with:"
17
+ shell.say "<%= @model_name %> has been successfully created, now you can login with:"
18
18
  shell.say "================================================================="
19
19
  shell.say " email: #{email}"
20
20
  shell.say " password: #{password}"
@@ -1,4 +1,4 @@
1
- class <%= options[:admin_model].underscore.camelize %> < ::Sequel::Model
1
+ class <%= @model_name %> < ::Sequel::Model
2
2
 
3
3
  plugin :validation_helpers
4
4
 
@@ -38,15 +38,15 @@ class <%= options[:admin_model].underscore.camelize %> < ::Sequel::Model
38
38
  end
39
39
 
40
40
  def has_password?(password)
41
- ::BCrypt::Password.new(crypted_password) == password
41
+ ::BCrypt::Password.new(self.crypted_password) == password
42
42
  end
43
43
 
44
44
  private
45
- def encrypt_password
46
- self.crypted_password = ::BCrypt::Password.create(password) if password.present?
47
- end
45
+ def encrypt_password
46
+ self.crypted_password = ::BCrypt::Password.create(password) if password.present?
47
+ end
48
48
 
49
- def password_required
50
- crypted_password.blank? || password.present?
51
- end
49
+ def password_required
50
+ self.crypted_password.blank? || password.present?
51
+ end
52
52
  end
@@ -20,7 +20,7 @@ class Admin < Padrino::Application
20
20
  # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
21
21
  #
22
22
 
23
- set :admin_model, '<%= options[:admin_model] %>'
23
+ set :admin_model, '<%= @model_name %>'
24
24
  set :login_page, "/admin/sessions/new"
25
25
 
26
26
  enable :sessions
@@ -5,11 +5,11 @@ Admin.controllers :sessions do
5
5
  end
6
6
 
7
7
  post :create do
8
- if account = <%= options[:admin_model] %>.authenticate(params[:email], params[:password])
8
+ if account = <%= @model_name %>.authenticate(params[:email], params[:password])
9
9
  set_current_account(account)
10
10
  redirect url(:base, :index)
11
11
  elsif Padrino.env == :development && params[:bypass]
12
- account = <%= options[:admin_model] %>.first
12
+ account = <%= @model_name %>.first
13
13
  set_current_account(account)
14
14
  redirect url(:base, :index)
15
15
  else
@@ -11,7 +11,7 @@
11
11
  <h1><%%= link_to "Padrino Admin", url(:base_index) %></h1>
12
12
  <div id="user-navigation">
13
13
  <ul class="wat-cf">
14
- <li><%%= link_to pat(:profile), url(:<%= options[:admin_model].underscore.pluralize %>, :edit, :id => current_account.id) %></li>
14
+ <li><%%= link_to pat(:profile), url(:<%= @model_plural %>, :edit, :id => current_account.id) %></li>
15
15
  <li><%%= button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to %></li>
16
16
  </ul>
17
17
  </div>
@@ -31,7 +31,7 @@
31
31
  <%%= yield %>
32
32
  <div id="footer">
33
33
  <div class="block">
34
- <p>Copyright &copy; <%%= Time.now.year %> Your Site - Powered by <a href="https://github.com/padrino/padrino-framework" target="_blank">Padrino v.<%%= Padrino.version %>.</a></p>
34
+ <p>Copyright &copy; <%%= Time.now.year %> Your Site - Powered by <a href="http://www.padrinorb.com" target="_blank">Padrino v.<%%= Padrino.version %>.</a></p>
35
35
  </div>
36
36
  </div>
37
37
  </div>
@@ -10,7 +10,7 @@
10
10
  %h1=link_to "Padrino Admin", url(:base_index)
11
11
  #user-navigation
12
12
  %ul.wat-cf
13
- %li=link_to pat(:profile), url(:<%= options[:admin_model].underscore.pluralize %>, :edit, :id => current_account.id)
13
+ %li=link_to pat(:profile), url(:<%= @model_plural %>, :edit, :id => current_account.id)
14
14
  %li=button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to
15
15
  #main-navigation
16
16
  %ul.wat-cf
@@ -27,5 +27,5 @@
27
27
  Copyright &copy;
28
28
  =Time.now.year
29
29
  Your Site - Powered by
30
- =link_to "Padrino v.#{Padrino.version}", "http://padrino.github.com", :target => :_blank
30
+ =link_to "Padrino v.#{Padrino.version}", "http://www.padrinorb.com", :target => :_blank
31
31
  #sidebar=yield_content :sidebar
@@ -7,5 +7,5 @@
7
7
  .block
8
8
  h3 Links
9
9
  ul.navigation
10
- li==link_to "Link 1"
11
- li==link_to "Link 2"
10
+ li == link_to 'Link 1'
11
+ li == link_to 'Link 2'
@@ -22,4 +22,4 @@
22
22
  span.hightlight
23
23
  | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
24
24
 
25
- -content_for :sidebar, partial("base/sidebar")
25
+ - content_for :sidebar, partial("base/sidebar")
@@ -1,30 +1,31 @@
1
1
  doctype html
2
- html lang="en" xmlns="http://www.w3.org/1999/xhtml"
2
+ html lang='en' xmlns='http://www.w3.org/1999/xhtml'
3
3
  head
4
- meta content="text/html; charset=utf-8" http-equiv="Content-Type"
4
+ meta content='text/html; charset=utf-8' http-equiv='Content-Type'
5
5
  title Padrino Admin
6
- ==stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
6
+ == stylesheet_link_tag 'base', 'themes/<%= options[:theme] %>/style'
7
7
 
8
8
  body
9
9
  #container
10
10
  #header
11
- h1==link_to "Padrino Admin", url(:base_index)
11
+ h1 == link_to 'Padrino Admin', url(:base_index)
12
12
  #user-navigation
13
13
  ul.wat-cf
14
- li==link_to pat(:profile), url(:<%= options[:admin_model].underscore.pluralize %>, :edit, :id => current_account.id)
15
- li==button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to
14
+ li == link_to pat(:profile), url(:<%= @model_plural %>, :edit, :id => current_account.id)
15
+ li == button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to
16
16
  #main-navigation
17
17
  ul.wat-cf
18
- -project_modules.each do |project_module|
19
- li class={"active" if request.path_info =~ /^#{project_module.path}/}
20
- ==link_to project_module.human_name, project_module.path("/admin")
18
+ - project_modules.each do |project_module|
19
+ li class=(:active if request.path_info =~ /^#{project_module.path}/)
20
+ == link_to project_module.human_name, project_module.path('/admin')
21
21
  #wrapper.wat-cf
22
- .flash==[:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
22
+ .flash == [:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
23
23
  #main
24
- ==yield
24
+ == yield
25
25
  #footer
26
26
  .block
27
27
  p
28
28
  ' Copyright &copy; #{Time.now.year} Your Site - Powered by
29
- ==link_to "Padrino v.#{Padrino.version}", "http://padrino.github.com", :target => :_blank
30
- #sidebar==yield_content :sidebar
29
+ == link_to "Padrino v.#{Padrino.version}", 'http://www.padrinorb.com', :target => :_blank
30
+ #sidebar
31
+ == yield_content :sidebar
@@ -1,9 +1,9 @@
1
1
  doctype html
2
- html lang="en" xmlns="http://www.w3.org/1999/xhtml"
2
+ html lang='en' xmlns='http://www.w3.org/1999/xhtml'
3
3
  head
4
- meta content="text/html; charset=utf-8" http-equiv="Content-Type"
4
+ meta content='text/html; charset=utf-8' http-equiv='Content-Type'
5
5
  title Padrino Admin
6
- ==stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
6
+ == stylesheet_link_tag 'base', 'themes/<%= options[:theme] %>/style'
7
7
 
8
8
  body
9
9
  #container
@@ -12,20 +12,20 @@ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
12
12
  #block-login.block
13
13
  h2 Login Box
14
14
  .content.login
15
- .flash==[:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
16
- ==form_tag(url(:sessions, :create), :class => 'form login') do
15
+ .flash == [:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
16
+ - form_tag url(:sessions, :create), :class => 'form login' do
17
17
  .group.wat-cf
18
18
  .left
19
19
  label.label.right Login
20
- .right==text_field_tag :email, :value => params[:email], :class => :text_field
20
+ .right == text_field_tag :email, :value => params[:email], :class => :text_field
21
21
  .group.wat-cf
22
22
  .left
23
23
  label.label.right Password
24
- .right==password_field_tag :password, :value => params[:password], :class => :text_field
25
- -if Padrino.env == :development
24
+ .right == password_field_tag :password, :value => params[:password], :class => :text_field
25
+ - if Padrino.env == :development
26
26
  .group.wat-cf
27
27
  .left
28
28
  label.label.right Bypass login?
29
- .right==check_box_tag :bypass
29
+ .right == check_box_tag :bypass
30
30
  .group.navform.wat-cf
31
- .right==submit_tag('Sign In', :class => :button)
31
+ .right == submit_tag 'Sign In', :class => :button
@@ -1,14 +1,14 @@
1
1
  <%- @orm.column_fields.each do |column| -%>
2
2
  .group
3
- ==f.label :<%= column[:name] %>
4
- ==f.error_message_on :<%= column[:name] %>
5
- ==f.<%= column[:field_type] %> :<%= column[:name] %>, :class => :<%= column[:field_type] %>
3
+ == f.label :<%= column[:name] %>
4
+ == f.error_message_on :<%= column[:name] %>
5
+ == f.<%= column[:field_type] %> :<%= column[:name] %>, :class => :<%= column[:field_type] %>
6
6
  br
7
7
  span.description Ex: a simple text
8
8
 
9
9
  <%- end -%>
10
10
 
11
11
  .group.navform.wat-cf
12
- ==f.submit pat(:save), :class => :button
13
- =="&nbsp;"
14
- ==f.submit pat(:cancel), :onclick => "window.location='#{url(:<%= @orm.name_plural %>, :index)}';return false", :class => :button
12
+ == f.submit pat(:save), :class => :button
13
+ == "&nbsp;"
14
+ == f.submit pat(:cancel), :onclick => "window.location='#{url(:<%= @orm.name_plural %>, :index)}';return false", :class => :button
@@ -1,16 +1,16 @@
1
1
  .block
2
2
  .secondary-navigation
3
3
  ul.wat-cf
4
- li.first==link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
- li==link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
6
- li.active==link_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
4
+ li.first == link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
+ li == link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
6
+ li.active == link_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
7
7
  .content
8
8
  h2.title
9
- =pat(:edit)
10
- =="&nbsp;"
11
- =mt(:<%= @orm.name_singular %>)
9
+ = pat(:edit)
10
+ == "&nbsp;"
11
+ = mt(:<%= @orm.name_singular %>)
12
12
  .inner
13
- ==form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :update, :id => @<%= @orm.name_singular %>.id), :method => :put, :class => :form do |f|
14
- ==partial "<%= @orm.name_plural %>/form", :locals => { :f => f }
13
+ == form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :update, :id => @<%= @orm.name_singular %>.id), :method => :put, :class => :form do |f|
14
+ == partial '<%= @orm.name_plural %>/form', :locals => { :f => f }
15
15
 
16
- -content_for :sidebar, partial("base/sidebar")
16
+ - content_for :sidebar, partial("base/sidebar")
@@ -1,30 +1,30 @@
1
1
  .block
2
2
  .secondary-navigation
3
3
  ul.wat-cf
4
- li.first.active==link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
- li==link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
4
+ li.first.active == link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
+ li == link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
6
6
  .content
7
7
  h2.title
8
- ==pat(:all)
9
- =="&nbsp;"
10
- ==mt(:<%= @orm.name_plural %>)
8
+ == pat(:all)
9
+ == '&nbsp;'
10
+ == mt(:<%= @orm.name_plural %>)
11
11
  .inner
12
12
  table.table
13
13
  tr
14
14
  <%- @orm.columns.each_with_index do |column, i| -%>
15
15
  th<%= ".first" if i==0 %>=mat(:<%= @orm.name_singular %>, :<%= column.name %>)
16
16
  <%- end -%>
17
- th.last=="&nbsp;"
18
- -@<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>|
17
+ th.last == '&nbsp;'
18
+ - @<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>|
19
19
  tr
20
20
  <%- @orm.columns.each_with_index do |column, i| -%>
21
21
  td<%= ".first" if i==0 %>=<%= @orm.name_singular %>.<%= column.name %>
22
22
  <%- end -%>
23
23
  td.last
24
- ==button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
25
- ==" | "
26
- ==button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')"
24
+ == button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
25
+ == ' | '
26
+ == button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')"
27
27
  .actions-bar.wat-cf
28
- .actions=="&nbsp;"
28
+ .actions == '&nbsp;'
29
29
 
30
30
  -content_for :sidebar, partial("base/sidebar")
@@ -1,15 +1,15 @@
1
1
  .block
2
2
  .secondary-navigation
3
3
  ul.wat-cf
4
- li.first==link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
- li.active==link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
4
+ li.first == link_to pat(:list), url(:<%= @orm.name_plural %>, :index)
5
+ li.active == link_to pat(:new), url(:<%= @orm.name_plural %>, :new)
6
6
  .content
7
7
  h2.title
8
- =pat(:new)
9
- =="&nbsp;"
10
- =mt(:<%= @orm.name_singular %>)
8
+ = pat(:new)
9
+ == '&nbsp;'
10
+ = mt(:<%= @orm.name_singular %>)
11
11
  .inner
12
- ==form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :create), :class => :form do |f|
13
- ==partial "<%= @orm.name_plural %>/form", :locals => { :f => f }
12
+ - form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :create), :class => :form do |f|
13
+ == partial "<%= @orm.name_plural %>/form", :locals => { :f => f }
14
14
 
15
- -content_for :sidebar, partial("base/sidebar")
15
+ - content_for :sidebar, partial("base/sidebar")
@@ -0,0 +1,16 @@
1
+ ro:
2
+ padrino:
3
+ admin:
4
+ save: Salvează
5
+ cancel: Anulează
6
+ list: Listă
7
+ edit: Editează
8
+ new: Crează
9
+ show: Afișează
10
+ delete: Șterge
11
+ confirm: Ești sigur?
12
+ created_at: Creat la
13
+ all: Toate
14
+ profile: Profil
15
+ settings: Setări
16
+ logout: Delogare
@@ -0,0 +1,16 @@
1
+ sv:
2
+ padrino:
3
+ admin:
4
+ save: Spara
5
+ cancel: Avbryt
6
+ list: Lista
7
+ edit: Redigera
8
+ new: Ny
9
+ show: Visa
10
+ delete: Radera
11
+ confirm: Är du säker?
12
+ created_at: Skapad
13
+ all: Alla
14
+ profile: Profil
15
+ settings: Inställningar
16
+ logout: Logga ut
@@ -0,0 +1,26 @@
1
+ ro:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "nu este inclus în listă"
6
+ exclusion: "este rezervat"
7
+ invalid: "nu este valid"
8
+ confirmation: "nu corespunde cu confirmarea"
9
+ accepted: "trebuie să fie acceptat"
10
+ empty: "nu poate fi gol"
11
+ blank: "nu poate fi gol"
12
+ too_long: "este prea lung (maximul este %{count} caractere)"
13
+ too_short: "este prea scurt (minimul este %{count} caractere)"
14
+ wrong_length: "are lungime necorespunzătoare (trebuie să fie de %{count} caractere)"
15
+ taken: "este deja utilizat"
16
+ not_a_number: "nu este un număr"
17
+ greater_than: "trebuie să fie mai mare de %{count}"
18
+ greater_than_or_equal_to: "trebuie să fie mai mare sau egal cu %{count}"
19
+ equal_to: "trebuie să fie egal cu %{count}"
20
+ less_than: "trebuie să fie mai mic de %{count}"
21
+ less_than_or_equal_to: "trebuie să fie mai mic sau egal cu %{count}"
22
+ odd: "trebuie să fie impar"
23
+ even: "trebuie să fie par"
24
+ record_invalid: "Eroare la validare: %{errors}"
25
+ content_type: "format de fișier neacceptat"
26
+ activerecord: *activemodel
@@ -0,0 +1,26 @@
1
+ sv:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "är inte inkluderad i listan"
6
+ exclusion: "är reserverad"
7
+ invalid: "är ogiltig"
8
+ confirmation: "matchar inte konfirmeringen"
9
+ accepted: "måste accepteras"
10
+ empty: "kan inte vara tomt"
11
+ blank: "kan inte vara blankt"
12
+ too_long: "är för långt (max %{count} tecken)"
13
+ too_short: "är för kort (minst %{count} tecken)"
14
+ wrong_length: "är fel längd (borde vara %{count} tecken)"
15
+ taken: "är redan upptaget"
16
+ not_a_number: "är inte ett tal"
17
+ greater_than: "måste vara större än %{count}"
18
+ greater_than_or_equal_to: "måste vara större än eller lika med %{count}"
19
+ equal_to: "måste vara lika med %{count}"
20
+ less_than: "måste vara mindre än %{count}"
21
+ less_than_or_equal_to: "måste vara mindre än eller lika med %{count}"
22
+ odd: "måste vara udda"
23
+ even: "måste vara jämnt"
24
+ record_invalid: "Validering misslyckades: %{errors}"
25
+ content_type: "filformatet stöds ej"
26
+ activerecord: *activemodel
@@ -1,3 +1,4 @@
1
+ require 'jdbc/sqlite3' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
1
2
  require 'dm-core'
2
3
  require 'dm-migrations'
3
4
  require 'dm-validations'
@@ -125,6 +125,45 @@ describe "AdminAppGenerator" do
125
125
  assert_match_in_file 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.slim"
126
126
  end
127
127
 
128
+ should 'correctly generate a new padrino admin application with a custom model' do
129
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=slim') }
130
+ capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project", '-m=User') }
131
+ assert_file_exists("#{@apptmp}/sample_project")
132
+ assert_file_exists("#{@apptmp}/sample_project/admin")
133
+ assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
134
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers")
135
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/users.rb")
136
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/admin/controllers/users.rb")
137
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/base.rb")
138
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/sessions.rb")
139
+ assert_file_exists("#{@apptmp}/sample_project/admin/views")
140
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/users/_form.slim")
141
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/admin/views/users/_form.slim")
142
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/users/edit.slim")
143
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/admin/views/users/edit.slim")
144
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/users/index.slim")
145
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/admin/views/users/index.slim")
146
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/users/new.slim")
147
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/admin/views/users/new.slim")
148
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.slim")
149
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.slim")
150
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/_sidebar.slim")
151
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.slim")
152
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/layouts/application.slim")
153
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.slim")
154
+ assert_file_exists("#{@apptmp}/sample_project/public/admin")
155
+ assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
156
+ assert_file_exists("#{@apptmp}/sample_project/models/user.rb")
157
+ assert_no_match_in_file(/Account/, "#{@apptmp}/sample_project/models/user.rb")
158
+ assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
159
+ assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
160
+ assert_no_match_in_file(/[^_]account/i, "#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
161
+ assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
162
+ assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
163
+ assert_match_in_file 'role.project_module :users, \'/users\'', "#{@apptmp}/sample_project/admin/app.rb"
164
+ assert_match_in_file 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.slim"
165
+ end
166
+
128
167
  should 'correctly generate a new padrino admin application with model in non-default application path' do
129
168
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
130
169
  capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
metadata CHANGED
@@ -1,10 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: padrino-admin
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.7
4
5
  prerelease:
5
- version: 0.10.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Padrino Team
9
9
  - Nathan Esquenazi
10
10
  - Davide D'Agostino
@@ -12,40 +12,47 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
-
16
- date: 2012-03-15 00:00:00 Z
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
15
+ date: 2012-06-20 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
19
18
  name: padrino-core
20
- prerelease: false
21
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
22
20
  none: false
23
- requirements:
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- version: 0.10.6
21
+ requirements:
22
+ - - '='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.10.7
27
25
  type: :runtime
28
- version_requirements: *id001
29
- - !ruby/object:Gem::Dependency
30
- name: padrino-helpers
31
26
  prerelease: false
32
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.10.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: padrino-helpers
35
+ requirement: !ruby/object:Gem::Requirement
33
36
  none: false
34
- requirements:
35
- - - "="
36
- - !ruby/object:Gem::Version
37
- version: 0.10.6
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.7
38
41
  type: :runtime
39
- version_requirements: *id002
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 0.10.7
40
49
  description: Admin View for Padrino applications
41
50
  email: padrinorb@gmail.com
42
51
  executables: []
43
-
44
52
  extensions: []
45
-
46
- extra_rdoc_files:
53
+ extra_rdoc_files:
47
54
  - README.rdoc
48
- files:
55
+ files:
49
56
  - .document
50
57
  - .gitignore
51
58
  - .yardopts
@@ -123,7 +130,9 @@ files:
123
130
  - lib/padrino-admin/locale/admin/no.yml
124
131
  - lib/padrino-admin/locale/admin/pl.yml
125
132
  - lib/padrino-admin/locale/admin/pt_br.yml
133
+ - lib/padrino-admin/locale/admin/ro.yml
126
134
  - lib/padrino-admin/locale/admin/ru.yml
135
+ - lib/padrino-admin/locale/admin/sv.yml
127
136
  - lib/padrino-admin/locale/admin/tr.yml
128
137
  - lib/padrino-admin/locale/admin/uk.yml
129
138
  - lib/padrino-admin/locale/admin/zh_cn.yml
@@ -142,7 +151,9 @@ files:
142
151
  - lib/padrino-admin/locale/orm/no.yml
143
152
  - lib/padrino-admin/locale/orm/pl.yml
144
153
  - lib/padrino-admin/locale/orm/pt_br.yml
154
+ - lib/padrino-admin/locale/orm/ro.yml
145
155
  - lib/padrino-admin/locale/orm/ru.yml
156
+ - lib/padrino-admin/locale/orm/sv.yml
146
157
  - lib/padrino-admin/locale/orm/tr.yml
147
158
  - lib/padrino-admin/locale/orm/uk.yml
148
159
  - lib/padrino-admin/locale/orm/zh_cn.yml
@@ -158,32 +169,30 @@ files:
158
169
  - test/test_locale.rb
159
170
  homepage: http://www.padrinorb.com
160
171
  licenses: []
161
-
162
172
  post_install_message:
163
- rdoc_options:
173
+ rdoc_options:
164
174
  - --charset=UTF-8
165
- require_paths:
175
+ require_paths:
166
176
  - lib
167
- required_ruby_version: !ruby/object:Gem::Requirement
177
+ required_ruby_version: !ruby/object:Gem::Requirement
168
178
  none: false
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: "0"
173
- required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
184
  none: false
175
- requirements:
176
- - - ">="
177
- - !ruby/object:Gem::Version
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
178
188
  version: 1.3.6
179
189
  requirements: []
180
-
181
190
  rubyforge_project: padrino-admin
182
- rubygems_version: 1.8.19
191
+ rubygems_version: 1.8.21
183
192
  signing_key:
184
193
  specification_version: 3
185
194
  summary: Admin Dashboard for Padrino
186
- test_files:
195
+ test_files:
187
196
  - test/fixtures/data_mapper.rb
188
197
  - test/generators/test_account_model_generator.rb
189
198
  - test/generators/test_admin_app_generator.rb
@@ -191,3 +200,4 @@ test_files:
191
200
  - test/helper.rb
192
201
  - test/test_admin_application.rb
193
202
  - test/test_locale.rb
203
+ has_rdoc: