flexi_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 (192) hide show
  1. data/README.textile +83 -70
  2. data/Rakefile +0 -22
  3. data/VERSION +1 -1
  4. data/flexi_generators.gemspec +75 -136
  5. data/init.rb +0 -1
  6. data/lib/flexi_generators.rb +2 -4
  7. data/lib/generators/flexi_auth/USAGE +5 -0
  8. data/lib/generators/flexi_auth/flexi_auth_generator.rb +117 -0
  9. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/authentication.rb +2 -9
  10. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/authlogic_session.rb +0 -0
  11. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/fixtures.yml +0 -0
  12. data/lib/generators/flexi_auth/templates/migration.rb +16 -0
  13. data/lib/generators/flexi_auth/templates/sessions_controller.rb +25 -0
  14. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/sessions_helper.rb +0 -0
  15. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/tests/testunit/sessions_controller.rb +1 -17
  16. data/lib/generators/flexi_auth/templates/tests/testunit/user.rb +4 -0
  17. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/tests/testunit/users_controller.rb +1 -1
  18. data/lib/generators/flexi_auth/templates/user.rb +3 -0
  19. data/lib/generators/flexi_auth/templates/users_controller.rb +42 -0
  20. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/users_helper.rb +0 -0
  21. data/lib/generators/flexi_auth/templates/views/erb/_error_messages.html.erb +11 -0
  22. data/lib/generators/flexi_auth/templates/views/erb/edit.html.erb +24 -0
  23. data/lib/generators/flexi_auth/templates/views/erb/index.html.erb +27 -0
  24. data/lib/generators/flexi_auth/templates/views/erb/login.html.erb +22 -0
  25. data/lib/generators/flexi_auth/templates/views/erb/new.html.erb +24 -0
  26. data/lib/generators/flexi_auth/templates/views/erb/show.html.erb +16 -0
  27. data/lib/generators/flexi_prepare/USAGE +6 -0
  28. data/lib/generators/flexi_prepare/flexi_prepare_generator.rb +56 -0
  29. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/add.png +0 -0
  30. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/admin_home_controller.rb +0 -0
  31. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/admin_home_index.html.erb +1 -1
  32. data/lib/generators/flexi_prepare/templates/application.css +278 -0
  33. data/lib/generators/flexi_prepare/templates/application.html.erb +57 -0
  34. data/lib/generators/flexi_prepare/templates/application_helper.rb +42 -0
  35. data/lib/generators/flexi_prepare/templates/back.png +0 -0
  36. data/lib/generators/flexi_prepare/templates/bg.png +0 -0
  37. data/lib/generators/flexi_prepare/templates/bg2.png +0 -0
  38. data/lib/generators/flexi_prepare/templates/boxheader.gif +0 -0
  39. data/lib/generators/flexi_prepare/templates/btn-bg-hover.png +0 -0
  40. data/lib/generators/flexi_prepare/templates/btn-bg.png +0 -0
  41. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/custom_field_error.rb +1 -1
  42. data/lib/generators/flexi_prepare/templates/delete.png +0 -0
  43. data/lib/generators/flexi_prepare/templates/edit.png +0 -0
  44. data/lib/generators/flexi_prepare/templates/inflector_portuguese.rb +59 -0
  45. data/lib/generators/flexi_prepare/templates/login.css +142 -0
  46. data/lib/generators/flexi_prepare/templates/login.html.erb +26 -0
  47. data/lib/generators/flexi_prepare/templates/logo.png +0 -0
  48. data/lib/generators/flexi_prepare/templates/menu.png +0 -0
  49. data/lib/generators/flexi_prepare/templates/messages/Thumbs.db +0 -0
  50. data/lib/generators/flexi_prepare/templates/messages/error.png +0 -0
  51. data/lib/generators/flexi_prepare/templates/messages/info.png +0 -0
  52. data/lib/generators/flexi_prepare/templates/messages/success.png +0 -0
  53. data/lib/generators/flexi_prepare/templates/messages/tip.png +0 -0
  54. data/lib/generators/flexi_prepare/templates/messages/warning.png +0 -0
  55. data/lib/generators/flexi_prepare/templates/pt-BR.yml +204 -0
  56. data/lib/generators/flexi_prepare/templates/show.png +0 -0
  57. data/{generators/flexi_layout/templates/stylesheet_site.css → lib/generators/flexi_prepare/templates/site.css} +32 -23
  58. data/lib/generators/flexi_prepare/templates/site.html.erb +20 -0
  59. data/{generators/flexi_layout/templates/home_controller.rb → lib/generators/flexi_prepare/templates/site_controller.rb} +1 -1
  60. data/lib/generators/flexi_prepare/templates/site_helper.rb +2 -0
  61. data/lib/generators/flexi_prepare/templates/site_index.html.erb +27 -0
  62. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/users.png +0 -0
  63. data/lib/generators/flexi_scaffold/USAGE +8 -0
  64. data/lib/generators/flexi_scaffold/flexi_scaffold_generator.rb +98 -0
  65. data/lib/generators/flexi_scaffold/templates/controller.rb +42 -0
  66. data/{generators → lib/generators}/flexi_scaffold/templates/fixtures.yml +3 -3
  67. data/{generators → lib/generators}/flexi_scaffold/templates/helper.rb +1 -1
  68. data/{generators → lib/generators}/flexi_scaffold/templates/migration.rb +3 -5
  69. data/lib/generators/flexi_scaffold/templates/model.rb +3 -0
  70. data/lib/generators/flexi_scaffold/templates/tests/controller.rb +50 -0
  71. data/lib/generators/flexi_scaffold/templates/tests/helper.rb +4 -0
  72. data/{test/flexi_generators_test.rb → lib/generators/flexi_scaffold/templates/tests/model.rb} +2 -2
  73. data/lib/generators/flexi_scaffold/templates/views/erb/_error_messages.html.erb +11 -0
  74. data/lib/generators/flexi_scaffold/templates/views/erb/_form.html.erb +13 -0
  75. data/lib/generators/flexi_scaffold/templates/views/erb/edit.html.erb +3 -0
  76. data/lib/generators/flexi_scaffold/templates/views/erb/index.html.erb +29 -0
  77. data/lib/generators/flexi_scaffold/templates/views/erb/new.html.erb +3 -0
  78. data/lib/generators/flexi_scaffold/templates/views/erb/show.html.erb +15 -0
  79. data/template.rb +6 -0
  80. metadata +79 -137
  81. data/flexi_template.rb +0 -28
  82. data/generators/flexi_authentication/USAGE +0 -50
  83. data/generators/flexi_authentication/flexi_authentication_generator.rb +0 -127
  84. data/generators/flexi_authentication/lib/insert_commands.rb +0 -74
  85. data/generators/flexi_authentication/templates/admin_users_controller.rb +0 -60
  86. data/generators/flexi_authentication/templates/migration.rb +0 -30
  87. data/generators/flexi_authentication/templates/sessions_controller.rb +0 -52
  88. data/generators/flexi_authentication/templates/tests/rspec/sessions_controller.rb +0 -39
  89. data/generators/flexi_authentication/templates/tests/rspec/user.rb +0 -83
  90. data/generators/flexi_authentication/templates/tests/rspec/users_controller.rb +0 -26
  91. data/generators/flexi_authentication/templates/tests/shoulda/sessions_controller.rb +0 -40
  92. data/generators/flexi_authentication/templates/tests/shoulda/user.rb +0 -85
  93. data/generators/flexi_authentication/templates/tests/shoulda/users_controller.rb +0 -27
  94. data/generators/flexi_authentication/templates/tests/testunit/user.rb +0 -88
  95. data/generators/flexi_authentication/templates/user.rb +0 -43
  96. data/generators/flexi_authentication/templates/views/erb/admin_user_edit.html.erb +0 -23
  97. data/generators/flexi_authentication/templates/views/erb/admin_user_index.html.erb +0 -33
  98. data/generators/flexi_authentication/templates/views/erb/admin_user_new.html.erb +0 -23
  99. data/generators/flexi_authentication/templates/views/erb/login.html.erb +0 -38
  100. data/generators/flexi_layout/USAGE +0 -18
  101. data/generators/flexi_layout/flexi_layout_generator.rb +0 -51
  102. data/generators/flexi_layout/lib/insert_commands.rb +0 -28
  103. data/generators/flexi_layout/templates/bg.png +0 -0
  104. data/generators/flexi_layout/templates/helper.rb +0 -19
  105. data/generators/flexi_layout/templates/home_helper.rb +0 -2
  106. data/generators/flexi_layout/templates/home_index.html.erb +0 -17
  107. data/generators/flexi_layout/templates/inflector_portuguese.rb +0 -62
  108. data/generators/flexi_layout/templates/layout.html.erb +0 -47
  109. data/generators/flexi_layout/templates/layout_login.html.erb +0 -27
  110. data/generators/flexi_layout/templates/layout_site.html.erb +0 -22
  111. data/generators/flexi_layout/templates/logo.png +0 -0
  112. data/generators/flexi_layout/templates/pt-BR.yml +0 -143
  113. data/generators/flexi_layout/templates/stylesheet.css +0 -132
  114. data/generators/flexi_layout/templates/stylesheet_login.css +0 -73
  115. data/generators/flexi_resource_scaffold/USAGE +0 -29
  116. data/generators/flexi_resource_scaffold/flexi_resource_scaffold_generator.rb +0 -179
  117. data/generators/flexi_resource_scaffold/templates/controller.rb +0 -29
  118. data/generators/flexi_resource_scaffold/templates/fixtures.yml +0 -10
  119. data/generators/flexi_resource_scaffold/templates/functional_test.rb +0 -57
  120. data/generators/flexi_resource_scaffold/templates/helper.rb +0 -2
  121. data/generators/flexi_resource_scaffold/templates/migration.rb +0 -15
  122. data/generators/flexi_resource_scaffold/templates/model.rb +0 -2
  123. data/generators/flexi_resource_scaffold/templates/old_migration.rb +0 -13
  124. data/generators/flexi_resource_scaffold/templates/rspec/functional_spec.rb +0 -255
  125. data/generators/flexi_resource_scaffold/templates/rspec/helper_spec.rb +0 -11
  126. data/generators/flexi_resource_scaffold/templates/rspec/routing_spec.rb +0 -61
  127. data/generators/flexi_resource_scaffold/templates/rspec/unit_spec.rb +0 -11
  128. data/generators/flexi_resource_scaffold/templates/rspec/views/edit_spec.rb +0 -28
  129. data/generators/flexi_resource_scaffold/templates/rspec/views/index_spec.rb +0 -26
  130. data/generators/flexi_resource_scaffold/templates/rspec/views/new_spec.rb +0 -30
  131. data/generators/flexi_resource_scaffold/templates/rspec/views/show_spec.rb +0 -25
  132. data/generators/flexi_resource_scaffold/templates/shoulda_functional_test.rb +0 -19
  133. data/generators/flexi_resource_scaffold/templates/unit_test.rb +0 -7
  134. data/generators/flexi_resource_scaffold/templates/view__form.erb +0 -6
  135. data/generators/flexi_resource_scaffold/templates/view__form.haml +0 -5
  136. data/generators/flexi_resource_scaffold/templates/view_edit.erb +0 -8
  137. data/generators/flexi_resource_scaffold/templates/view_edit.haml +0 -11
  138. data/generators/flexi_resource_scaffold/templates/view_index.erb +0 -27
  139. data/generators/flexi_resource_scaffold/templates/view_index.haml +0 -19
  140. data/generators/flexi_resource_scaffold/templates/view_new.erb +0 -9
  141. data/generators/flexi_resource_scaffold/templates/view_new.haml +0 -9
  142. data/generators/flexi_resource_scaffold/templates/view_show.erb +0 -10
  143. data/generators/flexi_resource_scaffold/templates/view_show.haml +0 -9
  144. data/generators/flexi_scaffold/USAGE +0 -51
  145. data/generators/flexi_scaffold/flexi_scaffold_generator.rb +0 -232
  146. data/generators/flexi_scaffold/templates/actions/create.rb +0 -9
  147. data/generators/flexi_scaffold/templates/actions/destroy.rb +0 -6
  148. data/generators/flexi_scaffold/templates/actions/edit.rb +0 -3
  149. data/generators/flexi_scaffold/templates/actions/index.rb +0 -4
  150. data/generators/flexi_scaffold/templates/actions/new.rb +0 -3
  151. data/generators/flexi_scaffold/templates/actions/show.rb +0 -3
  152. data/generators/flexi_scaffold/templates/actions/update.rb +0 -9
  153. data/generators/flexi_scaffold/templates/controller.rb +0 -5
  154. data/generators/flexi_scaffold/templates/model.rb +0 -3
  155. data/generators/flexi_scaffold/templates/tests/rspec/actions/create.rb +0 -11
  156. data/generators/flexi_scaffold/templates/tests/rspec/actions/destroy.rb +0 -6
  157. data/generators/flexi_scaffold/templates/tests/rspec/actions/edit.rb +0 -4
  158. data/generators/flexi_scaffold/templates/tests/rspec/actions/index.rb +0 -4
  159. data/generators/flexi_scaffold/templates/tests/rspec/actions/new.rb +0 -4
  160. data/generators/flexi_scaffold/templates/tests/rspec/actions/show.rb +0 -4
  161. data/generators/flexi_scaffold/templates/tests/rspec/actions/update.rb +0 -11
  162. data/generators/flexi_scaffold/templates/tests/rspec/controller.rb +0 -8
  163. data/generators/flexi_scaffold/templates/tests/rspec/model.rb +0 -7
  164. data/generators/flexi_scaffold/templates/tests/shoulda/actions/create.rb +0 -13
  165. data/generators/flexi_scaffold/templates/tests/shoulda/actions/destroy.rb +0 -8
  166. data/generators/flexi_scaffold/templates/tests/shoulda/actions/edit.rb +0 -6
  167. data/generators/flexi_scaffold/templates/tests/shoulda/actions/index.rb +0 -6
  168. data/generators/flexi_scaffold/templates/tests/shoulda/actions/new.rb +0 -6
  169. data/generators/flexi_scaffold/templates/tests/shoulda/actions/show.rb +0 -6
  170. data/generators/flexi_scaffold/templates/tests/shoulda/actions/update.rb +0 -13
  171. data/generators/flexi_scaffold/templates/tests/shoulda/controller.rb +0 -5
  172. data/generators/flexi_scaffold/templates/tests/shoulda/model.rb +0 -7
  173. data/generators/flexi_scaffold/templates/tests/testunit/actions/create.rb +0 -11
  174. data/generators/flexi_scaffold/templates/tests/testunit/actions/destroy.rb +0 -6
  175. data/generators/flexi_scaffold/templates/tests/testunit/actions/edit.rb +0 -4
  176. data/generators/flexi_scaffold/templates/tests/testunit/actions/index.rb +0 -4
  177. data/generators/flexi_scaffold/templates/tests/testunit/actions/new.rb +0 -4
  178. data/generators/flexi_scaffold/templates/tests/testunit/actions/show.rb +0 -4
  179. data/generators/flexi_scaffold/templates/tests/testunit/actions/update.rb +0 -11
  180. data/generators/flexi_scaffold/templates/tests/testunit/controller.rb +0 -5
  181. data/generators/flexi_scaffold/templates/tests/testunit/model.rb +0 -7
  182. data/generators/flexi_scaffold/templates/views/erb/_form.html.erb +0 -6
  183. data/generators/flexi_scaffold/templates/views/erb/edit.html.erb +0 -8
  184. data/generators/flexi_scaffold/templates/views/erb/index.html.erb +0 -41
  185. data/generators/flexi_scaffold/templates/views/erb/new.html.erb +0 -10
  186. data/generators/flexi_scaffold/templates/views/erb/show.html.erb +0 -19
  187. data/generators/flexi_scaffold/templates/views/haml/_form.html.haml +0 -10
  188. data/generators/flexi_scaffold/templates/views/haml/edit.html.haml +0 -14
  189. data/generators/flexi_scaffold/templates/views/haml/index.html.haml +0 -25
  190. data/generators/flexi_scaffold/templates/views/haml/new.html.haml +0 -7
  191. data/generators/flexi_scaffold/templates/views/haml/show.html.haml +0 -20
  192. data/test/test_helper.rb +0 -3
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
4
- context "new action" do
5
- should "render new template" do
6
- get :new
7
- assert_template 'new'
8
- end
9
- end
10
-
11
- context "create action" do
12
- should "render new template when model is invalid" do
13
- <%= user_class_name %>.any_instance.stubs(:valid?).returns(false)
14
- post :create
15
- assert_template 'new'
16
- end
17
-
18
- should "redirect when model is valid" do
19
- <%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
20
- post :create
21
- assert_redirected_to root_url
22
- <%- unless options[:authlogic] -%>
23
- assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
24
- <%- end -%>
25
- end
26
- end
27
- end
@@ -1,88 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= user_class_name %>Test < ActiveSupport::TestCase
4
- <%- unless options[:authlogic] -%>
5
- def new_<%= user_singular_name %>(attributes = {})
6
- attributes[:username] ||= 'foo'
7
- attributes[:email] ||= 'foo@example.com'
8
- attributes[:password] ||= 'abc123'
9
- attributes[:password_confirmation] ||= attributes[:password]
10
- <%= user_singular_name %> = <%= user_class_name %>.new(attributes)
11
- <%= user_singular_name %>.valid? # run validations
12
- <%= user_singular_name %>
13
- end
14
-
15
- def setup
16
- <%= user_class_name %>.delete_all
17
- end
18
-
19
- def test_valid
20
- assert new_<%= user_singular_name %>.valid?
21
- end
22
-
23
- def test_require_username
24
- assert new_<%= user_singular_name %>(:username => '').errors.on(:username)
25
- end
26
-
27
- def test_require_password
28
- assert new_<%= user_singular_name %>(:password => '').errors.on(:password)
29
- end
30
-
31
- def test_require_well_formed_email
32
- assert new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors.on(:email)
33
- end
34
-
35
- def test_validate_uniqueness_of_email
36
- new_<%= user_singular_name %>(:email => 'bar@example.com').save!
37
- assert new_<%= user_singular_name %>(:email => 'bar@example.com').errors.on(:email)
38
- end
39
-
40
- def test_validate_uniqueness_of_username
41
- new_<%= user_singular_name %>(:username => 'uniquename').save!
42
- assert new_<%= user_singular_name %>(:username => 'uniquename').errors.on(:username)
43
- end
44
-
45
- def test_validate_odd_characters_in_username
46
- assert new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors.on(:username)
47
- end
48
-
49
- def test_validate_password_length
50
- assert new_<%= user_singular_name %>(:password => 'bad').errors.on(:password)
51
- end
52
-
53
- def test_require_matching_password_confirmation
54
- assert new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors.on(:password)
55
- end
56
-
57
- def test_generate_password_hash_and_salt_on_create
58
- <%= user_singular_name %> = new_<%= user_singular_name %>
59
- <%= user_singular_name %>.save!
60
- assert <%= user_singular_name %>.password_hash
61
- assert <%= user_singular_name %>.password_salt
62
- end
63
-
64
- def test_authenticate_by_username
65
- <%= user_class_name %>.delete_all
66
- <%= user_singular_name %> = new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret')
67
- <%= user_singular_name %>.save!
68
- assert_equal <%= user_singular_name %>, <%= user_class_name %>.authenticate('foobar', 'secret')
69
- end
70
-
71
- def test_authenticate_by_email
72
- <%= user_class_name %>.delete_all
73
- <%= user_singular_name %> = new_<%= user_singular_name %>(:email => 'foo@bar.com', :password => 'secret')
74
- <%= user_singular_name %>.save!
75
- assert_equal <%= user_singular_name %>, <%= user_class_name %>.authenticate('foo@bar.com', 'secret')
76
- end
77
-
78
- def test_authenticate_bad_username
79
- assert_nil <%= user_class_name %>.authenticate('nonexisting', 'secret')
80
- end
81
-
82
- def test_authenticate_bad_password
83
- <%= user_class_name %>.delete_all
84
- new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
85
- assert_nil <%= user_class_name %>.authenticate('foobar', 'badpassword')
86
- end
87
- <%- end -%>
88
- end
@@ -1,43 +0,0 @@
1
- class <%= user_class_name %> < ActiveRecord::Base
2
- <%- if options[:authlogic] -%>
3
- acts_as_authentic
4
- <%- else -%>
5
- # new columns need to be added here to be writable through mass assignment
6
- attr_accessible :username, :email, :password, :password_confirmation
7
-
8
- attr_accessor :password
9
- before_save :prepare_password
10
-
11
- validates_presence_of :username
12
- validates_uniqueness_of :username, :email, :allow_blank => true
13
- validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@"
14
- validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
15
- validates_presence_of :password, :on => :create
16
- validates_presence_of :password_confirmation, :on => :create
17
- validates_confirmation_of :password
18
- validates_length_of :password, :minimum => 4, :allow_blank => true
19
-
20
- # login can be either username or email address
21
- def self.authenticate(login, pass)
22
- <%= user_singular_name %> = find_by_username(login) || find_by_email(login)
23
- return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.matching_password?(pass)
24
- end
25
-
26
- def matching_password?(pass)
27
- self.password_hash == encrypt_password(pass)
28
- end
29
-
30
- private
31
-
32
- def prepare_password
33
- unless password.blank?
34
- self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
35
- self.password_hash = encrypt_password(password)
36
- end
37
- end
38
-
39
- def encrypt_password(pass)
40
- Digest::SHA1.hexdigest([pass, password_salt].join)
41
- end
42
- <%- end -%>
43
- end
@@ -1,23 +0,0 @@
1
- <%% title("Editando Usuário") %>
2
-
3
- <%% form_for(@user, :url=> admin_user_url ,:html => { :method => :put }) do |f| %>
4
- <p>
5
- <%%= f.label :username, "Usuário:" %><br />
6
- <%%= f.text_field :username, :readonly=>"readonly" %>
7
- </p>
8
- <p>
9
- <%%= f.label :email, "E-mail:" %><br />
10
- <%%= f.text_field :email %>
11
- </p>
12
- <p>
13
- <%%= f.label :password, "Senha:" %><br />
14
- <%%= f.password_field :password %>
15
- </p>
16
- <p>
17
- <%%= f.label :password_confirmation, "Confirmar Senha:" %><br />
18
- <%%= f.password_field :password_confirmation %>
19
- </p>
20
- <div id="control_box">
21
- <%%=submit_tag "Alterar" %> | <%%= link_to 'Cancelar', admin_users_url %>
22
- </div>
23
- <%% end %>
@@ -1,33 +0,0 @@
1
- <%% title("Usuários") %>
2
-
3
- <div id="new_box">
4
- <%%= link_to 'Novo Usuário', new_admin_user_url, :class=>'new' %>
5
- </div>
6
-
7
- <table cellspacing="1" cellpadding="2">
8
- <tr>
9
-
10
- <th>Usuário</th>
11
-
12
- <th>E-mail</th>
13
-
14
- <th></th>
15
- <th></th>
16
- </tr>
17
- <%%- @users.each do |user|%>
18
- <tr>
19
-
20
- <td width="46%"><%%=h user.username %></td>
21
-
22
- <td width="46%"><%%=h user.email %></td>
23
-
24
- <td width="8%" align="center"><%%=link_to 'Editar', edit_admin_user_url(user), :class=>'edit' %></td>
25
- <%% if (user.username == 'admin') %>
26
- <td width="8%" align="center"><%%=link_to 'Excluir', "#delete", :class=>'delete', :onclick => "alert('Não é possível excluir o usuário Admin.');" %></td>
27
- <%% else %>
28
- <td width="8%" align="center"><%%=link_to 'Excluir', admin_user_url(user), :class=>'delete', :confirm => 'Tem certeza que deseja excluir?', :method => :delete %></td>
29
- <%% end %>
30
- </tr>
31
- <%% end %>
32
- </table>
33
- <%%= will_paginate @users, :previous_label=>'&laquo; Anterior', :next_label=>'Próximo &raquo;' %>
@@ -1,23 +0,0 @@
1
- <%% title("Novo Usuário") %>
2
-
3
- <%% form_for(@user, :url => admin_users_url ) do |f| %>
4
- <p>
5
- <%%= f.label :username, "Usuário:" %><br />
6
- <%%= f.text_field :username %>
7
- </p>
8
- <p>
9
- <%%= f.label :email, "E-mail:" %><br />
10
- <%%= f.text_field :email %>
11
- </p>
12
- <p>
13
- <%%= f.label :password, "Senha:" %><br />
14
- <%%= f.password_field :password %>
15
- </p>
16
- <p>
17
- <%%= f.label :password_confirmation, "Confirmar Senha:" %><br />
18
- <%%= f.password_field :password_confirmation %>
19
- </p>
20
- <div id="control_box">
21
- <%%= submit_tag "Salvar" %> | <%%= link_to 'Cancelar', admin_users_url %>
22
- </div>
23
- <%% end %>
@@ -1,38 +0,0 @@
1
- <%% title "Autenticação" %>
2
-
3
- <%- if options[:authlogic] -%>
4
-
5
- <%% form_for @<%= session_singular_name %> do |f| %>
6
- <%%= f.error_messages %>
7
- <p>
8
- <%%= f.label :username, "Usuário:" %><br />
9
- <%%= f.text_field :username %>
10
- </p>
11
- <p>
12
- <%%= f.label :password, "Senha:" %><br />
13
- <%%= f.password_field :password %>
14
- </p>
15
- <div id="control_box">
16
- <%%= f.submit "Acessar" %>
17
- </div>
18
- <%% end %>
19
-
20
- <%- else -%>
21
-
22
- <%% form_tag <%= session_plural_name %>_path do %>
23
- <table cellspacing="1" cellpadding="2" align="center" style="padding-top:20px;padding-bottom:20px;">
24
- <tr>
25
- <td align="right"><%%= label_tag :login, "Usuário ou E-mail:" %></td>
26
- <td><%%= text_field_tag :login, params[:login] %></td>
27
- </tr>
28
- <tr>
29
- <td align="right"><%%= label_tag :password, "Senha:" %></td>
30
- <td><%%= password_field_tag :password %></td>
31
- </tr>
32
- </table>
33
- <div id="control_box">
34
- <%%= submit_tag "Acessar" %>
35
- </div>
36
- <%% end %>
37
-
38
- <%- end -%>
@@ -1,18 +0,0 @@
1
- Description:
2
- The flexi_layout generator creates a basic layout and login layout stylesheet and
3
- helper which will give some structure to a starting Rails app.
4
-
5
- The generator takes one argument which will be the name of the
6
- layout and stylesheet files. If no argument is passed then it defaults
7
- to "application".
8
-
9
- The helper module includes some methods which can be called in any
10
- template or partial to set variables to be used in the layout, such as
11
- page title and javascript/stylesheet includes.
12
-
13
- Examples:
14
- script/generate flexi_layout
15
-
16
- Layout: app/views/layouts/application.html.erb | login.html.erb
17
- Stylesheet: public/stylesheets/application.css | login.css
18
- Helper: app/helpers/layout_helper.rb
@@ -1,51 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
-
3
- class FlexiLayoutGenerator < Rails::Generator::Base
4
-
5
- def manifest
6
- record do |m|
7
- m.directory "app/views/layouts"
8
- m.directory "public/stylesheets"
9
- m.directory "public/images"
10
- m.directory "app/helpers"
11
- m.directory "app/views/home"
12
- m.directory "app/views/admin/home"
13
- m.directory "app/controllers/admin"
14
- m.template "layout.html.erb", "app/views/layouts/application.html.erb"
15
- m.template "layout_login.html.erb", "app/views/layouts/login.html.erb"
16
- m.template "layout_site.html.erb", "app/views/layouts/site.html.erb"
17
- m.template "home_index.html.erb", "app/views/home/index.html.erb"
18
- m.template "admin_home_index.html.erb", "app/views/admin/home/index.html.erb"
19
- m.file "admin_home_controller.rb", "app/controllers/admin/home_controller.rb"
20
- m.file "home_controller.rb", "app/controllers/home_controller.rb"
21
- m.file "home_helper.rb", "app/helpers/home_helper.rb"
22
- m.file "stylesheet.css", "public/stylesheets/application.css"
23
- m.file "stylesheet_login.css", "public/stylesheets/login.css"
24
- m.file "stylesheet_site.css", "public/stylesheets/site.css"
25
- m.file "logo.png", "public/images/logo.png"
26
- m.file "add.png", "public/images/add.png"
27
- m.file "users.png", "public/images/users.png"
28
- m.file "bg.png", "public/images/bg.png"
29
- m.file "helper.rb", "app/helpers/layout_helper.rb"
30
- m.file "custom_field_error.rb", "config/initializers/custom_field_error.rb"
31
- m.file "inflector_portuguese.rb", "config/initializers/inflector_portuguese.rb"
32
- m.file "pt-BR.yml", "config/locales/pt-BR.yml"
33
- m.route "map.root :controller => :home"
34
- m.route "map.admin 'admin', :controller => 'sessions', :action => 'new'"
35
- m.route "map.namespace :admin do |admin|
36
- admin.home 'home', :controller => 'home', :action => 'index'
37
- admin.resources :users
38
- end"
39
- end
40
- end
41
-
42
- protected
43
-
44
- def banner
45
- <<-EOS
46
- Creates generic layout, stylesheet, and helper files.
47
-
48
- USAGE: #{$0} #{spec.name} [layout_name]
49
- EOS
50
- end
51
- end
@@ -1,28 +0,0 @@
1
- Rails::Generator::Commands::Create.class_eval do
2
- def route(route)
3
- sentinel = 'ActionController::Routing::Routes.draw do |map|'
4
-
5
- logger.route "#{route}"
6
- unless options[:pretend]
7
- gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
8
- "#{match}\n #{route}"
9
- end
10
- end
11
- end
12
- end
13
-
14
- Rails::Generator::Commands::Destroy.class_eval do
15
- def route_name(route)
16
- look_for = "\n #{route}"
17
- logger.route "#{route}"
18
- unless options[:pretend]
19
- gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
20
- end
21
- end
22
- end
23
-
24
- Rails::Generator::Commands::List.class_eval do
25
- def route(route)
26
- logger.route "{route}"
27
- end
28
- end
@@ -1,19 +0,0 @@
1
- # helper :layout
2
- module LayoutHelper
3
- def title(page_title, show_title = true)
4
- @content_for_title = page_title.to_s
5
- @show_title = show_title
6
- end
7
-
8
- def show_title?
9
- @show_title
10
- end
11
-
12
- def stylesheet(*args)
13
- content_for(:head) { stylesheet_link_tag(*args) }
14
- end
15
-
16
- def javascript(*args)
17
- content_for(:head) { javascript_include_tag(*args) }
18
- end
19
- end
@@ -1,2 +0,0 @@
1
- module HomeHelper
2
- end
@@ -1,17 +0,0 @@
1
- <%% title("Home#index") %>
2
- <h1>Primeiros passos</h1>
3
- <ul>
4
- <li>
5
- <h2>Edite este layout em app/views/layouts/site.html.erb</h2>
6
- <p>Crie seu layout, altere o logo e estilos.</p>
7
- </li>
8
- <li>
9
- <h2>Edite esta página em app/views/home/index.html.erb</h2>
10
- <p>Crie sua página inicial.</p>
11
- </li>
12
- <li>
13
- <h2>Acesse a área administrativa <%%= link_to 'aqui', login_path %></h2>
14
- <p>Usuário: admin</p>
15
- <p>Senha: admin123</p>
16
- </li>
17
- </ul>
@@ -1,62 +0,0 @@
1
- # Infelizmente não é possível colocar todas as regras...
2
- #
3
- # http://pt.wikipedia.org/wiki/Plural e
4
- # http://pt.wikipedia.org/wiki/Singular
5
- module Inflector
6
- ActiveSupport::Inflector.inflections do |inflect|
7
- inflect.clear
8
-
9
- inflect.plural(/$/, 's')
10
- inflect.plural(/(s)$/i, '\1')
11
- inflect.plural(/^(paí)s$/i, '\1ses')
12
- #inflect.plural(/(z|r)$/i, '\1es')
13
- inflect.plural(/al$/i, 'ais')
14
- inflect.plural(/el$/i, 'eis')
15
- inflect.plural(/ol$/i, 'ois')
16
- inflect.plural(/ul$/i, 'uis')
17
- inflect.plural(/([^aeou])il$/i, '\1is')
18
- inflect.plural(/m$/i, 'ns')
19
- inflect.plural(/^(japon|escoc|ingl|dinamarqu|fregu|portugu)ês$/i, '\1eses')
20
- inflect.plural(/^(|g)ás$/i, '\1ases')
21
- inflect.plural(/ão$/i, 'ões')
22
- inflect.plural(/^(irm|m)ão$/i, '\1ãos')
23
- inflect.plural(/^(alem|c|p)ão$/i, '\1ães')
24
- inflect.plural(/or$/i, 'ores')
25
- # Sem acentos...
26
- inflect.plural(/ao$/i, 'oes')
27
- inflect.plural(/^(irm|m)ao$/i, '\1aos')
28
- inflect.plural(/^(alem|c|p)ao$/i, '\1aes')
29
-
30
- inflect.singular(/ores$/i, 'or')
31
- inflect.singular(/([^ê])s$/i, '\1')
32
- inflect.singular(/^(á|gá|paí)s$/i, '\1s')
33
- inflect.singular(/(r|z)es$/i, '\1')
34
- inflect.singular(/([^p])ais$/i, '\1al')
35
- inflect.singular(/eis$/i, 'el')
36
- inflect.singular(/ois$/i, 'ol')
37
- inflect.singular(/uis$/i, 'ul')
38
- inflect.singular(/(r|t|f|v)is$/i, '\1il')
39
- inflect.singular(/ns$/i, 'm')
40
- inflect.singular(/sses$/i, 'sse')
41
- inflect.singular(/^(.*[^s]s)es$/i, '\1')
42
- inflect.singular(/ães$/i, 'ão')
43
- inflect.singular(/aes$/i, 'ao')
44
- inflect.singular(/ãos$/i, 'ão')
45
- inflect.singular(/aos$/i, 'ao')
46
- inflect.singular(/ões$/i, 'ão')
47
- inflect.singular(/oes$/i, 'ao')
48
- inflect.singular(/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i, '\1ês')
49
- inflect.singular(/^(g|)ases$/i, '\1ás')
50
-
51
- # #irregulares
52
- # irregulares = {'país' => 'paises'}
53
- #
54
- #
55
- # irregulares.each do |key, value|
56
- # inflect.plural(/^#{key.to_s}$/, value)
57
- # inflect.singular(/^#{value}$/, key.to_s)
58
- # end
59
-
60
- inflect.uncountable %w( tórax tênis ônibus lápis fênix )
61
- end
62
- end
@@ -1,47 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <title><%%= "Área administrativa - #{h(yield(:title))}" %></title>
7
- <%%= stylesheet_link_tag 'application' %>
8
- <%%= yield(:head) %>
9
- </head>
10
- <body>
11
- <div id="top_nav">
12
- <%% if logged_in? %>
13
- <%%= current_user.username %> | <%%= current_user.email %> | <%%= link_to "&raquo; Sair", logout_path, :class => 'logout' %>
14
- <%% else %>
15
- <%%= link_to "&raquo; Entrar", login_path, :class => 'login' %>
16
- <%% end %>
17
- </div>
18
- <div id="header">
19
- <%%= link_to image_tag("logo.png"), admin_home_url %>
20
- </div>
21
- <div id="container">
22
- <div id="sidenav">
23
- <%% tabs do |tab| %>
24
- <%% tab.users admin_users_path do %>
25
- <%%= image_tag 'users.png' %> Usuários
26
- <%% end %>
27
- <%%= tab.menu1 'Menu1', "#menu" %>
28
- <%%= tab.menu2 'Menu2', "#menu" %>
29
- <%%= tab.menu3 'Menu3', "#menu" %>
30
- <%%= tab.menu4 'Menu4', "#menu" %>
31
- <%% end %>
32
- </div>
33
- <div id="main">
34
- <%%- if show_title? -%>
35
- <div id="title_box">
36
- <h2><%%=h yield(:title) %></h2>
37
- </div>
38
- <%%- end -%>
39
- <%%- flash.each do |name, msg| -%>
40
- <%%= content_tag :div, msg, :id => "flash_#{name}" %>
41
- <%%- end -%>
42
-
43
- <%%= yield %>
44
- </div>
45
- </div>
46
- </body>
47
- </html>
@@ -1,27 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <title><%%= "Área administrativa - #{h(yield(:title))}" %></title>
7
- <%%= stylesheet_link_tag 'login' %>
8
- <%%= yield(:head) %>
9
- </head>
10
- <body>
11
- <div align="center">
12
- <%%= image_tag("logo.png") %>
13
- </div>
14
- <div id="container">
15
- <%%- if show_title? -%>
16
- <div id="title_box">
17
- <h2><%%=h yield(:title) %></h2>
18
- </div>
19
- <%%- end -%>
20
- <%%- flash.each do |name, msg| -%>
21
- <%%= content_tag :div, msg, :id => "flash_#{name}" %>
22
- <%%- end -%>
23
-
24
- <%%= yield %>
25
- </div>
26
- </body>
27
- </html>
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <title><%%= "Página inicial - #{h(yield(:title))}" %></title>
7
- <%%= stylesheet_link_tag 'site' %>
8
- <%%= yield(:head) %>
9
- </head>
10
- <body>
11
- <div id="header">
12
- <%%= link_to image_tag("logo.png"), root_path %>
13
- </div>
14
- <div id="container">
15
- <%%- flash.each do |name, msg| -%>
16
- <%%= content_tag :div, msg, :id => "flash_#{name}" %>
17
- <%%- end -%>
18
-
19
- <%%= yield %>
20
- </div>
21
- </body>
22
- </html>