dust-generators 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Rakefile +10 -11
  2. data/lib/dust/version.rb +9 -0
  3. data/lib/generators/dust/config/config_generator.rb +1 -1
  4. data/lib/generators/dust/scaffold/scaffold_generator.rb +3 -1
  5. data/lib/generators/dust/scaffold/templates/actions/index.rb +1 -1
  6. data/lib/generators/dust/scaffold/templates/model.rb +12 -0
  7. data/lib/generators/dust/scaffold/templates/views/erb/_form.html.erb +10 -4
  8. data/lib/generators/dust/scaffold/templates/views/erb/_search.html.erb +6 -0
  9. data/lib/generators/dust/scaffold/templates/views/erb/edit.html.erb +2 -12
  10. data/lib/generators/dust/scaffold/templates/views/erb/index.html.erb +21 -26
  11. data/lib/generators/dust/scaffold/templates/views/erb/new.html.erb +1 -3
  12. data/lib/generators/dust/scaffold/templates/views/erb/show.html.erb +20 -18
  13. metadata +6 -40
  14. data/lib/generators/dust/authentication/USAGE +0 -50
  15. data/lib/generators/dust/authentication/authentication_generator.rb +0 -154
  16. data/lib/generators/dust/authentication/templates/authlogic_session.rb +0 -2
  17. data/lib/generators/dust/authentication/templates/controller_authentication.rb +0 -61
  18. data/lib/generators/dust/authentication/templates/fixtures.yml +0 -24
  19. data/lib/generators/dust/authentication/templates/migration.rb +0 -20
  20. data/lib/generators/dust/authentication/templates/sessions_controller.rb +0 -45
  21. data/lib/generators/dust/authentication/templates/sessions_helper.rb +0 -2
  22. data/lib/generators/dust/authentication/templates/tests/rspec/sessions_controller.rb +0 -39
  23. data/lib/generators/dust/authentication/templates/tests/rspec/user.rb +0 -83
  24. data/lib/generators/dust/authentication/templates/tests/rspec/users_controller.rb +0 -56
  25. data/lib/generators/dust/authentication/templates/tests/shoulda/sessions_controller.rb +0 -40
  26. data/lib/generators/dust/authentication/templates/tests/shoulda/user.rb +0 -85
  27. data/lib/generators/dust/authentication/templates/tests/shoulda/users_controller.rb +0 -61
  28. data/lib/generators/dust/authentication/templates/tests/testunit/sessions_controller.rb +0 -36
  29. data/lib/generators/dust/authentication/templates/tests/testunit/user.rb +0 -88
  30. data/lib/generators/dust/authentication/templates/tests/testunit/users_controller.rb +0 -53
  31. data/lib/generators/dust/authentication/templates/user.rb +0 -42
  32. data/lib/generators/dust/authentication/templates/users_controller.rb +0 -34
  33. data/lib/generators/dust/authentication/templates/users_helper.rb +0 -2
  34. data/lib/generators/dust/authentication/templates/views/erb/_form.html.erb +0 -20
  35. data/lib/generators/dust/authentication/templates/views/erb/edit.html.erb +0 -3
  36. data/lib/generators/dust/authentication/templates/views/erb/login.html.erb +0 -30
  37. data/lib/generators/dust/authentication/templates/views/erb/signup.html.erb +0 -5
  38. data/lib/generators/dust/authentication/templates/views/haml/_form.html.haml +0 -20
  39. data/lib/generators/dust/authentication/templates/views/haml/edit.html.haml +0 -3
  40. data/lib/generators/dust/authentication/templates/views/haml/login.html.haml +0 -30
  41. data/lib/generators/dust/authentication/templates/views/haml/signup.html.haml +0 -5
  42. data/lib/generators/dust/layout/USAGE +0 -25
  43. data/lib/generators/dust/layout/layout_generator.rb +0 -29
  44. data/lib/generators/dust/layout/templates/error_messages_helper.rb +0 -23
  45. data/lib/generators/dust/layout/templates/layout.html.erb +0 -19
  46. data/lib/generators/dust/layout/templates/layout.html.haml +0 -21
  47. data/lib/generators/dust/layout/templates/layout_helper.rb +0 -22
  48. data/lib/generators/dust/layout/templates/stylesheet.css +0 -75
  49. data/lib/generators/dust/layout/templates/stylesheet.sass +0 -66
@@ -1,20 +0,0 @@
1
- <%%= form_for @<%= user_singular_name %> do |f| %>
2
- <%%= f.error_messages %>
3
- <p>
4
- <%%= f.label :username %><br />
5
- <%%= f.text_field :username %>
6
- </p>
7
- <p>
8
- <%%= f.label :email, "Email Address" %><br />
9
- <%%= f.text_field :email %>
10
- </p>
11
- <p>
12
- <%%= f.label :password %><br />
13
- <%%= f.password_field :password %>
14
- </p>
15
- <p>
16
- <%%= f.label :password_confirmation, "Confirm Password" %><br />
17
- <%%= f.password_field :password_confirmation %>
18
- </p>
19
- <p><%%= f.submit (@<%= user_singular_name %>.new_record? ? "Sign up" : "Update") %></p>
20
- <%% end %>
@@ -1,3 +0,0 @@
1
- <%% title "Update Profile" %>
2
-
3
- <%%= render 'form' %>
@@ -1,30 +0,0 @@
1
- <%% title "Log in" %>
2
-
3
- <p>Don't have an account? <%%= link_to "Sign up!", signup_path %></p>
4
-
5
- <%- if options[:authlogic] -%>
6
- <%%= form_for @<%= session_singular_name %> do |f| %>
7
- <%%= f.error_messages %>
8
- <p>
9
- <%%= f.label :username %><br />
10
- <%%= f.text_field :username %>
11
- </p>
12
- <p>
13
- <%%= f.label :password %><br />
14
- <%%= f.password_field :password %>
15
- </p>
16
- <p><%%= f.submit "Log in" %></p>
17
- <%% end %>
18
- <%- else -%>
19
- <%%= form_tag <%= session_plural_name %>_path do %>
20
- <p>
21
- <%%= label_tag :login, "Username or Email Address" %><br />
22
- <%%= text_field_tag :login, params[:login] %>
23
- </p>
24
- <p>
25
- <%%= label_tag :password %><br />
26
- <%%= password_field_tag :password %>
27
- </p>
28
- <p><%%= submit_tag "Log in" %></p>
29
- <%% end %>
30
- <%- end -%>
@@ -1,5 +0,0 @@
1
- <%% title "Sign up" %>
2
-
3
- <p>Already have an account? <%%= link_to "Log in", login_path %>.</p>
4
-
5
- <%%= render 'form' %>
@@ -1,20 +0,0 @@
1
- - form_for @<%= user_singular_name %> do |f|
2
- = f.error_messages
3
- %p
4
- = f.label :username
5
- %br
6
- = f.text_field :username
7
- %p
8
- = f.label :email, "Email Address"
9
- %br
10
- = f.text_field :email
11
- %p
12
- = f.label :password
13
- %br
14
- = f.password_field :password
15
- %p
16
- = f.label :password_confirmation, "Confirm Password"
17
- %br
18
- = f.password_field :password_confirmation
19
- %p
20
- = f.submit (@<%= user_singular_name %>.new_record? ? "Sign up" : "Update")
@@ -1,3 +0,0 @@
1
- - title "Sign up"
2
-
3
- = render 'form'
@@ -1,30 +0,0 @@
1
- - title "Log in"
2
-
3
- %p== Don't have an account? #{link_to "Sign up!", signup_path}
4
-
5
- <%- if options[:authlogic] -%>
6
- - form_for @<%= session_singular_name %> do |f|
7
- = f.error_messages
8
- %p
9
- = f.label :username
10
- %br
11
- = f.text_field :username
12
- %p
13
- = f.label :password
14
- %br
15
- = f.password_field :password
16
- %p
17
- = f.submit "Log in"
18
- <%- else -%>
19
- - form_tag <%= session_plural_name %>_path do
20
- %p
21
- = label_tag :login, "Username or Email Address"
22
- %br
23
- = text_field_tag :login, params[:login]
24
- %p
25
- = label_tag :password
26
- %br
27
- = password_field_tag :password
28
- %p
29
- = submit_tag "Log in"
30
- <%- end -%>
@@ -1,5 +0,0 @@
1
- - title "Sign up"
2
-
3
- %p== Already have an account? #{link_to "Log in", login_path}.
4
-
5
- = render 'form'
@@ -1,25 +0,0 @@
1
- Description:
2
- The dust_layout generator creates a basic 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
- rails generate dust:layout
15
-
16
- Layout: app/views/layouts/application.html.erb
17
- Stylesheet: public/stylesheets/application.css
18
- Helper: app/helpers/layout_helper.rb
19
-
20
-
21
- rails generate dust:layout admin
22
-
23
- Layout: app/views/layouts/admin.html.erb
24
- Stylesheet: public/stylesheets/admin.css
25
- Helper: app/helpers/layout_helper.rb
@@ -1,29 +0,0 @@
1
- require 'generators/dust'
2
-
3
- module Dust
4
- module Generators
5
- class LayoutGenerator < Base
6
- argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'
7
-
8
- class_option :haml, :desc => 'Generate HAML for view, and SASS for stylesheet.', :type => :boolean
9
-
10
- def create_layout
11
- if options.haml?
12
- template 'layout.html.haml', "app/views/layouts/#{file_name}.html.haml"
13
- copy_file 'stylesheet.sass', "public/stylesheets/sass/#{file_name}.sass"
14
- else
15
- template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb"
16
- copy_file 'stylesheet.css', "public/stylesheets/#{file_name}.css"
17
- end
18
- copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
19
- copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb'
20
- end
21
-
22
- private
23
-
24
- def file_name
25
- layout_name.underscore
26
- end
27
- end
28
- end
29
- end
@@ -1,23 +0,0 @@
1
- module ErrorMessagesHelper
2
- # Render error messages for the given objects. The :message and :header_message options are allowed.
3
- def error_messages_for(*objects)
4
- options = objects.extract_options!
5
- options[:header_message] ||= "Invalid Fields"
6
- options[:message] ||= "Correct the following errors and try again."
7
- messages = objects.compact.map { |o| o.errors.full_messages }.flatten
8
- unless messages.empty?
9
- content_tag(:div, :class => "error_messages") do
10
- list_items = messages.map { |msg| content_tag(:li, msg) }
11
- content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
12
- end
13
- end
14
- end
15
-
16
- module FormBuilderAdditions
17
- def error_messages(options = {})
18
- @template.error_messages_for(@object, options)
19
- end
20
- end
21
- end
22
-
23
- ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
5
- <%%= stylesheet_link_tag "<%= file_name %>" %>
6
- <%%= javascript_include_tag :defaults %>
7
- <%%= csrf_meta_tag %>
8
- <%%= yield(:head) %>
9
- </head>
10
- <body>
11
- <div id="container">
12
- <%% flash.each do |name, msg| %>
13
- <%%= content_tag :div, msg, :id => "flash_#{name}" %>
14
- <%% end %>
15
- <%%= content_tag :h1, yield(:title) if show_title? %>
16
- <%%= yield %>
17
- </div>
18
- </body>
19
- </html>
@@ -1,21 +0,0 @@
1
- !!!
2
- %html
3
-
4
- %head
5
- %title
6
- = yield(:title) || "Untitled"
7
- %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
8
- = stylesheet_link_tag "<%= file_name %>"
9
- = javascript_include_tag :defaults
10
- = csrf_meta_tag
11
- = yield(:head)
12
-
13
- %body
14
- #container
15
- - flash.each do |name, msg|
16
- = content_tag :div, msg, :id => "flash_#{name}"
17
-
18
- - if show_title?
19
- %h1= yield(:title)
20
-
21
- = yield
@@ -1,22 +0,0 @@
1
- # These helper methods can be called in your template to set variables to be used in the layout
2
- # This module should be included in all views globally,
3
- # to do so you may need to add this line to your ApplicationController
4
- # helper :layout
5
- module LayoutHelper
6
- def title(page_title, show_title = true)
7
- content_for(:title) { h(page_title.to_s) }
8
- @show_title = show_title
9
- end
10
-
11
- def show_title?
12
- @show_title
13
- end
14
-
15
- def stylesheet(*args)
16
- content_for(:head) { stylesheet_link_tag(*args) }
17
- end
18
-
19
- def javascript(*args)
20
- content_for(:head) { javascript_include_tag(*args) }
21
- end
22
- end
@@ -1,75 +0,0 @@
1
- body {
2
- background-color: #4B7399;
3
- font-family: Verdana, Helvetica, Arial;
4
- font-size: 14px;
5
- }
6
-
7
- a img {
8
- border: none;
9
- }
10
-
11
- a {
12
- color: #0000FF;
13
- }
14
-
15
- .clear {
16
- clear: both;
17
- height: 0;
18
- overflow: hidden;
19
- }
20
-
21
- #container {
22
- width: 75%;
23
- margin: 0 auto;
24
- background-color: #FFF;
25
- padding: 20px 40px;
26
- border: solid 1px black;
27
- margin-top: 20px;
28
- }
29
-
30
- #flash_notice, #flash_error, #flash_alert {
31
- padding: 5px 8px;
32
- margin: 10px 0;
33
- }
34
-
35
- #flash_notice {
36
- background-color: #CFC;
37
- border: solid 1px #6C6;
38
- }
39
-
40
- #flash_error, #flash_alert {
41
- background-color: #FCC;
42
- border: solid 1px #C66;
43
- }
44
-
45
- .fieldWithErrors {
46
- display: inline;
47
- }
48
-
49
- .error_messages {
50
- width: 400px;
51
- border: 2px solid #CF0000;
52
- padding: 0px;
53
- padding-bottom: 12px;
54
- margin-bottom: 20px;
55
- background-color: #f0f0f0;
56
- font-size: 12px;
57
- }
58
-
59
- .error_messages h2 {
60
- text-align: left;
61
- font-weight: bold;
62
- padding: 5px 10px;
63
- font-size: 12px;
64
- margin: 0;
65
- background-color: #c00;
66
- color: #fff;
67
- }
68
-
69
- .error_messages p {
70
- margin: 8px 10px;
71
- }
72
-
73
- .error_messages ul {
74
- margin: 0;
75
- }
@@ -1,66 +0,0 @@
1
- $primary_color: #4b7399
2
-
3
- body
4
- background-color: $primary_color
5
- font:
6
- family: Verdana, Helvetica, Arial
7
- size: 14px
8
-
9
- a
10
- color: blue
11
- img
12
- border: none
13
-
14
- .clear
15
- clear: both
16
- height: 0
17
- overflow: hidden
18
-
19
- #container
20
- width: 75%
21
- margin: 0 auto
22
- background: white
23
- padding: 20px 40px
24
- border: solid 1px black
25
- margin-top: 20px
26
-
27
- #flash_notice,
28
- #flash_error,
29
- #flash_alert
30
- padding: 5px 8px
31
- margin: 10px 0
32
-
33
- #flash_notice
34
- background-color: #ccffcc
35
- border: solid 1px #66cc66
36
-
37
- #flash_error,
38
- #flash_alert
39
- background-color: #ffcccc
40
- border: solid 1px #cc6666
41
-
42
- .fieldWithErrors
43
- display: inline
44
-
45
- .error_messages
46
- width: 400px
47
- border: 2px solid #cf0000
48
- padding: 0
49
- padding-bottom: 12px
50
- margin-bottom: 20px
51
- background-color: #f0f0f0
52
- font:
53
- size: 12px
54
- h2
55
- text-align: left
56
- padding: 5px 5px 5px 15px
57
- margin: 0
58
- font:
59
- weight: bold
60
- size: 12px
61
- background-color: #cc0000
62
- color: white
63
- p
64
- margin: 8px 10px
65
- ul
66
- margin: 0