mondo-generators 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. data/.gitignore +4 -0
  2. data/Rakefile +19 -0
  3. data/VERSION +1 -0
  4. data/lib/mondo_generators.rb +3 -0
  5. data/mondo-generators.gemspec +59 -0
  6. data/rails_generators/mondo_authentication/lib/insert_commands.rb +74 -0
  7. data/rails_generators/mondo_authentication/mondo_authentication_generator.rb +99 -0
  8. data/rails_generators/mondo_authentication/templates/authentication.rb +52 -0
  9. data/rails_generators/mondo_authentication/templates/authorization_rules.rb +24 -0
  10. data/rails_generators/mondo_authentication/templates/migration.rb +31 -0
  11. data/rails_generators/mondo_authentication/templates/session.rb +3 -0
  12. data/rails_generators/mondo_authentication/templates/sessions_controller.rb +25 -0
  13. data/rails_generators/mondo_authentication/templates/user.rb +29 -0
  14. data/rails_generators/mondo_authentication/templates/users_controller.rb +74 -0
  15. data/rails_generators/mondo_authentication/templates/users_helper.rb +17 -0
  16. data/rails_generators/mondo_authentication/templates/views/_form.html.haml +37 -0
  17. data/rails_generators/mondo_authentication/templates/views/edit.html.haml +7 -0
  18. data/rails_generators/mondo_authentication/templates/views/index.html.haml +44 -0
  19. data/rails_generators/mondo_authentication/templates/views/login.html.haml +15 -0
  20. data/rails_generators/mondo_authentication/templates/views/mass_new.html.haml +13 -0
  21. data/rails_generators/mondo_authentication/templates/views/new.html.haml +7 -0
  22. data/rails_generators/mondo_authentication/templates/views/show.html.haml +5 -0
  23. metadata +23 -1
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg
2
+ doc
3
+ Manifest
4
+
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gemspec|
7
+ gemspec.name = "mondo-generators"
8
+ gemspec.summary = "A collection of useful generator scripts for Rails."
9
+ gemspec.description = "A collection of useful generator scripts for Rails."
10
+ gemspec.email = "luca.tironi@gmail.com"
11
+ gemspec.homepage = "http://gemcutter.org/gems/mondo-generators"
12
+ gemspec.authors = ["Luca Tironi"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
17
+ end
18
+
19
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,3 @@
1
+ module MondoGenerators
2
+ # nothing to see here, the real action is under rails_generators
3
+ end
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mondo-generators}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Luca Tironi"]
12
+ s.date = %q{2009-11-25}
13
+ s.description = %q{A collection of useful generator scripts for Rails.}
14
+ s.email = %q{luca.tironi@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/mondo_generators.rb",
24
+ "mondo-generators.gemspec",
25
+ "rails_generators/mondo_authentication/lib/insert_commands.rb",
26
+ "rails_generators/mondo_authentication/mondo_authentication_generator.rb",
27
+ "rails_generators/mondo_authentication/templates/authentication.rb",
28
+ "rails_generators/mondo_authentication/templates/authorization_rules.rb",
29
+ "rails_generators/mondo_authentication/templates/migration.rb",
30
+ "rails_generators/mondo_authentication/templates/session.rb",
31
+ "rails_generators/mondo_authentication/templates/sessions_controller.rb",
32
+ "rails_generators/mondo_authentication/templates/user.rb",
33
+ "rails_generators/mondo_authentication/templates/users_controller.rb",
34
+ "rails_generators/mondo_authentication/templates/users_helper.rb",
35
+ "rails_generators/mondo_authentication/templates/views/_form.html.haml",
36
+ "rails_generators/mondo_authentication/templates/views/edit.html.haml",
37
+ "rails_generators/mondo_authentication/templates/views/index.html.haml",
38
+ "rails_generators/mondo_authentication/templates/views/login.html.haml",
39
+ "rails_generators/mondo_authentication/templates/views/mass_new.html.haml",
40
+ "rails_generators/mondo_authentication/templates/views/new.html.haml",
41
+ "rails_generators/mondo_authentication/templates/views/show.html.haml"
42
+ ]
43
+ s.homepage = %q{http://gemcutter.org/gems/mondo-generators}
44
+ s.rdoc_options = ["--charset=UTF-8"]
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = %q{1.3.5}
47
+ s.summary = %q{A collection of useful generator scripts for Rails.}
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ else
55
+ end
56
+ else
57
+ end
58
+ end
59
+
@@ -0,0 +1,74 @@
1
+ Rails::Generator::Commands::Create.class_eval do
2
+ def route_resource(*resources)
3
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
4
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
5
+
6
+ logger.route "map.resource #{resource_list}"
7
+ unless options[:pretend]
8
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
9
+ "#{match}\n map.resource #{resource_list}\n"
10
+ end
11
+ end
12
+ end
13
+
14
+ def route_name(name, path, route_options = {})
15
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
16
+
17
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
18
+ unless options[:pretend]
19
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
20
+ "#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
21
+ end
22
+ end
23
+ end
24
+
25
+ def insert_into(file, line)
26
+ logger.insert "#{line} into #{file}"
27
+ unless options[:pretend]
28
+ gsub_file file, /^(class|module) .+$/ do |match|
29
+ "#{match}\n #{line}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ Rails::Generator::Commands::Destroy.class_eval do
36
+ def route_resource(*resources)
37
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
38
+ look_for = "\n map.resource #{resource_list}\n"
39
+ logger.route "map.resource #{resource_list}"
40
+ unless options[:pretend]
41
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
42
+ end
43
+ end
44
+
45
+ def route_name(name, path, route_options = {})
46
+ look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
47
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
48
+ unless options[:pretend]
49
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
50
+ end
51
+ end
52
+
53
+ def insert_into(file, line)
54
+ logger.remove "#{line} from #{file}"
55
+ unless options[:pretend]
56
+ gsub_file file, "\n #{line}", ''
57
+ end
58
+ end
59
+ end
60
+
61
+ Rails::Generator::Commands::List.class_eval do
62
+ def route_resource(*resources)
63
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
64
+ logger.route "map.resource #{resource_list}"
65
+ end
66
+
67
+ def route_name(name, path, options = {})
68
+ logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
69
+ end
70
+
71
+ def insert_into(file, line)
72
+ logger.insert "#{line} into #{file}"
73
+ end
74
+ end
@@ -0,0 +1,99 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
+ class MondoAuthenticationGenerator < Rails::Generator::Base
3
+ attr_accessor :user_name, :session_name
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+
8
+ @user_name = @args[0] || 'user'
9
+ @session_name = @args[1] || 'user_session'
10
+ end
11
+
12
+ def manifest
13
+ record do |m|
14
+ m.directory "app/models"
15
+ m.directory "app/controllers"
16
+ m.directory "app/helpers"
17
+ m.directory "app/views"
18
+ m.directory "lib"
19
+
20
+ m.directory "app/views/#{user_plural_name}"
21
+ m.template "user.rb", "app/models/#{user_singular_name}.rb"
22
+ m.template "users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
23
+ m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
24
+ m.template "views/new.html.haml", "app/views/#{user_plural_name}/new.html.haml"
25
+ m.template "views/edit.html.haml", "app/views/#{user_plural_name}/edit.html.haml"
26
+ m.template "views/_form.html.haml", "app/views/#{user_plural_name}/_form.html.haml"
27
+ m.template "views/show.html.haml", "app/views/#{user_plural_name}/show.html.haml"
28
+ m.template "views/index.html.haml", "app/views/#{user_plural_name}/index.html.haml"
29
+ m.template "views/mass_new.html.haml", "app/views/#{user_plural_name}/mass_new.html.haml"
30
+
31
+ m.directory "app/views/#{session_plural_name}"
32
+ m.template "session.rb", "app/models/#{user_singular_name}_session.rb"
33
+ m.template "sessions_controller.rb", "app/controllers/#{session_plural_name}_controller.rb"
34
+ m.template "views/login.html.haml", "app/views/#{session_plural_name}/new.html.haml"
35
+
36
+ m.template "authentication.rb", "lib/authentication.rb"
37
+ m.template "authorization_rules.rb", "config/authorization_rules.rb"
38
+ m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
39
+
40
+ m.insert_into "config/routes.rb", "map.resources :#{user_plural_name}, :collection => { :mass_new => :get, :mass_create => :post }"
41
+ m.route_resources session_plural_name
42
+ m.route_name :login, 'login', :controller => session_plural_name, :action => 'new'
43
+ m.route_name :logout, 'logout', :controller => session_plural_name, :action => 'destroy'
44
+ m.route_name :signup, 'signup', :controller => user_plural_name, :action => 'new'
45
+
46
+ m.insert_into "app/controllers/#{application_controller_name}.rb", 'include Authentication'
47
+ end
48
+ end
49
+
50
+ def user_singular_name
51
+ user_name.underscore
52
+ end
53
+
54
+ def user_plural_name
55
+ user_singular_name.pluralize
56
+ end
57
+
58
+ def user_class_name
59
+ user_name.camelize
60
+ end
61
+
62
+ def user_plural_class_name
63
+ user_plural_name.camelize
64
+ end
65
+
66
+ def session_singular_name
67
+ session_name.underscore
68
+ end
69
+
70
+ def session_plural_name
71
+ session_singular_name.pluralize
72
+ end
73
+
74
+ def session_class_name
75
+ session_name.camelize
76
+ end
77
+
78
+ def session_plural_class_name
79
+ session_plural_name.camelize
80
+ end
81
+
82
+ def application_controller_name
83
+ Rails.version >= '2.3.0' ? 'application_controller' : 'application'
84
+ end
85
+
86
+ protected
87
+ def add_options!(opt)
88
+ opt.separator ''
89
+ opt.separator 'Options:'
90
+ end
91
+
92
+ def banner
93
+ <<-EOS
94
+ Creates user model and controllers to handle registration and authentication.
95
+
96
+ USAGE: #{$0} #{spec.name} [user_name] [sessions_controller_name]
97
+ EOS
98
+ end
99
+ end
@@ -0,0 +1,52 @@
1
+ module Authentication
2
+ def self.included(controller)
3
+ controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?, :redirect_to_target_or_default
4
+ controller.filter_parameter_logging :password, :password_confirmation
5
+ end
6
+
7
+ def current_<%= user_singular_name %>_session
8
+ return @current_<%= user_singular_name %>_session if defined?(@current_<%= user_singular_name %>_session)
9
+ @current_<%= user_singular_name %>_session = <%= session_class_name %>.find
10
+ end
11
+
12
+ def current_<%= user_singular_name %>
13
+ return @current_<%= user_singular_name %> if defined?(@current_<%= user_singular_name %>)
14
+ @current_<%= user_singular_name %> = current_<%= user_singular_name %>_session && current_<%= user_singular_name %>_session.record
15
+ end
16
+
17
+ def logged_in?
18
+ current_<%= user_singular_name %>
19
+ end
20
+
21
+ def require_user
22
+ unless logged_in?
23
+ store_target_location
24
+ redirect_to login_url
25
+ return false
26
+ end
27
+ end
28
+
29
+ def require_no_user
30
+ if logged_in?
31
+ store_target_location
32
+ flash[:notice] = t("application.require_user")
33
+ redirect_to root_url
34
+ return false
35
+ end
36
+ end
37
+
38
+ def permission_denied
39
+ flash[:error] = t("application.permission_denied")
40
+ redirect_to root_url
41
+ end
42
+
43
+ def redirect_to_target_or_default(default)
44
+ redirect_to(session[:return_to] || default)
45
+ session[:return_to] = nil
46
+ end
47
+
48
+ private
49
+ def store_target_location
50
+ session[:return_to] = request.request_uri
51
+ end
52
+ end
@@ -0,0 +1,24 @@
1
+ authorization do
2
+ role :guest do
3
+ end
4
+
5
+ role :<%= user_singular_name %> do
6
+ includes :guest
7
+ has_permission_on :%= user_plural_name %>, :to => :show
8
+ has_permission_on :%= user_plural_name %>, :to => :update do
9
+ if_attribute :id => is { <%= user_singular_name %> .id }
10
+ end
11
+ end
12
+
13
+ role :admin do
14
+ has_permission_on :users, :to => [:manage, :mass_new, :mass_create]
15
+ end
16
+ end
17
+
18
+ privileges do
19
+ privilege :manage, :includes => [:create, :read, :update, :delete]
20
+ privilege :read, :includes => [:index, :show]
21
+ privilege :create, :includes => :new
22
+ privilege :update, :includes => :edit
23
+ privilege :delete, :includes => :destroy
24
+ end
@@ -0,0 +1,31 @@
1
+ class Create<%= user_plural_class_name %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :<%= user_plural_class_name %> do |t|
4
+ t.string :email
5
+ t.string :first_name
6
+ t.string :last_name
7
+ t.string :language, :default => "en"
8
+ t.string :crypted_password, :limit => 128
9
+ t.string :password_salt, :limit => 20
10
+ t.string :persistence_token, :limit => 128
11
+ t.string :single_access_token, :limit => 20
12
+ t.string :perishable_token, :limit => 20
13
+
14
+ t.integer :roles_mask, :default => 1
15
+
16
+ t.integer :login_count, :null => false, :default => 0
17
+ t.integer :failed_login_count, :null => false, :default => 0
18
+ t.datetime :last_request_at
19
+ t.datetime :current_login_at
20
+ t.datetime :last_login_at
21
+ t.string :current_login_ip
22
+ t.string :last_login_ip
23
+
24
+ t.timestamps
25
+ end
26
+ end
27
+
28
+ def self.down
29
+ drop_table :<%= user_plural_class_name %>
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ class <%= session_class_name %> < Authlogic::Session::Base
2
+ last_request_at_threshold 2.minutes
3
+ end
@@ -0,0 +1,25 @@
1
+ class <%= session_plural_class_name %>Controller < ApplicationController
2
+ before_filter :require_user, :only => :destroy
3
+ before_filter :require_no_user, :only => [:new, :create]
4
+
5
+ def new
6
+ @<%= session_singular_name %> = <%= session_class_name %>.new
7
+ end
8
+
9
+ def create
10
+ @<%= session_singular_name %> = <%= session_class_name %>.new(params[:<%= session_singular_name %>])
11
+ if @<%= session_singular_name %>.save
12
+ flash[:success] = t("user_sessions.create.notice")
13
+ redirect_to root_url
14
+ else
15
+ render :new
16
+ end
17
+ end
18
+
19
+ def destroy
20
+ @<%= session_singular_name %> = <%= session_class_name %>.find
21
+ @<%= session_singular_name %>.destroy
22
+ flash[:success] = t("user_sessions.destroy.notice")
23
+ redirect_to root_url
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ class <%= user_class_name %> < ActiveRecord::Base
2
+ acts_as_authentic
3
+
4
+ attr_accessible :first_name, :last_name, :full_name, :email, :password, :password_confirmation, :language, :roles
5
+
6
+ named_scope :with_role, lambda { |role| {:conditions => "roles_mask & #{2**ROLES.index(role.to_s)} > 0"} }
7
+
8
+ ROLES = %w[<%= user_singular_name %> admin]
9
+
10
+ def roles=(roles)
11
+ self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum
12
+ end
13
+
14
+ def roles
15
+ ROLES.reject { |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? }
16
+ end
17
+
18
+ def role_symbols
19
+ roles.map(&:to_sym)
20
+ end
21
+
22
+ def has_role?(role)
23
+ roles.include?(role) ? true : false
24
+ end
25
+
26
+ def full_name
27
+ "#{first_name} #{last_name}".strip
28
+ end
29
+ end
@@ -0,0 +1,74 @@
1
+ class <%= user_plural_class_name %>Controller < ApplicationController
2
+ filter_access_to :all
3
+
4
+ def index
5
+ @<%= user_plural_name %> = <%= user_class_name %>.paginate(:per_page => 20, :page => params[:page], :conditions => search_conditions)
6
+ end
7
+
8
+ def show
9
+ @<%= user_singular_name %> = params[:id].nil? ? @current_user : <%= user_class_name %>.find(params[:id])
10
+ end
11
+
12
+ def new
13
+ @<%= user_singular_name %> = <%= user_class_name %>.new
14
+ end
15
+
16
+ def create
17
+ @<%= user_singular_name %> = <%= user_class_name %>.new(params[:user])
18
+ if @<%= user_singular_name %>.save
19
+ flash[:success] = t("users.create.notice")
20
+ redirect_to <%= user_plural_name %>_url
21
+ else
22
+ render :new
23
+ end
24
+ end
25
+
26
+ def mass_new
27
+ end
28
+
29
+ def mass_create
30
+ unless params[:text_area].blank?
31
+ lines = params[:text_area].split("\r\n")
32
+ for line in lines
33
+ first_name, last_name, email, password = line.split(",")
34
+ <%= user_class_name %>.create!(:first_name => first_name, :last_name => last_name, :email => email, :password => password, :password_confirmation => password)
35
+ end
36
+ flash[:success] = t("users.mass_create.notice")
37
+ redirect_to <%= user_plural_name %>_url
38
+ else
39
+ flash[:error] = t("users.mass_create.error")
40
+ render :mass_new
41
+ end
42
+ end
43
+
44
+ def edit
45
+ @<%= user_singular_name %> = <%= user_class_name %>.find(params[:id])
46
+ end
47
+
48
+ def update
49
+ @<%= user_singular_name %> = <%= user_class_name %>.find(params[:id])
50
+ @<%= user_singular_name %>.attributes = params[:<%= user_singular_name %>]
51
+ if @user.save
52
+ flash[:success] = t("users.update.notice")
53
+ redirect_to @user
54
+ else
55
+ render :edit
56
+ end
57
+ end
58
+
59
+ def destroy
60
+ @<%= user_singular_name %> = <%= user_class_name %>.find(params[:id])
61
+ @<%= user_singular_name %>.destroy
62
+ flash[:notice] = t("users.destroy.notice")
63
+ redirect_to <%= user_plural_name %>_url
64
+ end
65
+
66
+ protected
67
+ def search_conditions
68
+ cond_params = { :q => "%#{params[:q]}%" }
69
+ cond_strings = returning([]) do |strings|
70
+ strings << "(<%= user_plural_name %>.first_name like :q or <%= user_plural_name %>.last_name like :q or <%= user_plural_name %>.email like :q)" unless params[:q].blank?
71
+ end
72
+ cond_strings.any? ? [ cond_strings.join(' and '), cond_params ] : nil
73
+ end
74
+ end
@@ -0,0 +1,17 @@
1
+ module <%= user_plural_class_name %>Helper
2
+ def current_user
3
+ @current_user
4
+ end
5
+
6
+ def profile_pic(user, size = "normal")
7
+ output = ""
8
+ case size
9
+ when "normal" then
10
+ output << image_tag("http://learninglab.sdabocconi.it/invader.php?seed=#{user.id}", :class => 'fb_profile_pic_rendered')
11
+ when "small" then
12
+ output << image_tag("http://learninglab.sdabocconi.it/invader.php?seed=#{user.id}&s=small", :class => 'fb_profile_pic_rendered')
13
+ when "big" then
14
+ output << image_tag("http://learninglab.sdabocconi.it/invader.php?seed=#{user.id}&s=big", :class => 'fb_profile_pic_rendered')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ = f.error_messages
2
+ - disabled = (permitted_to? :manage, @<%= user_singular_name %>) ? false : true
3
+ %p
4
+ = f.label :first_name
5
+ %br
6
+ = f.text_field :first_name
7
+ %p
8
+ = f.label :last_name
9
+ %br
10
+ = f.text_field :last_name
11
+ %p
12
+ = f.label :email
13
+ %br
14
+ = f.text_field :email, :disabled => disabled
15
+ %p
16
+ = f.label :language
17
+ %br
18
+ = f.select :language, [["English", "en"], ["Italiano", "it"]]
19
+ %p
20
+ = f.label :password
21
+ %br
22
+ = f.password_field :password
23
+ %p
24
+ = f.label :password_confirmation
25
+ %br
26
+ = f.password_field :password_confirmation
27
+ - if permitted_to? :manage, @<%= user_singular_name %>
28
+ %p
29
+ = f.label :roles
30
+ %br
31
+ - for role in User::ROLES
32
+ = check_box_tag "user[roles][]", role, @<%= user_singular_name %>.roles.include?(role), :disabled => (@<%= user_singular_name %> == @current_<%= user_singular_name %> ? true : false)
33
+ =h role.humanize
34
+ %br
35
+ %p
36
+ %button.button.positive{:type => "submit"}
37
+ = submit_button
@@ -0,0 +1,7 @@
1
+ - title t("users.edit.title")
2
+ - page "admin_page"
3
+
4
+ - form_for @<%= user_singular_name %> do |f|
5
+ = render :partial => "form", :locals => { :f => f, :submit_button => t("label.update") }
6
+
7
+ = link_to t("label.back"), :back, :class => "button"
@@ -0,0 +1,44 @@
1
+ - title t("users.index.title")
2
+ - page "admin_page"
3
+
4
+ %table
5
+ %thead
6
+ %tr
7
+ %td{:colspan => 2}
8
+ = will_paginate @<%= user_plural_name %>
9
+ %td{:style => "text-align:right;"}
10
+ = link_to t("users.index.new_user_link"), new_<%= user_singular_name %>_path
11
+ |
12
+ = link_to t("users.index.mass_new_users_link"), mass_new_<%= user_plural_name %>_path
13
+ %td
14
+ #search
15
+ - form_tag <%= user_plural_name %>_path, :method => :get do
16
+ = text_field_tag :q, h(params[:q])
17
+ = submit_tag t("users.index.search")
18
+ %tbody
19
+ %tr
20
+ %th <%= user_class_name %>
21
+ %th Active
22
+ %th Roles
23
+ %th Actions
24
+ - for user in @<%= user_plural_name %>
25
+ - tr_class = cycle 'even', 'odd'
26
+ %tr{:class => tr_class}
27
+ %td
28
+ .user_profile_pic_small
29
+ = profile_pic(<%= user_singular_name %>, "small")
30
+ .data
31
+ = link_to <%= user_singular_name %>.full_name, <%= user_singular_name %>_path(<%= user_singular_name %>)
32
+ %br
33
+ = <%= user_singular_name %>.email
34
+ %td
35
+ %td
36
+ = <%= user_singular_name %>.roles.join(', ')
37
+ %td
38
+ = link_to t("label.edit"), edit_<%= user_singular_name %>_path(<%= user_singular_name %>), :class => "button"
39
+ = link_to t("label.destroy"), <%= user_singular_name %>_path(<%= user_singular_name %>), :confirm => t("confirm.destroy"), :method => :delete, :class => "button negative" unless <%= user_singular_name %> == current_<%= user_singular_name %>
40
+
41
+ %tfoot
42
+ %tr
43
+ %td{:colspan => 4}
44
+ = will_paginate @<%= user_plural_name %>
@@ -0,0 +1,15 @@
1
+ - title t("user_sessions.new.title")
2
+ - page "home_page"
3
+
4
+ - form_for @<%= session_singular_name %> do |f|
5
+ = f.error_messages
6
+ %p
7
+ = f.label :email, t("user_sessions.new.email")
8
+ %br
9
+ = f.text_field :email, :class => "bigfield span-8"
10
+ %p
11
+ = f.label :password, t("user_sessions.new.password")
12
+ %br
13
+ = f.password_field :password, :class => "bigfield span-8"
14
+ %button.button.positive{:type => "submit"}
15
+ = t("label.login")
@@ -0,0 +1,13 @@
1
+ - title t("users.mass_new.title")
2
+ - page "admin_page"
3
+
4
+ - form_tag mass_create_<%= user_plural_name %>_path, :method => :post do
5
+ %p
6
+ = label_tag "text_area", t("users.mass_new.label")
7
+ %br
8
+ = t("users.mass_new.help")
9
+ = text_area_tag "text_area", nil, :rows => 10, :class => "span-17"
10
+ %p
11
+ %button.button.positive{:type => "submit"}
12
+ = t("label.create")
13
+ = link_to t("label.back"), <%= user_plural_name %>_path, :class => "button"
@@ -0,0 +1,7 @@
1
+ - title t("users.new.title")
2
+ - page "admin_page"
3
+
4
+ - form_for @<%= user_singular_name %> do |f|
5
+ = render :partial => "form", :locals => { :f => f, :submit_button => t("label.create") }
6
+
7
+ = link_to t("label.back"), <%= user_plural_name %>_path, :class => "button"
@@ -0,0 +1,5 @@
1
+ - title "#{@<%= user_singular_name %>.full_name}"
2
+ - page "home_page"
3
+
4
+ - if permitted_to? :update, @<%= user_singular_name %>
5
+ = link_to t("label.edit"), edit_<%= user_singular_name %>_path(@<%= user_singular_name %>)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mondo-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Tironi
@@ -22,7 +22,29 @@ extensions: []
22
22
  extra_rdoc_files:
23
23
  - README.rdoc
24
24
  files:
25
+ - .gitignore
25
26
  - README.rdoc
27
+ - Rakefile
28
+ - VERSION
29
+ - lib/mondo_generators.rb
30
+ - mondo-generators.gemspec
31
+ - rails_generators/mondo_authentication/lib/insert_commands.rb
32
+ - rails_generators/mondo_authentication/mondo_authentication_generator.rb
33
+ - rails_generators/mondo_authentication/templates/authentication.rb
34
+ - rails_generators/mondo_authentication/templates/authorization_rules.rb
35
+ - rails_generators/mondo_authentication/templates/migration.rb
36
+ - rails_generators/mondo_authentication/templates/session.rb
37
+ - rails_generators/mondo_authentication/templates/sessions_controller.rb
38
+ - rails_generators/mondo_authentication/templates/user.rb
39
+ - rails_generators/mondo_authentication/templates/users_controller.rb
40
+ - rails_generators/mondo_authentication/templates/users_helper.rb
41
+ - rails_generators/mondo_authentication/templates/views/_form.html.haml
42
+ - rails_generators/mondo_authentication/templates/views/edit.html.haml
43
+ - rails_generators/mondo_authentication/templates/views/index.html.haml
44
+ - rails_generators/mondo_authentication/templates/views/login.html.haml
45
+ - rails_generators/mondo_authentication/templates/views/mass_new.html.haml
46
+ - rails_generators/mondo_authentication/templates/views/new.html.haml
47
+ - rails_generators/mondo_authentication/templates/views/show.html.haml
26
48
  has_rdoc: true
27
49
  homepage: http://gemcutter.org/gems/mondo-generators
28
50
  licenses: []