padrino-admin 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/README.rdoc +3 -3
  2. data/Rakefile +2 -2
  3. data/VERSION +1 -1
  4. data/lib/padrino-admin.rb +6 -6
  5. data/lib/padrino-admin/access_control.rb +23 -15
  6. data/lib/padrino-admin/generators/actions.rb +4 -12
  7. data/lib/padrino-admin/generators/admin_page.rb +3 -4
  8. data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +2 -2
  9. data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +2 -2
  10. data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +2 -2
  11. data/lib/padrino-admin/generators/templates/account/mongomapper.rb.tt +2 -2
  12. data/lib/padrino-admin/generators/templates/account/seeds.rb.tt +2 -2
  13. data/lib/padrino-admin/generators/templates/app/app.rb +2 -2
  14. data/lib/padrino-admin/generators/templates/app/controllers/base.rb +0 -1
  15. data/lib/padrino-admin/generators/templates/erb/app/base/index.erb.tt +1 -1
  16. data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +2 -2
  17. data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +4 -4
  18. data/lib/padrino-admin/generators/templates/haml/app/base/_sidebar.haml.tt +1 -1
  19. data/lib/padrino-admin/generators/templates/haml/app/base/index.haml.tt +4 -4
  20. data/lib/padrino-admin/generators/templates/haml/app/layouts/application.haml.tt +1 -1
  21. data/lib/padrino-admin/generators/templates/haml/page/index.haml.tt +1 -1
  22. data/lib/padrino-admin/helpers/authentication_helpers.rb +12 -12
  23. data/lib/padrino-admin/helpers/view_helpers.rb +10 -10
  24. data/lib/padrino-admin/locale/orm/de.yml +1 -1
  25. data/lib/padrino-admin/utils/crypt.rb +11 -6
  26. data/padrino-admin.gemspec +11 -11
  27. data/test/fixtures/data_mapper.rb +4 -4
  28. data/test/generators/test_admin_app_generator.rb +1 -1
  29. data/test/generators/test_admin_page_generator.rb +1 -1
  30. data/test/helper.rb +3 -4
  31. metadata +9 -9
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ Access Control:: Supports authentication and role permissions for your applicati
12
12
 
13
13
  === Admin Dashboard Usage
14
14
 
15
- For a complete look at usage of the Admin dashboard functionality, be sure to check out the
15
+ For a complete look at usage of the Admin dashboard functionality, be sure to check out the
16
16
  {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
17
17
 
18
18
  Create a new project:
@@ -38,7 +38,7 @@ To create a new "scaffold" you need to provide only a Model name to the command:
38
38
  demo$ padrino-gen rake dm:auto:migrate
39
39
  demo$ padrino-gen admin_page post
40
40
  demo$ padrino start # and go to http://localhost:3000/admin
41
-
41
+
42
42
  That's all!!
43
43
 
44
44
  === Admin Access Control
@@ -62,7 +62,7 @@ by the admin access control features:
62
62
  In this example +if+ we visit urls that start with /+customer+/+orders+ or /+cart/checkout+ we will be redirected
63
63
  to our :+login_page+ "/login". Once we are correctly logged in we can visit these pages.
64
64
 
65
- For a more complete look at using the Admin panel functionality and access features, be sure to check out the
65
+ For a more complete look at using the Admin panel functionality and access features, be sure to check out the
66
66
  {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
67
67
 
68
68
  == Copyright
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ end
33
33
  require 'rake/testtask'
34
34
  Rake::TestTask.new(:test) do |test|
35
35
  test.libs << 'test'
36
-
36
+
37
37
  test.pattern = 'test/**/test_*.rb'
38
38
  test.verbose = true
39
39
  end
@@ -67,7 +67,7 @@ Rake::RDocTask.new do |rdoc|
67
67
  end
68
68
 
69
69
 
70
- spec = Gem::Specification.new do |s|
70
+ spec = Gem::Specification.new do |s|
71
71
  s.name = "foo"
72
72
  s.version = "1.0.1"
73
73
  s.author = "Davide D'Agostino"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.6
1
+ 0.9.7
data/lib/padrino-admin.rb CHANGED
@@ -8,31 +8,31 @@ Dir[File.dirname(__FILE__) + '/padrino-admin/{helpers,utils}/*.rb'].each { |file
8
8
  module Padrino
9
9
  ##
10
10
  # Padrino::Admin is beautiful Ajax Admin, with these fatures:
11
- #
11
+ #
12
12
  # Orm Agnostic:: Adapters for datamapper, activerecord, mongomapper, couchdb (now only: datamapper and activerecord)
13
13
  # Authentication:: Support for Account authentication, Account Permission managment
14
14
  # Scaffold:: You can simply create a new "admin interface" simply providing a Model
15
15
  # Ajax Uploads:: You can upload file, manage them and attach them to any model in a quick and simple way (coming soon)
16
- #
16
+ #
17
17
  module Admin; end
18
18
  end
19
19
 
20
20
  ##
21
21
  # We need to apply Padrino::Admin::Utils::Extensions
22
- #
22
+ #
23
23
  String.send(:include, Padrino::Admin::Utils::Crypt)
24
24
 
25
25
  ##
26
26
  # We need to add to Padrino::Application a +access_control+ class
27
- #
27
+ #
28
28
  Padrino::Application.extend(Padrino::Admin::AccessControl::ClassMethods)
29
29
 
30
30
  ##
31
31
  # Load our Padrino::Admin locales
32
- #
32
+ #
33
33
  I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-admin/locale/**/*.yml"]
34
34
 
35
35
  ##
36
36
  # Now we need to add admin generators to padrino-gen
37
- #
37
+ #
38
38
  Padrino::Generators.load_paths << Dir[File.dirname(__FILE__) + '/padrino-admin/generators/{actions,orm,admin_app,admin_page}.rb']
@@ -8,7 +8,7 @@ module Padrino
8
8
  module AccessControl
9
9
  ##
10
10
  # Method used by Padrino::Application when we register the extension
11
- #
11
+ #
12
12
  def self.registered(app)
13
13
  app.set :session_id, "_padrino_#{File.basename(Padrino.root)}_#{app.app_name}".to_sym
14
14
  app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
@@ -18,9 +18,17 @@ module Padrino
18
18
 
19
19
  module ClassMethods #:nodoc:
20
20
  def inherited(base)
21
- base.send(:cattr_accessor, :access_control)
22
- base.send(:access_control=, Padrino::Admin::AccessControl::Base.new)
21
+ unless base.respond_to?(:access_control)
22
+ base.send(:cattr_accessor, :access_control)
23
+ base.send(:access_control=, Padrino::Admin::AccessControl::Base.new)
24
+ end
23
25
  super(base)
26
+ base.class_eval { class << self; alias_method_chain :reload!, :access_control; end }
27
+ end
28
+
29
+ def reload_with_access_control!
30
+ self.access_control = Padrino::Admin::AccessControl::Base.new
31
+ reload_without_access_control!
24
32
  end
25
33
  end
26
34
 
@@ -30,7 +38,7 @@ module Padrino
30
38
  end
31
39
  ##
32
40
  # We map project modules for a given role or roles
33
- #
41
+ #
34
42
  def roles_for(*roles, &block)
35
43
  raise Padrino::Admin::AccessControlError, "You must define an Account Model!" unless defined?(Account)
36
44
  raise Padrino::Admin::AccessControlError, "Role #{role} must be present and must be a symbol!" if roles.any? { |r| !r.kind_of?(Symbol) } || roles.empty?
@@ -42,14 +50,14 @@ module Padrino
42
50
 
43
51
  ##
44
52
  # Return an array of roles
45
- #
53
+ #
46
54
  def roles
47
55
  @roles.uniq.reject { |r| r == :any }
48
56
  end
49
57
 
50
58
  ##
51
59
  # Return an array of project_modules
52
- #
60
+ #
53
61
  def project_modules(account)
54
62
  role = account.role.to_sym rescue :any
55
63
  authorizations = @authorizations.find_all { |auth| auth.roles.include?(role) }
@@ -58,7 +66,7 @@ module Padrino
58
66
 
59
67
  ##
60
68
  # Return true if the given account is allowed to see the given path.
61
- #
69
+ #
62
70
  def allowed?(account=nil, path=nil)
63
71
  path = "/" if path.blank?
64
72
  role = account.role.to_sym rescue nil
@@ -92,21 +100,21 @@ module Padrino
92
100
 
93
101
  ##
94
102
  # Allow a specified path
95
- #
103
+ #
96
104
  def allow(path)
97
105
  @allowed << path unless @allowed.include?(path)
98
106
  end
99
107
 
100
108
  ##
101
109
  # Protect access from
102
- #
110
+ #
103
111
  def protect(path)
104
112
  @denied << path unless @denied.include?(path)
105
113
  end
106
114
 
107
115
  ##
108
116
  # Create a project module
109
- #
117
+ #
110
118
  def project_module(name, path)
111
119
  allow(path)
112
120
  @project_modules << ProjectModule.new(name, path)
@@ -115,7 +123,7 @@ module Padrino
115
123
 
116
124
  ##
117
125
  # Project Module class
118
- #
126
+ #
119
127
  class ProjectModule
120
128
  attr_reader :name
121
129
 
@@ -125,21 +133,21 @@ module Padrino
125
133
 
126
134
  ##
127
135
  # Returns the name of the project module. If a symbol it translate/humanize them for you.
128
- #
136
+ #
129
137
  def human_name
130
138
  @name.is_a?(Symbol) ? I18n.t("padrino.admin.menu.#{@name}", :default => @name.to_s.humanize) : @name
131
139
  end
132
140
 
133
141
  ##
134
142
  # Return the path of the project module. If a prefix given will be prepended.
135
- #
143
+ #
136
144
  # ==== Examples
137
- #
145
+ #
138
146
  # # => /accounts/new
139
147
  # project_module.path
140
148
  # # => /admin/accounts
141
149
  # project_module.path("/admin")
142
- #
150
+ #
143
151
  def path(prefix=nil)
144
152
  prefix ? File.join(prefix, @path) : @path
145
153
  end
@@ -4,7 +4,7 @@ module Padrino
4
4
  module Actions
5
5
  ##
6
6
  # Tell us which orm we are using
7
- #
7
+ #
8
8
  def orm
9
9
  fetch_component_choice(:orm).to_sym rescue :datamapper
10
10
  end
@@ -12,26 +12,18 @@ module Padrino
12
12
 
13
13
  ##
14
14
  # Tell us for now wich orm we support
15
- #
15
+ #
16
16
  def supported_orm
17
17
  [:datamapper, :activerecord, :mongomapper, :mongoid]
18
18
  end
19
19
 
20
20
  ##
21
21
  # Add access_control permission in our app.rb
22
- #
22
+ #
23
23
  def add_project_module(controller)
24
- permission = indent(6, "role.project_module :#{controller}, \"/#{controller}\"\n")
24
+ permission = " role.project_module :#{controller}, \"/#{controller}\"\n"
25
25
  inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role, account|\n"
26
26
  end
27
-
28
- ##
29
- # Indent a content/string for the given spaces
30
- #
31
- def indent(count, content)
32
- indent = ' ' * count
33
- content.lines.map { |line| line != "\n" ? indent+line : "\n" }.join
34
- end
35
27
  end # Actions
36
28
  end # Admin
37
29
  end # Generators
@@ -44,7 +44,6 @@ module Padrino
44
44
  say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
45
45
  end
46
46
  end
47
- end
48
-
49
- end
50
- end
47
+ end # AdminPage
48
+ end # Generators
49
+ end # Padrino
@@ -17,7 +17,7 @@ class Account < ActiveRecord::Base
17
17
 
18
18
  ##
19
19
  # This method is for authentication purpose
20
- #
20
+ #
21
21
  def self.authenticate(email, password)
22
22
  account = first(:conditions => { :email => email }) if email.present?
23
23
  account && account.password_clean == password ? account : nil
@@ -25,7 +25,7 @@ class Account < ActiveRecord::Base
25
25
 
26
26
  ##
27
27
  # This method is used for retrive the original password.
28
- #
28
+ #
29
29
  def password_clean
30
30
  crypted_password.decrypt(salt)
31
31
  end
@@ -28,7 +28,7 @@ class Account
28
28
 
29
29
  ##
30
30
  # This method is for authentication purpose
31
- #
31
+ #
32
32
  def self.authenticate(email, password)
33
33
  account = first(:conditions => { :email => email }) if email.present?
34
34
  account && account.password_clean == password ? account : nil
@@ -43,7 +43,7 @@ class Account
43
43
 
44
44
  ##
45
45
  # This method is used for retrive the original password.
46
- #
46
+ #
47
47
  def password_clean
48
48
  crypted_password.decrypt(salt)
49
49
  end
@@ -26,7 +26,7 @@ class Account
26
26
 
27
27
  ##
28
28
  # This method is for authentication purpose
29
- #
29
+ #
30
30
  def self.authenticate(email, password)
31
31
  account = first(:conditions => { :email => email }) if email.present?
32
32
  account && account.password_clean == password ? account : nil
@@ -41,7 +41,7 @@ class Account
41
41
 
42
42
  ##
43
43
  # This method is used for retrive the original password.
44
- #
44
+ #
45
45
  def password_clean
46
46
  crypted_password.decrypt(salt)
47
47
  end
@@ -26,7 +26,7 @@ class Account
26
26
 
27
27
  ##
28
28
  # This method is for authentication purpose
29
- #
29
+ #
30
30
  def self.authenticate(email, password)
31
31
  account = first(:email => email) if email.present?
32
32
  account && account.password_clean == password ? account : nil
@@ -34,7 +34,7 @@ class Account
34
34
 
35
35
  ##
36
36
  # This method is used for retrive the original password.
37
- #
37
+ #
38
38
  def password_clean
39
39
  crypted_password.decrypt(salt)
40
40
  end
@@ -1,10 +1,10 @@
1
1
  # Seed add you the ability to populate your db.
2
2
  # We provide you a basic shell for interaction with the end user.
3
3
  # So try some code like below:
4
- #
4
+ #
5
5
  # name = shell.ask("What's your name?")
6
6
  # shell.say name
7
- #
7
+ #
8
8
  email = shell.ask "Which email do you want use for loggin into admin?"
9
9
  password = shell.ask "Tell me the password to use:"
10
10
 
@@ -2,7 +2,7 @@ class Admin < Padrino::Application
2
2
  configure do
3
3
  ##
4
4
  # Application-specific configuration options
5
- #
5
+ #
6
6
  # set :raise_errors, true # Show exceptions (default for development)
7
7
  # set :public, "foo/bar" # Location for static assets (default root/public)
8
8
  # set :sessions, false # Enabled by default
@@ -14,7 +14,7 @@ class Admin < Padrino::Application
14
14
  # disable :flash # Disables rack-flash (enabled by default)
15
15
  # enable :authentication # Enable padrino-admin authentication (disabled by default)
16
16
  # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
17
- #
17
+ #
18
18
  enable :authentication
19
19
  disable :store_location
20
20
  set :login_page, "/admin/sessions/new"
@@ -3,5 +3,4 @@ Admin.controllers :base do
3
3
  get :index, :map => "(/)" do
4
4
  render "base/index"
5
5
  end
6
-
7
6
  end
@@ -1,4 +1,4 @@
1
- <div class="block" id="block-text">
1
+ <div class="block" id="block-text">
2
2
  <div class="content">
3
3
  <h2 class="title">Dashboard</h2>
4
4
  <div class="inner">
@@ -22,7 +22,7 @@
22
22
  <%% end %>
23
23
  </ul>
24
24
  </div>
25
- </div>
25
+ </div>
26
26
  <div id="wrapper" class="wat-cf">
27
27
  <div class="flash">
28
28
  <%%= [:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join %>
@@ -38,7 +38,7 @@
38
38
  <div id="sidebar">
39
39
  <%%= yield_content :sidebar %>
40
40
  </div>
41
- </div>
41
+ </div>
42
42
  </div>
43
43
  </body>
44
44
  </html>
@@ -10,7 +10,7 @@
10
10
  <div id="box">
11
11
  <h1><%= options[:name] %></h1>
12
12
  <div class="block" id="block-login">
13
- <h2>Login Box</h2>
13
+ <h2>Login Box</h2>
14
14
  <div class="content login">
15
15
  <div class="flash">
16
16
  <%%= [:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join %>
@@ -22,7 +22,7 @@
22
22
  </div>
23
23
  <div class="right">
24
24
  <%%= text_field_tag :email, :value => params[:email], :class => 'text_field' %>
25
- </div>
25
+ </div>
26
26
  </div>
27
27
  <div class="group wat-cf">
28
28
  <div class="left">
@@ -30,13 +30,13 @@
30
30
  </div>
31
31
  <div class="right">
32
32
  <%%= password_field_tag :password, :value => params[:password], :class => 'text_field' %>
33
- </div>
33
+ </div>
34
34
  </div>
35
35
  <div class="group navform wat-cf">
36
36
  <div class="right">
37
37
  <%%= submit_tag "Sign in", :class => :button %>
38
38
  </div>
39
- </div>
39
+ </div>
40
40
  <%% end %>
41
41
  </div>
42
42
  </div>
@@ -2,7 +2,7 @@
2
2
  %h3 Simple Block
3
3
  .content
4
4
  %p
5
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
5
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
6
6
  Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
7
7
  .block
8
8
  %h3 Links
@@ -3,8 +3,8 @@
3
3
  %h2.title Dashboard
4
4
  .inner
5
5
  %p.first
6
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
7
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
6
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
7
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
8
8
  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
9
9
  %span.hightlight
10
10
  Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -16,8 +16,8 @@
16
16
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
17
17
  %hr
18
18
  %p
19
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
20
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
19
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
20
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
21
21
  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
22
22
  %span.hightlight
23
23
  Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -24,7 +24,7 @@
24
24
  #footer
25
25
  .block
26
26
  %p
27
- Copyright ©
27
+ Copyright ©
28
28
  =Time.now.year
29
29
  Your Site - Powered by
30
30
  =link_to "Padrino v.#{Padrino.version}", "http://padrino.github.com", :target => :_blank
@@ -20,7 +20,7 @@
20
20
  %td<%= ".first" if i==0 %>=<%= @orm.name_singular %>.<%= column.name %>
21
21
  <%- end -%>
22
22
  %td.last
23
- =button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
23
+ =button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to
24
24
  ="|"
25
25
  =button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to
26
26
  .actions-bar.wat-cf
@@ -4,25 +4,25 @@ module Padrino
4
4
  module AuthenticationHelpers
5
5
  ##
6
6
  # Returns true if +current_account+ is logged and active.
7
- #
7
+ #
8
8
  def logged_in?
9
9
  !current_account.nil?
10
10
  end
11
11
 
12
12
  ##
13
13
  # Returns the current_account, it's an instance of <tt>Account</tt> model
14
- #
14
+ #
15
15
  def current_account
16
16
  @current_account ||= login_from_session
17
17
  end
18
18
 
19
19
  ##
20
20
  # Override the current_account, you must provide an instance of Account Model
21
- #
21
+ #
22
22
  # ==== Examples:
23
- #
23
+ #
24
24
  # set_current_account(Account.authenticate(params[:email], params[:password])
25
- #
25
+ #
26
26
  def set_current_account(account=nil)
27
27
  session[options.session_id] = account ? account.id : nil
28
28
  @current_account = account
@@ -30,16 +30,16 @@ module Padrino
30
30
 
31
31
  ##
32
32
  # Returns true if the +current_account+ is allowed to see the requested path
33
- #
33
+ #
34
34
  # For configure this role please refer to: +Padrino::Admin::AccessControl::Base+
35
- #
35
+ #
36
36
  def allowed?
37
37
  access_control.allowed?(current_account, request.path_info)
38
38
  end
39
39
 
40
40
  ##
41
41
  # Returns project modules for the current account
42
- #
42
+ #
43
43
  def project_modules
44
44
  access_control.project_modules(current_account)
45
45
  end
@@ -47,9 +47,9 @@ module Padrino
47
47
  ##
48
48
  # Returns a helper useful in a +before_filter+ for check if
49
49
  # an account are: +logged_in?+ and +allowed?+
50
- #
50
+ #
51
51
  # By default this method is used in Admin Apps.
52
- #
52
+ #
53
53
  def login_required
54
54
  store_location! if store_location
55
55
  return access_denied unless allowed?
@@ -57,7 +57,7 @@ module Padrino
57
57
 
58
58
  ##
59
59
  # Store in session[:return_to] the env['HTTP_REFERER']
60
- #
60
+ #
61
61
  def store_location!
62
62
  session[:return_to] = env['HTTP_REFERER']
63
63
  end
@@ -65,7 +65,7 @@ module Padrino
65
65
  ##
66
66
  # Redirect the account to the page that requested an authentication or
67
67
  # if the account is not allowed/logged return it to a default page
68
- #
68
+ #
69
69
  def redirect_back_or_default(default)
70
70
  return_to = session.delete(:return_to)
71
71
  redirect(return_to || default)
@@ -4,15 +4,15 @@ module Padrino
4
4
  module ViewHelpers
5
5
  ##
6
6
  # Translate a given word for padrino admin
7
- #
7
+ #
8
8
  # ==== Examples
9
- #
9
+ #
10
10
  # # => t("padrino.admin.profile", :default => "Profile")
11
11
  # pat(:profile)
12
- #
12
+ #
13
13
  # # => t("padrino.admin.profile", :default => "My Profile")
14
14
  # pat(:profile, "My Profile")
15
- #
15
+ #
16
16
  def padrino_admin_translate(word, default=nil)
17
17
  t("padrino.admin.#{word}", :default => (default || word.to_s.humanize))
18
18
  end
@@ -20,12 +20,12 @@ module Padrino
20
20
 
21
21
  ##
22
22
  # Translate attribute name for the given model
23
- #
23
+ #
24
24
  # ==== Examples
25
- #
25
+ #
26
26
  # # => t("models.account.email", :default => "Email")
27
27
  # mat(:account, :email)
28
- #
28
+ #
29
29
  def model_attribute_translate(model, attribute)
30
30
  t("models.#{model}.attributes.#{attribute}", :default => attribute.to_s.humanize)
31
31
  end
@@ -33,12 +33,12 @@ module Padrino
33
33
 
34
34
  ##
35
35
  # Translate model name
36
- #
36
+ #
37
37
  # ==== Examples
38
- #
38
+ #
39
39
  # # => t("models.account.name", :default => "Account")
40
40
  # mt(:account)
41
- #
41
+ #
42
42
  def model_translate(model)
43
43
  t("models.#{model}.name", :default => model.to_s.humanize)
44
44
  end
@@ -5,7 +5,7 @@ de:
5
5
  inclusion: "ist nicht in der Liste enthalten"
6
6
  exclusion: "ist reserviert"
7
7
  invalid: "ist ung¸ltig"
8
- confirmation: "entspricht nicht der Best‰tigung"
8
+ confirmation: "entspricht nicht der Best‰tigung"
9
9
  accepted: "muss akzeptiert werden"
10
10
  empty: "Darf nicht leer sein"
11
11
  blank: "Darf nicht nur Leerzeichen sein"
@@ -3,17 +3,23 @@ require 'openssl'
3
3
  module Padrino
4
4
  module Admin
5
5
  module Utils
6
+ ##
6
7
  # This util it's used for encrypt/decrypt password.
7
8
  # We want password decryptable because generally for our sites we have: password_lost.
8
9
  # We prefer send original password instead reset them.
10
+ #
9
11
  module Crypt
10
- # Decrypts the current string using the current key and algorithm specified
12
+ ##
13
+ # Decrypts the current string using the current key specified
14
+ #
11
15
  def decrypt(password)
12
16
  cipher = build_cipher(:decrypt, password)
13
17
  cipher.update(self.unpack('m')[0]) + cipher.final
14
18
  end
15
19
 
20
+ ##
16
21
  # Encrypts the current string using the current key and algorithm specified
22
+ #
17
23
  def encrypt(password)
18
24
  cipher = build_cipher(:encrypt, password)
19
25
  [cipher.update(self) + cipher.final].pack('m').chomp
@@ -25,8 +31,7 @@ module Padrino
25
31
  cipher.pkcs5_keyivgen(password)
26
32
  cipher
27
33
  end
28
- end
29
-
30
- end
31
- end
32
- end
34
+ end # Crypt
35
+ end # Utils
36
+ end # Admin
37
+ end # Padrino
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-admin}
8
- s.version = "0.9.6"
8
+ s.version = "0.9.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-03-15}
12
+ s.date = %q{2010-03-22}
13
13
  s.description = %q{Admin View for Padrino applications}
14
14
  s.email = %q{padrinorb@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -94,18 +94,18 @@ Gem::Specification.new do |s|
94
94
  s.specification_version = 3
95
95
 
96
96
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
97
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.6"])
98
- s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.6"])
99
- s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.6"])
97
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.7"])
98
+ s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.7"])
99
+ s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.7"])
100
100
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
101
101
  s.add_development_dependency(%q<shoulda>, [">= 0"])
102
102
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
103
103
  s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
104
104
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
105
105
  else
106
- s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
107
- s.add_dependency(%q<padrino-gen>, ["= 0.9.6"])
108
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.6"])
106
+ s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
107
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.7"])
108
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.7"])
109
109
  s.add_dependency(%q<haml>, [">= 2.2.1"])
110
110
  s.add_dependency(%q<shoulda>, [">= 0"])
111
111
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -113,9 +113,9 @@ Gem::Specification.new do |s|
113
113
  s.add_dependency(%q<webrat>, [">= 0.5.1"])
114
114
  end
115
115
  else
116
- s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
117
- s.add_dependency(%q<padrino-gen>, ["= 0.9.6"])
118
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.6"])
116
+ s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
117
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.7"])
118
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.7"])
119
119
  s.add_dependency(%q<haml>, [">= 2.2.1"])
120
120
  s.add_dependency(%q<shoulda>, [">= 0"])
121
121
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -47,7 +47,7 @@ class Account
47
47
 
48
48
  ##
49
49
  # This method it's for authentication purpose
50
- #
50
+ #
51
51
  def self.authenticate(email, password)
52
52
  account = first(:conditions => { :email => email }) if email.present?
53
53
  account && account.password_clean == password ? account : nil
@@ -62,7 +62,7 @@ class Account
62
62
 
63
63
  ##
64
64
  # This method it's used for retrive the original password.
65
- #
65
+ #
66
66
  def password_clean
67
67
  crypted_password.decrypt(salt)
68
68
  end
@@ -82,12 +82,12 @@ end
82
82
  DataMapper.auto_migrate!
83
83
 
84
84
  # We build some fake accounts
85
- admin = Account.create(:name => "DAddYE", :role => "admin", :email => "d.dagostino@lipsiasoft.com",
85
+ admin = Account.create(:name => "DAddYE", :role => "admin", :email => "d.dagostino@lipsiasoft.com",
86
86
  :password => "some", :password_confirmation => "some")
87
87
  editor = Account.create(:name => "Dexter", :role => "editor", :email => "editor@lipsiasoft.com",
88
88
  :password => "some", :password_confirmation => "some")
89
89
 
90
- %w(News Press HowTo).each do |c|
90
+ %w(News Press HowTo).each do |c|
91
91
  admin.categories.create(:name => c)
92
92
  editor.categories.create(:name => c)
93
93
  end
@@ -5,7 +5,7 @@ require 'padrino-gen/generators/actions'
5
5
  Dir[File.dirname(__FILE__) + '/generators/{components}/**/*.rb'].each { |lib| require lib }
6
6
 
7
7
  class TestAdminAppGenerator < Test::Unit::TestCase
8
-
8
+
9
9
  def setup
10
10
  `rm -rf /tmp/sample_project`
11
11
  @project = Padrino::Generators::Project.dup
@@ -21,7 +21,7 @@ class TestAdminPageGenerator < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  context 'the admin page generator' do
24
-
24
+
25
25
  should 'fail outside app root' do
26
26
  output = silence_logger { @page.start(['foo', '-r=/tmp/sample_project']) }
27
27
  assert_match(/not at the root/, output)
data/test/helper.rb CHANGED
@@ -9,13 +9,12 @@ require 'shoulda'
9
9
  require 'thor/group'
10
10
 
11
11
  # We try to load the vendored padrino-core if exist
12
- %w(core gen helpers).each do |gem|
13
- if File.exist?(File.dirname(__FILE__) + "/../../padrino-#{gem}/lib")
14
- $:.unshift File.dirname(__FILE__) + "/../../padrino-#{gem}/lib"
12
+ %w(core gen helpers).each do |lib|
13
+ if File.exist?(File.dirname(__FILE__) + "/../../padrino-#{lib}/lib")
14
+ $:.unshift File.dirname(__FILE__) + "/../../padrino-#{lib}/lib"
15
15
  end
16
16
  end
17
17
 
18
-
19
18
  require 'padrino-core/support_lite'
20
19
  require 'padrino-admin'
21
20
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 6
9
- version: 0.9.6
8
+ - 7
9
+ version: 0.9.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Padrino Team
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-15 00:00:00 -07:00
20
+ date: 2010-03-22 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -30,8 +30,8 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  - 9
33
- - 6
34
- version: 0.9.6
33
+ - 7
34
+ version: 0.9.7
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -44,8 +44,8 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  - 9
47
- - 6
48
- version: 0.9.6
47
+ - 7
48
+ version: 0.9.7
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
@@ -58,8 +58,8 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  - 9
61
- - 6
62
- version: 0.9.6
61
+ - 7
62
+ version: 0.9.7
63
63
  type: :runtime
64
64
  version_requirements: *id003
65
65
  - !ruby/object:Gem::Dependency