padrino-admin 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Padrino has a beautiful Admin management dashboard with these features:
6
6
 
7
- Orm Agnostic:: Data Adapters for Datamapper, Activerecord, Mongomapper, Mongoid
7
+ Orm Agnostic:: Data Adapters for Datamapper, Activerecord, Sequel, Mongomapper, Mongoid, Couchrest
8
8
  Template Agnostic:: Erb 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
@@ -13,7 +13,7 @@ Access Control:: Supports authentication and role permissions for your applicati
13
13
  === Admin Dashboard Usage
14
14
 
15
15
  For a complete look at usage of the Admin dashboard functionality, be sure to check out the
16
- {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
16
+ {Padrino Admin}[http://www.padrinorb.com/guides/padrino-admin] guide.
17
17
 
18
18
  Create a new project:
19
19
 
@@ -63,7 +63,7 @@ In this example +if+ we visit urls that start with /+customer+/+orders+ or /+car
63
63
  to our :+login_page+ "/login". Once we are correctly logged in we can visit these pages.
64
64
 
65
65
  For a more complete look at using the Admin panel functionality and access features, be sure to check out the
66
- {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
66
+ {Padrino Admin}[http://www.padrinorb.com/guides/padrino-admin] guide.
67
67
 
68
68
  == Copyright
69
69
 
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
-
4
- GEM_VERSION = File.read(File.dirname(__FILE__) + '/VERSION')
3
+ require File.expand_path("../../padrino-core/lib/padrino-core/version.rb", __FILE__)
5
4
 
6
5
  begin
7
6
  require 'jeweler'
@@ -13,9 +12,10 @@ begin
13
12
  gem.homepage = "http://github.com/padrino/padrino-framework/tree/master/padrino-admin"
14
13
  gem.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
15
14
  gem.rubyforge_project = 'padrino-admin'
16
- gem.add_runtime_dependency "padrino-core", "= #{GEM_VERSION}"
17
- gem.add_runtime_dependency "padrino-gen", "= #{GEM_VERSION}"
18
- gem.add_runtime_dependency "padrino-helpers", "= #{GEM_VERSION}"
15
+ gem.version = Padrino.version
16
+ gem.add_runtime_dependency "padrino-core", "= #{Padrino.version}"
17
+ gem.add_runtime_dependency "padrino-gen", "= #{Padrino.version}"
18
+ gem.add_runtime_dependency "padrino-helpers", "= #{Padrino.version}"
19
19
  gem.add_development_dependency "haml", ">= 2.2.1"
20
20
  gem.add_development_dependency "shoulda", ">= 0"
21
21
  gem.add_development_dependency "mocha", ">= 0.9.7"
@@ -51,33 +51,4 @@ rescue LoadError
51
51
  end
52
52
  end
53
53
 
54
- # task :test => :check_dependencies
55
-
56
- task :default => :test
57
-
58
- require 'rake/rdoctask'
59
- Rake::RDocTask.new do |rdoc|
60
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
61
-
62
- rdoc.rdoc_dir = 'rdoc'
63
- rdoc.title = "padrino-admin #{version}"
64
- rdoc.rdoc_files.include('README*')
65
- rdoc.rdoc_files.include('lib/**/*.rb')
66
- end
67
-
68
-
69
- spec = Gem::Specification.new do |s|
70
- s.name = "foo"
71
- s.version = "1.0.1"
72
- s.author = "Davide D'Agostino"
73
- s.email = "d.dagostino@lipsiasoft.com"
74
- s.homepage = "http://www.lipsiadmin.com"
75
- s.rubyforge_project = "lipsiadmin"
76
- s.platform = Gem::Platform::RUBY
77
- s.summary = "Lipsiadmin is a new revolutionary admin for your projects.Lipsiadmin is based on Ext Js 2.0. framework (with prototype adapter) and is ready for Rails 2.0. This admin is for newbie developper but also for experts, is not entirely written in javascript because the aim of developper wose build in a agile way web/site apps so we use extjs in a new intelligent way a mixin of 'old' html and new ajax functions, for example ext manage the layout of page, grids, tree and errors, but form are in html code."
78
- s.files = FileList["CHANGELOG", "README.rdoc", "MIT-LICENSE", "Rakefile", "init.rb", "{lipsiadmin_generators,lib,resources,tasks}/**/*"].to_a
79
- s.has_rdoc = true
80
- s.requirements << "ImageMagick"
81
- s.add_dependency('haml')
82
- s.add_dependency('rails', '>= 2.2.1')
83
- end
54
+ task :default => :test
@@ -11,6 +11,7 @@ module Padrino
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
+ app.enable :sessions
14
15
  app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
15
16
  app.helpers Padrino::Admin::Helpers::ViewHelpers
16
17
  app.before { login_required }
@@ -149,7 +150,9 @@ module Padrino
149
150
  # project_module.path("/admin")
150
151
  #
151
152
  def path(prefix=nil)
152
- prefix ? File.join(prefix, @path) : @path
153
+ path = prefix ? File.join(prefix, @path) : @path
154
+ path = File.join(ENV['RACK_BASE_URI'].to_s, path) if ENV['RACK_BASE_URI']
155
+ path
153
156
  end
154
157
  end # ProjectModule
155
158
  end # AccessControl
@@ -14,7 +14,7 @@ module Padrino
14
14
  # Tell us for now wich orm we support
15
15
  #
16
16
  def supported_orm
17
- [:datamapper, :activerecord, :mongomapper, :mongoid]
17
+ [:datamapper, :activerecord, :mongomapper, :mongoid, :couchrest, :sequel]
18
18
  end
19
19
 
20
20
  ##
@@ -46,7 +46,7 @@ module Padrino
46
46
  directory "templates/app", destination_root("admin")
47
47
  directory "templates/assets", destination_root("public", "admin")
48
48
 
49
- Padrino::Generators::Model.dup.start([
49
+ Padrino::Generators::Model.start([
50
50
  "account", "name:string", "surname:string", "email:string", "crypted_password:string", "salt:string", "role:string",
51
51
  "-r=#{options[:root]}", "-s=#{options[:skip_migration]}", "-d=#{options[:destroy]}"
52
52
  ])
@@ -18,6 +18,7 @@ module Padrino
18
18
  end
19
19
 
20
20
  def field_type(type)
21
+ type = type.to_s.demodulize.downcase.to_sym unless type.is_a?(Symbol)
21
22
  case type
22
23
  when :integer, :float, :decimal then :text_field
23
24
  when :string then :text_field
@@ -27,12 +28,16 @@ module Padrino
27
28
  end
28
29
  end
29
30
 
31
+ Column = Struct.new(:name, :type) # for compatibility
32
+
30
33
  def columns
31
34
  @columns ||= case orm
32
35
  when :activerecord then @klass.columns
33
36
  when :datamapper then @klass.properties
37
+ when :couchrest then @klass.properties
34
38
  when :mongoid then @klass.fields.values
35
39
  when :mongomapper then @klass.keys.values.reject { |key| key.name == "_id" } # On MongoMapper keys are an hash
40
+ when :sequel then @klass.db_schema.map { |k,v| Column.new(k, v[:type]) }
36
41
  else raise OrmError, "Adapter #{orm} is not yet supported!"
37
42
  end
38
43
  end
@@ -53,7 +58,8 @@ module Padrino
53
58
  def find(params=nil)
54
59
  case orm
55
60
  when :activerecord, :mongomapper, :mongoid then "#{klass_name}.find(#{params})"
56
- when :datamapper then "#{klass_name}.get(#{params})"
61
+ when :datamapper, :couchrest then "#{klass_name}.get(#{params})"
62
+ when :sequel then "#{klass_name}.filter(#{params}).first"
57
63
  else raise OrmError, "Adapter #{orm} is not yet supported!"
58
64
  end
59
65
  end
@@ -67,13 +73,17 @@ module Padrino
67
73
  end
68
74
 
69
75
  def save
70
- "#{name_singular}.save"
76
+ case orm
77
+ when :sequel then "(@#{name_singular}.save rescue false)"
78
+ else "@#{name_singular}.save"
79
+ end
71
80
  end
72
81
 
73
82
  def update_attributes(params=nil)
74
83
  case orm
75
- when :activerecord, :mongomapper, :mongoid then "#{name_singular}.update_attributes(#{params})"
76
- when :datamapper then "#{name_singular}.update(#{params})"
84
+ when :activerecord, :mongomapper, :mongoid, :couchrest then "@#{name_singular}.update_attributes(#{params})"
85
+ when :datamapper then "@#{name_singular}.update(#{params})"
86
+ when :sequel then "(@#{name_singular}.update(#{params}) rescue false)"
77
87
  else raise OrmError, "Adapter #{orm} is not yet supported!"
78
88
  end
79
89
  end
@@ -0,0 +1,73 @@
1
+ class Account < CouchRest::ExtendedDocument
2
+ include CouchRest::Validation
3
+ use_database COUCHDB
4
+
5
+ attr_accessor :password, :password_confirmation
6
+
7
+ # Properties
8
+ property :name
9
+ property :surname
10
+ property :email
11
+ property :crypted_password
12
+ property :salt
13
+ property :role
14
+
15
+ view_by :email
16
+ view_by :id,
17
+ :map => "function(doc) {\n if ((doc['couchrest-type'] == 'Account') && doc['_id']) {\n emit(doc['_id'], null);\n }\n}\n"
18
+
19
+ # Validations
20
+ validates_presence_of :email, :role
21
+ validates_presence_of :password, :if => :password_required
22
+ validates_presence_of :password_confirmation, :if => :password_required
23
+ validates_length_of :password, :within => 4..40, :if => :password_required
24
+ validates_confirmation_of :password, :if => :password_required
25
+ validates_length_of :email, :within => 3..100
26
+ validates_with_method :email, :method => :email_is_unique
27
+ validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
28
+ validates_format_of :role, :with => /[A-Za-z]/
29
+
30
+ # Callbacks
31
+ before_save :generate_password
32
+
33
+ ##
34
+ # This method is for authentication purpose
35
+ #
36
+ def self.authenticate(email, password)
37
+ email_array = self.by_email :key => email
38
+ account = email_array[0]
39
+ account && account.password_clean == password ? account : nil
40
+ end
41
+
42
+ ##
43
+ # This method is used for retrive the original password.
44
+ #
45
+ def password_clean
46
+ crypted_password.decrypt(salt)
47
+ end
48
+
49
+ ##
50
+ # This method is used for retrive the first record by id without raise errors if not found.
51
+ #
52
+ def self.find_by_id(id)
53
+ id_array = self.by_id :key => id
54
+ id_array[0]
55
+ end
56
+
57
+ private
58
+ def generate_password
59
+ return if password.blank?
60
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
61
+ self.crypted_password = password.encrypt(self.salt)
62
+ end
63
+
64
+ def password_required
65
+ crypted_password.blank? || !password.blank?
66
+ end
67
+
68
+ def email_is_unique
69
+ Account.by_email(:key => self.email, :limit => 1).empty? ||
70
+ Account.by_email(:key => self.email, :limit => 1) == [self] ||
71
+ [false, "Email has already been taken"]
72
+ end
73
+ end
@@ -0,0 +1,57 @@
1
+ class Account < ::Sequel::Model
2
+
3
+ plugin :validation_helpers
4
+
5
+ attr_accessor :password, :password_confirmation
6
+
7
+ def validate
8
+ validates_presence :email
9
+ validates_presence :role
10
+ validates_presence :password if password_required
11
+ validates_presence :password_confirmation if password_required
12
+ validates_length_range 4..40, :password unless password.blank?
13
+ errors.add(:password_confirmation, 'must confirm password') if !password.blank? && password != password_confirmation
14
+ validates_length_range 3..100, :email unless email.blank?
15
+ validates_unique :email unless email.blank?
16
+ validates_format /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :email unless email.blank?
17
+ validates_format /[A-Za-z]/, :role unless role.blank?
18
+ end
19
+
20
+ # Callbacks
21
+ def before_save
22
+ generate_password
23
+ end
24
+
25
+ ##
26
+ # This method is for authentication purpose
27
+ #
28
+ def self.authenticate(email, password)
29
+ account = filter(:email => email).first
30
+ account && account.password_clean == password ? account : nil
31
+ end
32
+
33
+ ##
34
+ # This method is used for retrive the original password.
35
+ #
36
+ def password_clean
37
+ crypted_password.decrypt(salt)
38
+ end
39
+
40
+ ##
41
+ # Replace AR method
42
+ #
43
+ def self.find_by_id(id)
44
+ filter(:id => id).first
45
+ end
46
+
47
+ private
48
+ def generate_password
49
+ return if password.blank?
50
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new?
51
+ self.crypted_password = password.encrypt(self.salt)
52
+ end
53
+
54
+ def password_required
55
+ crypted_password.blank? || !password.blank?
56
+ end
57
+ end
@@ -5,13 +5,13 @@ class Admin < Padrino::Application
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
- # set :sessions, false # Enabled by default
9
8
  # set :reload, false # Reload application files (default in development)
10
9
  # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
11
10
  # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
11
+ # enable :sessions # Disabled by default
12
+ # disable :flash # Disables rack-flash (enabled by default if sessions)
12
13
  # disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present)
13
14
  # disable :padrino_mailer # Disables padrino mailer (enabled by default if present)
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
  #
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
5
  <title><%= options[:name] %></title>
6
- <%%= stylesheet_link_tag :base, :override, "themes/<%= options[:theme] %>/style" %>
6
+ <%%= stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style" %>
7
7
  </head>
8
8
  <body>
9
9
  <div id="container">
@@ -3,7 +3,7 @@
3
3
  %head
4
4
  %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
5
5
  %title <%= options[:name] %>
6
- =stylesheet_link_tag :base, :override, "themes/<%= options[:theme] %>/style"
6
+ =stylesheet_link_tag :base, "themes/<%= options[:theme] %>/style"
7
7
  %body
8
8
  #container
9
9
  #box
@@ -12,7 +12,7 @@ Admin.controllers :<%= @orm.name_plural %> do
12
12
 
13
13
  post :create do
14
14
  @<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_singular}]") %>
15
- if @<%= @orm.save %>
15
+ if <%= @orm.save %>
16
16
  flash[:notice] = '<%= @orm.klass_name %> was successfully created.'
17
17
  redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular%>.id)
18
18
  else
@@ -27,7 +27,7 @@ Admin.controllers :<%= @orm.name_plural %> do
27
27
 
28
28
  put :update, :with => :id do
29
29
  @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
30
- if @<%= @orm.update_attributes("params[:#{@orm.name_singular}]") %>
30
+ if <%= @orm.update_attributes("params[:#{@orm.name_singular}]") %>
31
31
  flash[:notice] = '<%= @orm.klass_name %> was successfully updated.'
32
32
  redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
33
33
  else
@@ -73,11 +73,8 @@ module Padrino
73
73
 
74
74
  private
75
75
  def access_denied
76
- # If request a javascript we alert the user
77
- if request.xhr? || content_type == :js
78
- halt 401, "alert('Protected resource')"
79
76
  # If we have a login_page we redirect the user
80
- elsif login_page
77
+ if login_page
81
78
  redirect(login_page)
82
79
  # If no match we halt with 401
83
80
  else
@@ -86,7 +83,10 @@ module Padrino
86
83
  end
87
84
 
88
85
  def login_page
89
- settings.login_page rescue nil
86
+ login_page ||= settings.login_page rescue nil
87
+ return unless login_page
88
+ login_page = File.join(ENV['RACK_BASE_URI'].to_s, login_page) if ENV['RACK_BASE_URI']
89
+ login_page
90
90
  end
91
91
 
92
92
  def store_location
@@ -0,0 +1,16 @@
1
+ da:
2
+ padrino:
3
+ admin:
4
+ save: Gem
5
+ cancel: Annuller
6
+ list: Liste
7
+ edit: Rediger
8
+ new: Tilføj
9
+ show: Vis
10
+ delete: Slet
11
+ confirm: Er du sikker?
12
+ created_at: Oprettet
13
+ all: Alle
14
+ profile: Profil
15
+ settings: Indstillinger
16
+ logout: Log ud
@@ -10,4 +10,7 @@ en:
10
10
  delete: Delete
11
11
  confirm: Are you sure?
12
12
  created_at: Created at
13
- all: All
13
+ all: All
14
+ profile: Profile
15
+ settings: Settings
16
+ logout: Logout
@@ -0,0 +1,16 @@
1
+ fr:
2
+ padrino:
3
+ admin:
4
+ save: Sauver
5
+ cancel: Annuler
6
+ list: Liste
7
+ edit: Editer
8
+ new: Nouveau
9
+ show: Voir
10
+ delete: Supprimmer
11
+ confirm: Etes-vous sur ?
12
+ created_at: Créé à
13
+ all: Tous
14
+ profile: Profile
15
+ settings: Paramètres
16
+ logout: Déconnexion
@@ -0,0 +1,16 @@
1
+ pt_br:
2
+ padrino:
3
+ admin:
4
+ save: Salvar
5
+ cancel: Cancelar
6
+ list: Lista
7
+ edit: Editar
8
+ new: Novo
9
+ show: Exibir
10
+ delete: Excluir
11
+ confirm: Tem certeza?
12
+ created_at: Criado em
13
+ all: Todos
14
+ profile: Perfil
15
+ settings: Preferências
16
+ logout: Sair
@@ -0,0 +1,16 @@
1
+ ru:
2
+ padrino:
3
+ admin:
4
+ save: Сохранить
5
+ cancel: Отмена
6
+ list: Список
7
+ edit: Изменить
8
+ new: Добавить
9
+ show: Показать
10
+ delete: Удалить
11
+ confirm: Вы уверены?
12
+ created_at: Добавлено
13
+ all: Все
14
+ profile: Профиль
15
+ settings: Настройки
16
+ logout: Выход
@@ -0,0 +1,26 @@
1
+ da:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "findes ikke i listen"
6
+ exclusion: "er reserveret"
7
+ invalid: "er ikke gyldig"
8
+ confirmation: "matcher ikke gentagelse"
9
+ accepted: "skal accepteres"
10
+ empty: "må ikke være tom"
11
+ blank: "må ikke være blank"
12
+ too_long: "er for lang (maksimum er {{count}} tegn)"
13
+ too_short: "er for kort (minimum er {{count}} tegn)"
14
+ wrong_length: "har ikke den rigtige længde (skal være på {{count}} tegn)"
15
+ taken: "er allerede i brug"
16
+ not_a_number: "er ikke et tal"
17
+ greater_than: "skal være større end {{count}}"
18
+ greater_than_or_equal_to: "skal være større end eller lig {{count}}"
19
+ equal_to: "skal være lig {{count}}"
20
+ less_than: "skal være mindre end {{count}}"
21
+ less_than_or_equal_to: "skal være mindre end eller lig {{count}}"
22
+ odd: "skal være ulige"
23
+ even: "skal være lige"
24
+ record_invalid: "Valideringsfejl: {{errors}}"
25
+ content_type: "fileformatet er ikke understøttet"
26
+ activerecord: *activemodel
@@ -0,0 +1,26 @@
1
+ fr:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "n'est pas inclue dans la liste"
6
+ exclusion: "est réservé"
7
+ invalid: "est invalide"
8
+ confirmation: "ne correspond pas a la confirmation"
9
+ accepted: "doit être accepté"
10
+ empty: "ne peux pas être vide"
11
+ blank: "ne peux pas être vide"
12
+ too_long: "est trop long (le maximum est de {{count}} caractères)"
13
+ too_short: "est trop court (le minimum est de {{count}} caractères)"
14
+ wrong_length: "n'est pas de bonne longueur (devrait être long de {{count}} caractères)"
15
+ taken: "n'est pas disponible"
16
+ not_a_number: "n'est pas un nombre"
17
+ greater_than: "doit être supèrieur à {{count}}"
18
+ greater_than_or_equal_to: "doit être supèrieur ou égal à {{count}}"
19
+ equal_to: "doit être égal à {{count}}"
20
+ less_than: "doit être infèrieur à {{count}}"
21
+ less_than_or_equal_to: "doit être infèrieur ou égal à {{count}}"
22
+ odd: "doit être impair"
23
+ even: "doit être pair"
24
+ record_invalid: "La validation a échoué: {{errors}}"
25
+ content_type: "format de fichier non pris en charge"
26
+ activerecord: *activemodel
@@ -0,0 +1,26 @@
1
+ pt_br:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "não está incluído na lista"
6
+ exclusion: "está reservado"
7
+ invalid: "não é válido"
8
+ confirmation: "não coincide com a confirmação"
9
+ accepted: "deve ser aceita"
10
+ empty: "não pode estar vazio"
11
+ blank: "não pode ser deixado em branco"
12
+ too_long: "é longo demais (o máximo são {{count}} letras)"
13
+ too_short: "é curto demais (o mínimo são {{count}} letras)"
14
+ wrong_length: "o comprimento está errado (deve ser de {{count}} letras)"
15
+ taken: "já está em uso"
16
+ not_a_number: "não é um número"
17
+ greater_than: "deve ser maior que {{count}}"
18
+ greater_than_or_equal_to: "deve ser maior ou igual a {{count}}"
19
+ equal_to: "deve ser igual a {{count}}"
20
+ less_than: "deve ser menor que {{count}}"
21
+ less_than_or_equal_to: "deve ser menor ou igual a {{count}}"
22
+ odd: "deve ser ímpar"
23
+ even: "deve ser par"
24
+ record_invalid: "Falha na validação: {{errors}}"
25
+ content_type: "o seguinte tipo de arquivo não é suportado"
26
+ activerecord: *activemodel
@@ -0,0 +1,26 @@
1
+ ru:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "не входит в список"
6
+ exclusion: "зарезервирован"
7
+ invalid: "неправильный"
8
+ confirmation: "не совпадает со своим подтверждением"
9
+ accepted: "должно быть принято"
10
+ empty: "не может быть пустым"
11
+ blank: "не может быть пустым"
12
+ too_long: "превышает длину (максимум {{count}} символов)"
13
+ too_short: "недостатночной длины (минимум {{count}} символов)"
14
+ wrong_length: "неправильной длины (должно быть {{count}} символов)"
15
+ taken: "уже занят"
16
+ not_a_number: "не число"
17
+ greater_than: "должно быть больше {{count}}"
18
+ greater_than_or_equal_to: "должно быть не менее {{count}}"
19
+ equal_to: "должно быть равно {{count}}"
20
+ less_than: "должно быть меньше {{count}}"
21
+ less_than_or_equal_to: "должно быть не более {{count}}"
22
+ odd: "должно быть нечетным"
23
+ even: "должно быть четным"
24
+ record_invalid: "Проверка не удалась: {{errors}}"
25
+ content_type: "формат файла не поддерживается"
26
+ activerecord: *activemodel
@@ -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.9"
8
+ s.version = "0.9.10"
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-29}
12
+ s.date = %q{2010-04-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 = [
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
  "LICENSE",
22
22
  "README.rdoc",
23
23
  "Rakefile",
24
- "VERSION",
25
24
  "lib/padrino-admin.rb",
26
25
  "lib/padrino-admin/access_control.rb",
27
26
  "lib/padrino-admin/generators/actions.rb",
@@ -29,10 +28,12 @@ Gem::Specification.new do |s|
29
28
  "lib/padrino-admin/generators/admin_page.rb",
30
29
  "lib/padrino-admin/generators/orm.rb",
31
30
  "lib/padrino-admin/generators/templates/account/activerecord.rb.tt",
31
+ "lib/padrino-admin/generators/templates/account/couchrest.rb.tt",
32
32
  "lib/padrino-admin/generators/templates/account/datamapper.rb.tt",
33
33
  "lib/padrino-admin/generators/templates/account/mongoid.rb.tt",
34
34
  "lib/padrino-admin/generators/templates/account/mongomapper.rb.tt",
35
35
  "lib/padrino-admin/generators/templates/account/seeds.rb.tt",
36
+ "lib/padrino-admin/generators/templates/account/sequel.rb.tt",
36
37
  "lib/padrino-admin/generators/templates/app/app.rb",
37
38
  "lib/padrino-admin/generators/templates/app/controllers/base.rb",
38
39
  "lib/padrino-admin/generators/templates/app/controllers/sessions.rb",
@@ -68,12 +69,20 @@ Gem::Specification.new do |s|
68
69
  "lib/padrino-admin/generators/templates/page/controller.rb.tt",
69
70
  "lib/padrino-admin/helpers/authentication_helpers.rb",
70
71
  "lib/padrino-admin/helpers/view_helpers.rb",
72
+ "lib/padrino-admin/locale/admin/da.yml",
71
73
  "lib/padrino-admin/locale/admin/de.yml",
72
74
  "lib/padrino-admin/locale/admin/en.yml",
75
+ "lib/padrino-admin/locale/admin/fr.yml",
73
76
  "lib/padrino-admin/locale/admin/it.yml",
77
+ "lib/padrino-admin/locale/admin/pt_br.yml",
78
+ "lib/padrino-admin/locale/admin/ru.yml",
79
+ "lib/padrino-admin/locale/orm/da.yml",
74
80
  "lib/padrino-admin/locale/orm/de.yml",
75
81
  "lib/padrino-admin/locale/orm/en.yml",
82
+ "lib/padrino-admin/locale/orm/fr.yml",
76
83
  "lib/padrino-admin/locale/orm/it.yml",
84
+ "lib/padrino-admin/locale/orm/pt_br.yml",
85
+ "lib/padrino-admin/locale/orm/ru.yml",
77
86
  "lib/padrino-admin/utils/crypt.rb",
78
87
  "padrino-admin.gemspec",
79
88
  "test/fixtures/data_mapper.rb",
@@ -94,18 +103,18 @@ Gem::Specification.new do |s|
94
103
  s.specification_version = 3
95
104
 
96
105
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
97
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.9"])
98
- s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.9"])
99
- s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.9"])
106
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.10"])
107
+ s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.10"])
108
+ s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.10"])
100
109
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
101
110
  s.add_development_dependency(%q<shoulda>, [">= 0"])
102
111
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
103
112
  s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
104
113
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
105
114
  else
106
- s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
107
- s.add_dependency(%q<padrino-gen>, ["= 0.9.9"])
108
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.9"])
115
+ s.add_dependency(%q<padrino-core>, ["= 0.9.10"])
116
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.10"])
117
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.10"])
109
118
  s.add_dependency(%q<haml>, [">= 2.2.1"])
110
119
  s.add_dependency(%q<shoulda>, [">= 0"])
111
120
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -113,9 +122,9 @@ Gem::Specification.new do |s|
113
122
  s.add_dependency(%q<webrat>, [">= 0.5.1"])
114
123
  end
115
124
  else
116
- s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
117
- s.add_dependency(%q<padrino-gen>, ["= 0.9.9"])
118
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.9"])
125
+ s.add_dependency(%q<padrino-core>, ["= 0.9.10"])
126
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.10"])
127
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.10"])
119
128
  s.add_dependency(%q<haml>, [">= 2.2.1"])
120
129
  s.add_dependency(%q<shoulda>, [">= 0"])
121
130
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -1,43 +1,32 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
- require 'thor/group'
3
- require 'fakeweb'
4
- require 'padrino-gen/generators/actions'
5
- Dir[File.dirname(__FILE__) + '/generators/{components}/**/*.rb'].each { |lib| require lib }
6
2
 
7
3
  class TestAdminAppGenerator < Test::Unit::TestCase
8
4
 
9
5
  def setup
10
6
  `rm -rf /tmp/sample_project`
11
- @project = Padrino::Generators::Project.dup
12
- @admin = Padrino::Generators::AdminApp.dup
13
7
  end
14
8
 
15
9
  context 'the admin app generator' do
16
10
 
17
11
  should 'fail outside app root' do
18
- output = silence_logger { @admin.start(['-r=/tmp/sample_project']) }
12
+ output = silence_logger { generate(:admin_app, '-r=/tmp/sample_project') }
19
13
  assert_match(/not at the root/, output)
20
14
  assert_no_file_exists('/tmp/admin')
21
15
  end
22
16
 
23
17
  should 'fail if we don\'t an orm' do
24
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp']) } }
25
- assert_raise(SystemExit) { silence_logger { @admin.start(['-r=/tmp/sample_project']) } }
26
- end
27
-
28
- should 'fail if we don\'t a valid orm' do
29
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=sequel']) } }
30
- assert_raise(SystemExit) { silence_logger { @admin.start(['-r=/tmp/sample_project']) } }
18
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp') } }
19
+ assert_raise(SystemExit) { silence_logger { generate(:admin_app, '-r=/tmp/sample_project') } }
31
20
  end
32
21
 
33
22
  should 'fail if we don\'t a valid theme' do
34
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=activerecord']) } }
35
- assert_raise(SystemExit) { silence_logger { @admin.start(['-r=/tmp/sample_project', '--theme=foo']) } }
23
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=activerecord') } }
24
+ assert_raise(SystemExit) { silence_logger { generate(:admin_app, '-r=/tmp/sample_project', '--theme=foo') } }
36
25
  end
37
26
 
38
27
  should 'correctyl generate a new padrino admin application with default renderer' do
39
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=activerecord']) } }
40
- assert_nothing_raised { silence_logger { @admin.start(['--root=/tmp/sample_project']) } }
28
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=activerecord') } }
29
+ assert_nothing_raised { silence_logger { generate(:admin_app, '--root=/tmp/sample_project') } }
41
30
  assert_file_exists('/tmp/sample_project')
42
31
  assert_file_exists('/tmp/sample_project/admin')
43
32
  assert_file_exists('/tmp/sample_project/admin/app.rb')
@@ -66,8 +55,8 @@ class TestAdminAppGenerator < Test::Unit::TestCase
66
55
  end
67
56
 
68
57
  should 'correctyl generate a new padrino admin application with erb renderer' do
69
- assert_nothing_raised { silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=activerecord', '-e=erb']) } }
70
- assert_nothing_raised { silence_logger { @admin.start(['--root=/tmp/sample_project']) } }
58
+ assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=activerecord', '-e=erb') } }
59
+ assert_nothing_raised { silence_logger { generate(:admin_app, '--root=/tmp/sample_project') } }
71
60
  assert_file_exists('/tmp/sample_project')
72
61
  assert_file_exists('/tmp/sample_project/admin')
73
62
  assert_file_exists('/tmp/sample_project/admin/app.rb')
@@ -95,4 +84,4 @@ class TestAdminAppGenerator < Test::Unit::TestCase
95
84
  assert_match_in_file 'role.project_module :accounts, "/accounts"', '/tmp/sample_project/admin/app.rb'
96
85
  end
97
86
  end
98
- end
87
+ end
@@ -1,8 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
- require 'thor/group'
3
- require 'fakeweb'
4
- require 'padrino-gen/generators/actions'
5
- Dir[File.dirname(__FILE__) + '/generators/{components}/**/*.rb'].each { |lib| require lib }
6
2
 
7
3
  class Person
8
4
  def self.properties
@@ -20,31 +16,27 @@ class TestAdminPageGenerator < Test::Unit::TestCase
20
16
 
21
17
  def setup
22
18
  `rm -rf /tmp/sample_project`
23
- @project = Padrino::Generators::Project.dup
24
- @admin = Padrino::Generators::AdminApp.dup
25
- @page = Padrino::Generators::AdminPage.dup
26
- @model = Padrino::Generators::Model.dup
27
19
  end
28
20
 
29
21
  context 'the admin page generator' do
30
22
 
31
23
  should 'fail outside app root' do
32
- output = silence_logger { @page.start(['foo', '-r=/tmp/sample_project']) }
24
+ output = silence_logger { generate(:admin_page, 'foo', '-r=/tmp/sample_project') }
33
25
  assert_match(/not at the root/, output)
34
26
  assert_no_file_exists('/tmp/admin')
35
27
  end
36
28
 
37
29
  should 'fail without argument and model' do
38
- silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=activerecord']) }
39
- silence_logger { @admin.start(['--root=/tmp/sample_project']) }
40
- assert_raise(Padrino::Admin::Generators::OrmError) { @page.start(['foo', '-r=/tmp/sample_project']) }
30
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=activerecord') }
31
+ silence_logger { generate(:admin_app, '--root=/tmp/sample_project') }
32
+ assert_raise(Padrino::Admin::Generators::OrmError) { generate(:admin_page, 'foo', '-r=/tmp/sample_project') }
41
33
  end
42
34
 
43
35
  should 'correctly generate a new padrino admin application default renderer' do
44
- silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper']) }
45
- silence_logger { @admin.start(['--root=/tmp/sample_project']) }
46
- silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
47
- silence_logger { @page.start(['person', '--root=/tmp/sample_project']) }
36
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=datamapper') }
37
+ silence_logger { generate(:admin_app, '--root=/tmp/sample_project') }
38
+ silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project') }
39
+ silence_logger { generate(:admin_page, 'person', '--root=/tmp/sample_project') }
48
40
  assert_file_exists '/tmp/sample_project/admin/controllers/people.rb'
49
41
  assert_file_exists '/tmp/sample_project/admin/views/people/_form.haml'
50
42
  assert_file_exists '/tmp/sample_project/admin/views/people/edit.haml'
@@ -58,10 +50,10 @@ class TestAdminPageGenerator < Test::Unit::TestCase
58
50
  end
59
51
 
60
52
  should 'correctly generate a new padrino admin application with erb renderer' do
61
- silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper', '-e=erb']) }
62
- silence_logger { @admin.start(['--root=/tmp/sample_project']) }
63
- silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
64
- silence_logger { @page.start(['person', '--root=/tmp/sample_project']) }
53
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=datamapper', '-e=erb') }
54
+ silence_logger { generate(:admin_app, '--root=/tmp/sample_project') }
55
+ silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project') }
56
+ silence_logger { generate(:admin_page, 'person', '--root=/tmp/sample_project') }
65
57
  assert_file_exists '/tmp/sample_project/admin/controllers/people.rb'
66
58
  assert_file_exists '/tmp/sample_project/admin/views/people/_form.erb'
67
59
  assert_file_exists '/tmp/sample_project/admin/views/people/edit.erb'
@@ -75,11 +67,11 @@ class TestAdminPageGenerator < Test::Unit::TestCase
75
67
  end
76
68
 
77
69
  should 'correctly generate a new padrino admin application with multiple models' do
78
- silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper']) }
79
- silence_logger { @admin.start(['--root=/tmp/sample_project']) }
80
- silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
81
- silence_logger { @model.start(['page', "name:string", "body:string", '-root=/tmp/sample_project']) }
82
- silence_logger { @page.start(['person', 'page', '--root=/tmp/sample_project']) }
70
+ silence_logger { generate(:project, 'sample_project', '--root=/tmp', '-d=datamapper') }
71
+ silence_logger { generate(:admin_app, '--root=/tmp/sample_project') }
72
+ silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project') }
73
+ silence_logger { generate(:model, 'page', "name:string", "body:string", '-root=/tmp/sample_project') }
74
+ silence_logger { generate(:admin_page, 'person', 'page', '--root=/tmp/sample_project') }
83
75
  # For Person
84
76
  assert_file_exists '/tmp/sample_project/admin/controllers/people.rb'
85
77
  assert_file_exists '/tmp/sample_project/admin/views/people/_form.haml'
data/test/helper.rb CHANGED
@@ -60,6 +60,11 @@ class Test::Unit::TestCase
60
60
  def app
61
61
  Rack::Lint.new(@app)
62
62
  end
63
+
64
+ # generate(:admin_app, '-r=/tmp/sample_project')
65
+ def generate(name, *params)
66
+ "Padrino::Generators::#{name.to_s.camelize}".constantize.start(params)
67
+ end
63
68
 
64
69
  # Asserts that a file matches the pattern
65
70
  def assert_match_in_file(pattern, file)
@@ -15,7 +15,7 @@ class TestAdminApplication < Test::Unit::TestCase
15
15
  role.protect "/foo"
16
16
  end
17
17
 
18
- get "/foo", :respond_to => [:html, :js] do
18
+ get "/foo", :provides => [:html, :js] do
19
19
  "foo"
20
20
  end
21
21
 
@@ -28,9 +28,6 @@ class TestAdminApplication < Test::Unit::TestCase
28
28
  get "/foo"
29
29
  assert_equal "You don't have permission for this resource", body
30
30
 
31
- get "/foo.js"
32
- assert_equal "alert('Protected resource')", body
33
-
34
31
  get "/unauthenticated"
35
32
  assert_equal "unauthenticated", body
36
33
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 9
9
- version: 0.9.9
8
+ - 10
9
+ version: 0.9.10
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-29 00:00:00 -07:00
20
+ date: 2010-04-22 00:00:00 +02: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
- - 9
34
- version: 0.9.9
33
+ - 10
34
+ version: 0.9.10
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
- - 9
48
- version: 0.9.9
47
+ - 10
48
+ version: 0.9.10
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
- - 9
62
- version: 0.9.9
61
+ - 10
62
+ version: 0.9.10
63
63
  type: :runtime
64
64
  version_requirements: *id003
65
65
  - !ruby/object:Gem::Dependency
@@ -144,7 +144,6 @@ files:
144
144
  - LICENSE
145
145
  - README.rdoc
146
146
  - Rakefile
147
- - VERSION
148
147
  - lib/padrino-admin.rb
149
148
  - lib/padrino-admin/access_control.rb
150
149
  - lib/padrino-admin/generators/actions.rb
@@ -152,10 +151,12 @@ files:
152
151
  - lib/padrino-admin/generators/admin_page.rb
153
152
  - lib/padrino-admin/generators/orm.rb
154
153
  - lib/padrino-admin/generators/templates/account/activerecord.rb.tt
154
+ - lib/padrino-admin/generators/templates/account/couchrest.rb.tt
155
155
  - lib/padrino-admin/generators/templates/account/datamapper.rb.tt
156
156
  - lib/padrino-admin/generators/templates/account/mongoid.rb.tt
157
157
  - lib/padrino-admin/generators/templates/account/mongomapper.rb.tt
158
158
  - lib/padrino-admin/generators/templates/account/seeds.rb.tt
159
+ - lib/padrino-admin/generators/templates/account/sequel.rb.tt
159
160
  - lib/padrino-admin/generators/templates/app/app.rb
160
161
  - lib/padrino-admin/generators/templates/app/controllers/base.rb
161
162
  - lib/padrino-admin/generators/templates/app/controllers/sessions.rb
@@ -191,12 +192,20 @@ files:
191
192
  - lib/padrino-admin/generators/templates/page/controller.rb.tt
192
193
  - lib/padrino-admin/helpers/authentication_helpers.rb
193
194
  - lib/padrino-admin/helpers/view_helpers.rb
195
+ - lib/padrino-admin/locale/admin/da.yml
194
196
  - lib/padrino-admin/locale/admin/de.yml
195
197
  - lib/padrino-admin/locale/admin/en.yml
198
+ - lib/padrino-admin/locale/admin/fr.yml
196
199
  - lib/padrino-admin/locale/admin/it.yml
200
+ - lib/padrino-admin/locale/admin/pt_br.yml
201
+ - lib/padrino-admin/locale/admin/ru.yml
202
+ - lib/padrino-admin/locale/orm/da.yml
197
203
  - lib/padrino-admin/locale/orm/de.yml
198
204
  - lib/padrino-admin/locale/orm/en.yml
205
+ - lib/padrino-admin/locale/orm/fr.yml
199
206
  - lib/padrino-admin/locale/orm/it.yml
207
+ - lib/padrino-admin/locale/orm/pt_br.yml
208
+ - lib/padrino-admin/locale/orm/ru.yml
200
209
  - lib/padrino-admin/utils/crypt.rb
201
210
  - padrino-admin.gemspec
202
211
  - test/fixtures/data_mapper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.9