padrino-admin 0.9.24 → 0.9.25

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
  Padrino has a beautiful Admin management dashboard with these features:
6
6
 
7
7
  Orm Agnostic:: Data Adapters for Datamapper, Activerecord, Sequel, Mongomapper, Mongoid, Couchrest
8
- Template Agnostic:: Erb and Haml Renderer
8
+ Template Agnostic:: Erb, Erubis and Haml Renderer
9
9
  Authentication:: Support for Account authentication, Account Permission managment
10
10
  Scaffold:: You can simply create a new "admin interface" by providing a Model
11
11
  Access Control:: Supports authentication and role permissions for your application
@@ -52,7 +52,7 @@ module Padrino
52
52
  def project_modules(account)
53
53
  role = account.role.to_sym rescue :any
54
54
  authorizations = @authorizations.find_all { |auth| auth.roles.include?(role) }
55
- authorizations.collect(&:project_modules).flatten.uniq
55
+ authorizations.map(&:project_modules).flatten.uniq
56
56
  end
57
57
 
58
58
  ##
@@ -62,15 +62,15 @@ module Padrino
62
62
  path = "/" if path.blank?
63
63
  role = account.role.to_sym rescue nil
64
64
  authorizations = @authorizations.find_all { |auth| auth.roles.include?(:any) }
65
- allowed_paths = authorizations.collect(&:allowed).flatten.uniq
66
- denied_paths = authorizations.collect(&:denied).flatten.uniq
65
+ allowed_paths = authorizations.map(&:allowed).flatten.uniq
66
+ denied_paths = authorizations.map(&:denied).flatten.uniq
67
67
  if account
68
68
  denied_paths.clear
69
69
  authorizations = @authorizations.find_all { |auth| auth.roles.include?(role) }
70
- allowed_paths += authorizations.collect(&:allowed).flatten.uniq
70
+ allowed_paths += authorizations.map(&:allowed).flatten.uniq
71
71
  authorizations = @authorizations.find_all { |auth| !auth.roles.include?(role) && !auth.roles.include?(:any) }
72
- denied_paths += authorizations.collect(&:allowed).flatten.uniq
73
- denied_paths += authorizations.collect(&:denied).flatten.uniq
72
+ denied_paths += authorizations.map(&:allowed).flatten.uniq
73
+ denied_paths += authorizations.map(&:denied).flatten.uniq
74
74
  end
75
75
  return true if allowed_paths.any? { |p| path =~ /^#{p}/ }
76
76
  return false if denied_paths.any? { |p| path =~ /^#{p}/ }
@@ -6,10 +6,17 @@ module Padrino
6
6
  # Tell us which orm we are using
7
7
  #
8
8
  def orm
9
- fetch_component_choice(:orm).to_sym rescue :datamapper
9
+ fetch_component_choice(:orm).to_sym rescue :activerecord
10
10
  end
11
11
  alias :adapter :orm
12
12
 
13
+ ##
14
+ # Tell us which rendering engine you are using
15
+ #
16
+ def ext
17
+ fetch_component_choice(:admin_renderer).to_sym rescue :haml
18
+ end
19
+
13
20
  ##
14
21
  # Tell us for now wich orm we support
15
22
  #
@@ -17,11 +24,18 @@ module Padrino
17
24
  [:datamapper, :activerecord, :mongomapper, :mongoid, :couchrest, :sequel]
18
25
  end
19
26
 
27
+ ##
28
+ # Tell us for now wich rendering engine we support
29
+ #
30
+ def supported_ext
31
+ [:haml, :erb, :slim]
32
+ end
33
+
20
34
  ##
21
35
  # Add access_control permission in our app.rb
22
36
  #
23
37
  def add_project_module(controller)
24
- permission = " role.project_module :#{controller}, \"/#{controller}\"\n"
38
+ permission = " role.project_module :#{controller}, \"/#{controller}\"\n"
25
39
  inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role|\n"
26
40
  end
27
41
  end # Actions
@@ -21,31 +21,36 @@ module Padrino
21
21
  class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean
22
22
  class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
23
23
  class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
24
- class_option :name, :desc => "The app name", :aliases => '-a', :default => "Padrino Admin", :type => :string
25
24
  class_option :theme, :desc => "Your admin theme: (#{self.themes.join(", ")})", :default => "default", :type => :string
25
+ class_option :renderer, :aliases => '-e', :desc => "Rendering engine (erb, haml)", :type => :string
26
26
 
27
27
  # Copies over the Padrino base admin application
28
28
  def create_admin
29
29
  self.destination_root = options[:root]
30
30
  if in_app_root?
31
-
32
31
  unless supported_orm.include?(orm)
33
- say "<= At the moment, Padrino only supports #{supported_orm.join(" or ")}. Sorry!"
32
+ say "<= At the moment, Padrino only supports #{supported_orm.join(" or ")}. Sorry!", :yellow
34
33
  raise SystemExit
35
34
  end
36
35
 
37
36
  unless self.class.themes.include?(options[:theme])
38
- say "<= You need to choose a theme from: #{self.class.themes.join(", ")}"
37
+ say "<= You need to choose a theme from: #{self.class.themes.join(", ")}", :yellow
39
38
  raise SystemExit
40
39
  end
41
40
 
42
- self.behavior = :revoke if options[:destroy]
41
+ tmp_ext = options[:renderer] || fetch_component_choice(:renderer)
42
+ unless supported_ext.include?(tmp_ext.to_sym)
43
+ say "<= Your are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use -e haml or -e erb or -e slim", :yellow
44
+ raise SystemExit
45
+ end
46
+ store_component_choice(:admin_renderer, tmp_ext)
43
47
 
44
- ext = fetch_component_choice(:renderer)
48
+ self.behavior = :revoke if options[:destroy]
45
49
 
46
50
  empty_directory destination_root("admin")
47
- directory "templates/app", destination_root("admin")
48
- directory "templates/assets", destination_root("public", "admin")
51
+ directory "templates/app", destination_root("admin")
52
+ directory "templates/assets", destination_root("public", "admin")
53
+ template "templates/app.rb.tt", destination_root("admin/app.rb")
49
54
 
50
55
  account_params = [
51
56
  "account", "name:string", "surname:string", "email:string", "crypted_password:string", "role:string",
@@ -56,9 +61,6 @@ module Padrino
56
61
  account_params << "-d" if options[:destroy]
57
62
 
58
63
  Padrino::Generators::Model.start(account_params)
59
- # Can't add this through model generator as it does not have /admin loaded yet
60
- # so run it and remove it and copy admin version over to admin path.
61
- remove_file destination_root('app','models','account.rb')
62
64
  column = Struct.new(:name, :type)
63
65
  columns = [:id, :name, :surname, :email].map { |col| column.new(col) }
64
66
  column_fields = [
@@ -74,12 +76,12 @@ module Padrino
74
76
  admin_app.default_orm = Padrino::Admin::Generators::Orm.new(:account, orm, columns, column_fields)
75
77
  admin_app.invoke_all
76
78
 
77
- template "templates/account/#{orm}.rb.tt", destination_root("admin", "models", "account.rb"), :force => true
79
+ template "templates/account/#{orm}.rb.tt", destination_root("app", "models", "account.rb"), :force => true
78
80
 
79
81
  if File.exist?(destination_root("db/seeds.rb"))
80
82
  append_file(destination_root("db/seeds.rb")) { "\n\n" + File.read(self.class.source_root+"/templates/account/seeds.rb.tt") }
81
83
  else
82
- template "templates/account/seeds.rb.tt", destination_root("db/seeds.rb")
84
+ template "templates/account/seeds.rb.tt", destination_root("db/seeds.rb")
83
85
  end
84
86
 
85
87
  empty_directory destination_root("admin/controllers")
@@ -32,8 +32,6 @@ module Padrino
32
32
  models.each do |model|
33
33
  @orm = default_orm || Padrino::Admin::Generators::Orm.new(model, adapter)
34
34
  self.behavior = :revoke if options[:destroy]
35
- ext = fetch_component_choice(:renderer)
36
-
37
35
  empty_directory destination_root("/admin/views/#{@orm.name_plural}")
38
36
 
39
37
  template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb")
@@ -6,16 +6,17 @@ class Admin < Padrino::Application
6
6
  ##
7
7
  # Application configuration options
8
8
  #
9
- # set :raise_errors, true # Show exceptions (default for development)
9
+ # set :raise_errors, true # Raise exceptions (will stop application) (default true for development)
10
+ # set :show_exceptions, true # Show a stack trace in browser (default is true)
10
11
  # set :public, "foo/bar" # Location for static assets (default root/public)
11
12
  # set :reload, false # Reload application files (default in development)
12
13
  # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
13
14
  # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
14
- # enable :sessions # Disabled by default
15
+ # disable :sessions # Enabled by default
15
16
  # disable :flash # Disables rack-flash (enabled by default if sessions)
16
17
  # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
17
18
  #
18
-
19
+ set :session_secret, "<%= '%x' % rand(2**255) %>"
19
20
  set :login_page, "/admin/sessions/new"
20
21
  disable :store_location
21
22
 
@@ -18,7 +18,7 @@ Admin.controllers :sessions do
18
18
  end
19
19
  end
20
20
 
21
- get :destroy do
21
+ delete :destroy do
22
22
  set_current_account(nil)
23
23
  redirect url(:sessions, :new)
24
24
  end
@@ -56,7 +56,7 @@ body{font-size:12px;font-family:sans-serif;}
56
56
  .table{width:100%;border-collapse:collapse;margin-bottom:15px;}
57
57
  .table th{padding:10px;font-weight:bold;text-align:left;}
58
58
  /*.table th.first{width:30px;}*/
59
- /*.table th.last{width:200px;}*/
59
+ .table th.last{width:80px;}
60
60
  .table .checkbox{margin-left:10px;}
61
61
  .table td{padding:10px;}
62
62
  .table td.last{text-align:right;}
@@ -77,7 +77,8 @@ input.check_box{margin:0;padding:0;}
77
77
  .form a{color:red;font-size:14px;}
78
78
  .form input.text_field,.form input.password_field,.form textarea.text_area{width:100%;border-width:1px;border-style:solid;}
79
79
  .button_to{display:inline;}
80
- .button_to input{background:none;border:none;display:inline;font-size:12px;color:#A72D2E;cursor:pointer;}
80
+ .button_to input{background:none;border:none;display:inline;font-size:12px;color:#A72D2E;cursor:pointer;font-family: helvetica, arial, sans-serif;}
81
+ #user-navigation .button_to input{color:#FFFFFF;}
81
82
  /* lists */
82
83
  ul.list{margin:0;padding:0;list-style-type:none;}
83
84
  ul.list li{clear:left;padding-bottom:5px;}
@@ -2,17 +2,17 @@
2
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <title><%= options[:name] %></title>
5
+ <title>Padrino Admin</title>
6
6
  <%%= stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style" %>
7
7
  </head>
8
8
  <body>
9
9
  <div id="container">
10
10
  <div id="header">
11
- <h1><%%= link_to "<%= options[:name] %>", url(:base_index) %></h1>
11
+ <h1><%%= link_to "Padrino Admin", url(:base_index) %></h1>
12
12
  <div id="user-navigation">
13
13
  <ul class="wat-cf">
14
14
  <li><%%= link_to pat(:profile), url(:accounts, :edit, :id => current_account.id) %></li>
15
- <li><%%= link_to pat(:logout), url(:sessions, :destroy), :method => :delete %></li>
15
+ <li><%%= button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to %></li>
16
16
  </ul>
17
17
  </div>
18
18
  <div id="main-navigation">
@@ -2,13 +2,13 @@
2
2
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <title><%= options[:name] %></title>
5
+ <title>Padrino Admin</title>
6
6
  <%%= stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style" %>
7
7
  </head>
8
8
  <body>
9
9
  <div id="container">
10
10
  <div id="box">
11
- <h1><%= options[:name] %></h1>
11
+ <h1>Padrino Admin</h1>
12
12
  <div class="block" id="block-login">
13
13
  <h2>Login Box</h2>
14
14
  <div class="content login">
@@ -22,7 +22,7 @@
22
22
  <%- end -%>
23
23
  <td class="last">
24
24
  <%%= button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to %> |
25
- <%%= button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to %>
25
+ <%%= button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')" %>
26
26
  </td>
27
27
  </tr>
28
28
  <%% end %>
@@ -2,16 +2,16 @@
2
2
  %html{:lang => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
3
3
  %head
4
4
  %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
5
- %title <%= options[:name] %>
5
+ %title Padrino Admin
6
6
  =stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
7
7
  %body
8
8
  #container
9
9
  #header
10
- %h1=link_to "<%= options[:name] %>", url(:base_index)
10
+ %h1=link_to "Padrino Admin", url(:base_index)
11
11
  #user-navigation
12
12
  %ul.wat-cf
13
13
  %li=link_to pat(:profile), url(:accounts, :edit, :id => current_account.id)
14
- %li=link_to pat(:logout), url(:sessions, :destroy), :method => :delete
14
+ %li=button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => :button_to
15
15
  #main-navigation
16
16
  %ul.wat-cf
17
17
  -project_modules.each do |project_module|
@@ -2,12 +2,12 @@
2
2
  %html{:lang => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
3
3
  %head
4
4
  %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
5
- %title <%= options[:name] %>
5
+ %title Padrino Admin
6
6
  =stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
7
7
  %body
8
8
  #container
9
9
  #box
10
- %h1 <%= options[:name] %>
10
+ %h1 Padrino Admin
11
11
  #block-login.block
12
12
  %h2 Login Box
13
13
  .content.login
@@ -2,7 +2,7 @@
2
2
  .group
3
3
  =f.label :<%= column[:name] %>
4
4
  =f.error_message_on :<%= column[:name] %>
5
- =f.<%= column[:field_type] %> :<%= column[:name] %>, :class => :<%= column[:field_type] %>
5
+ <% if column[:field_type] == :text_area %>~<% else %>=<% end %>f.<%= column[:field_type] %> :<%= column[:name] %>, :class => :<%= column[:field_type] %>
6
6
  %span.description Ex: a simple text
7
7
 
8
8
  <%- end -%>
@@ -22,7 +22,7 @@
22
22
  %td.last
23
23
  =button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
24
24
  ="|"
25
- =button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to
25
+ =button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')"
26
26
  .actions-bar.wat-cf
27
27
  .actions="&nbsp;"
28
28
 
@@ -2,13 +2,13 @@
2
2
  html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
3
  head
4
4
  meta content="text/html; charset=utf-8" http-equiv="Content-Type"
5
- title <%= options[:name] %>
5
+ title Padrino Admin
6
6
  ==stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
7
7
 
8
8
  body
9
9
  #container
10
10
  #header
11
- h1==link_to "<%= options[:name] %>", url(:base_index)
11
+ h1==link_to "Padrino Admin", url(:base_index)
12
12
  #user-navigation
13
13
  ul.wat-cf
14
14
  li==link_to pat(:profile), url(:accounts, :edit, :id => current_account.id)
@@ -2,13 +2,13 @@
2
2
  html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
3
  head
4
4
  meta content="text/html; charset=utf-8" http-equiv="Content-Type"
5
- title <%= options[:name] %>
5
+ title Padrino Admin
6
6
  ==stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
7
7
 
8
8
  body
9
9
  #container
10
10
  #box
11
- h1 <%= options[:name] %>
11
+ h1 Padrino Admin
12
12
  #block-login.block
13
13
  h2 Login Box
14
14
  .content.login
@@ -23,7 +23,7 @@
23
23
  td.last
24
24
  ==button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
25
25
  ==" | "
26
- ==button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to
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
28
  .actions=="&nbsp;"
29
29
 
@@ -52,12 +52,13 @@ class TestAdminAppGenerator < Test::Unit::TestCase
52
52
  assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.haml")
53
53
  assert_file_exists("#{@apptmp}/sample_project/public/admin")
54
54
  assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
55
- assert_file_exists("#{@apptmp}/sample_project/admin/models/account.rb")
55
+ assert_file_exists("#{@apptmp}/sample_project/app/models/account.rb")
56
56
  assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
57
57
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_accounts.rb")
58
58
  assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
59
59
  assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
60
60
  assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
61
+ assert_match_in_file 'set :session_secret, "', "#{@apptmp}/sample_project/admin/app.rb"
61
62
  end
62
63
 
63
64
  should 'correctly generate a new padrino admin application with erb renderer' do
@@ -83,12 +84,45 @@ class TestAdminAppGenerator < Test::Unit::TestCase
83
84
  assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.erb")
84
85
  assert_file_exists("#{@apptmp}/sample_project/public/admin")
85
86
  assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
86
- assert_file_exists("#{@apptmp}/sample_project/admin/models/account.rb")
87
+ assert_file_exists("#{@apptmp}/sample_project/app/models/account.rb")
87
88
  assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
88
89
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_accounts.rb")
89
90
  assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
90
91
  assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
91
92
  assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
93
+ assert_match_in_file 'set :session_secret, "', "#{@apptmp}/sample_project/admin/app.rb"
94
+ end
95
+
96
+ should 'correctly generate a new padrino admin application with slim renderer' do
97
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=slim') } }
98
+ assert_nothing_raised { silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") } }
99
+ assert_file_exists("#{@apptmp}/sample_project")
100
+ assert_file_exists("#{@apptmp}/sample_project/admin")
101
+ assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
102
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers")
103
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/accounts.rb")
104
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/base.rb")
105
+ assert_file_exists("#{@apptmp}/sample_project/admin/controllers/sessions.rb")
106
+ assert_file_exists("#{@apptmp}/sample_project/admin/views")
107
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/_form.slim")
108
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/edit.slim")
109
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/index.slim")
110
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/new.slim")
111
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.slim")
112
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.slim")
113
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/_sidebar.slim")
114
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.slim")
115
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/layouts/application.slim")
116
+ assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.slim")
117
+ assert_file_exists("#{@apptmp}/sample_project/public/admin")
118
+ assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
119
+ assert_file_exists("#{@apptmp}/sample_project/app/models/account.rb")
120
+ assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
121
+ assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_accounts.rb")
122
+ assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
123
+ assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
124
+ assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
125
+ assert_match_in_file 'set :session_secret, "', "#{@apptmp}/sample_project/admin/app.rb"
92
126
  end
93
127
 
94
128
  should 'not conflict with existing seeds file' do
@@ -75,6 +75,25 @@ class TestAdminPageGenerator < Test::Unit::TestCase
75
75
  assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.erb"
76
76
  end
77
77
 
78
+ should 'correctly generate a new padrino admin application with slim renderer' do
79
+ silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '-e=slim') }
80
+ silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
81
+ silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
82
+ silence_logger { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
83
+ assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
84
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.slim"
85
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.slim"
86
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.slim"
87
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.slim"
88
+ %w(name age email).each do |field|
89
+ assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.slim"
90
+ assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.slim"
91
+ end
92
+ assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
93
+ assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
94
+ assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.slim"
95
+ end
96
+
78
97
  should 'correctly generate a new padrino admin application with multiple models' do
79
98
  silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
80
99
  silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
@@ -220,11 +220,11 @@ class TestAdminApplication < Test::Unit::TestCase
220
220
  end
221
221
 
222
222
  get "/modules" do
223
- project_modules.collect { |pm| "#{pm.name} => #{pm.path}" }.join(", ")
223
+ project_modules.map { |pm| "#{pm.name} => #{pm.path}" }.join(", ")
224
224
  end
225
225
 
226
226
  get "/modules-prefixed" do
227
- project_modules.collect { |pm| "#{pm.name} => #{pm.path("/admin")}" }.join(", ")
227
+ project_modules.map { |pm| "#{pm.name} => #{pm.path("/admin")}" }.join(", ")
228
228
  end
229
229
  end
230
230
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-admin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 24
10
- version: 0.9.24
9
+ - 25
10
+ version: 0.9.25
11
11
  platform: ruby
12
12
  authors:
13
13
  - Padrino Team
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-04-28 00:00:00 +02:00
21
+ date: 2011-04-27 00:00:00 +02:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -29,12 +29,12 @@ dependencies:
29
29
  requirements:
30
30
  - - "="
31
31
  - !ruby/object:Gem::Version
32
- hash: 11
32
+ hash: 9
33
33
  segments:
34
34
  - 0
35
35
  - 9
36
- - 24
37
- version: 0.9.24
36
+ - 25
37
+ version: 0.9.25
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
40
  - !ruby/object:Gem::Dependency
@@ -45,12 +45,12 @@ dependencies:
45
45
  requirements:
46
46
  - - "="
47
47
  - !ruby/object:Gem::Version
48
- hash: 11
48
+ hash: 9
49
49
  segments:
50
50
  - 0
51
51
  - 9
52
- - 24
53
- version: 0.9.24
52
+ - 25
53
+ version: 0.9.25
54
54
  type: :runtime
55
55
  version_requirements: *id002
56
56
  description: Admin View for Padrino applications
@@ -80,9 +80,9 @@ files:
80
80
  - lib/padrino-admin/generators/templates/account/mongomapper.rb.tt
81
81
  - lib/padrino-admin/generators/templates/account/seeds.rb.tt
82
82
  - lib/padrino-admin/generators/templates/account/sequel.rb.tt
83
- - lib/padrino-admin/generators/templates/app/app.rb
84
83
  - lib/padrino-admin/generators/templates/app/controllers/base.rb
85
84
  - lib/padrino-admin/generators/templates/app/controllers/sessions.rb
85
+ - lib/padrino-admin/generators/templates/app.rb.tt
86
86
  - lib/padrino-admin/generators/templates/assets/stylesheets/base.css
87
87
  - lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css
88
88
  - lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css