nickel-haml_scaffold 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,91 @@
1
+ h1. Haml Scaffold
2
+
3
+ A collection of hacks to the Rails scaffold generator, to make it output
4
+ templates using Haml rather than ERB. You may like some of it, and may hate
5
+ other parts. You're free to use it under the terms of the MIT license if the
6
+ parts you like outweigh the parts you hate.
7
+
8
+ This scaffold generator does the same thing as the default Rails scaffold
9
+ generator, with a few differences.
10
+
11
+ h2. Differences from Rails Scaffolding:
12
+
13
+ * Haml not ERB.
14
+
15
+ h3. Controller
16
+
17
+ * Loads object with a before_filter to be DRYer.
18
+ * "Destroy" method handles error conditions.
19
+ * Actions are alphabetized for more obvious consistency.
20
+ * Uses will_paginate.
21
+
22
+ h3. Controller Test
23
+
24
+ * Tests error conditions, not just the "happy-path."
25
+ * Has 100% code coverage with RCov.
26
+ * Simplifies test method names and alphabetizes them for more obvious consistency.
27
+ * Uses some very simple mocking with mocha to limit calls to the DB.
28
+
29
+ h3. Views
30
+
31
+ * Have cleaner, more semantic XHTML.
32
+ * Are broken up into a couple of partials to be DRYer.
33
+ * Use will_paginate.
34
+
35
+ h3. Misc
36
+
37
+ * Doesn't generate a layout or CSS file.
38
+
39
+ h2. Samples
40
+
41
+ "View them here.":http://github.com/norman/haml-scaffold/tree/master/samples
42
+
43
+ h2. Installation
44
+
45
+ There are three ways you can install this generator:
46
+
47
+ h3. Gem
48
+
49
+ @sudo gem install norman-haml_scaffold --source http://gems.github.com@
50
+
51
+ - or -
52
+
53
+ <code>
54
+ <pre>
55
+ git clone git://github.com/norman/haml-scaffold.git
56
+ cd haml-scaffold
57
+ gem build haml_scaffold.gemspec
58
+ sudo gem install haml_scaffold-*.gem
59
+ </pre>
60
+ </code>
61
+
62
+ h3. Manual
63
+
64
+ Download the tarball from the Github repository and unarchive it in ~/.rails/generators.
65
+
66
+ h3. Rails Plugin
67
+
68
+ @./script/plugin install git://github.com/norman/haml-scaffold.git@
69
+
70
+ h2. Dependencies
71
+
72
+ The generated code will depend on:
73
+
74
+ * "will_paginate":http://github.com/mislav/will_paginate/
75
+ * "mocha":http://mocha.rubyforge.org/
76
+
77
+ You'll need to add the gems and/or requires to your config/environment.rb
78
+ manually.
79
+
80
+ h2. Other stuff you might be interested in:
81
+
82
+ * "Haml":http://haml.hamptoncatlin.com/
83
+ * "RSpec Haml scaffold generator":http://github.com/dfischer/rspec-haml-scaffold-generator
84
+ * "Randomba scaffold":https://github.com/norman/randomba-scaffold/tree (like this one, but ERB)
85
+
86
+ h2. Author
87
+
88
+ "Norman Clarke":mailto:norman@randomba.org
89
+
90
+ This work is derived from code in "Ruby on Rails":http://rubyonrails.org/ and
91
+ is released under its same license, the MIT License.
@@ -0,0 +1,151 @@
1
+ class HamlScaffoldGenerator < Rails::Generator::NamedBase
2
+ default_options :skip_timestamps => false, :skip_migration => false
3
+
4
+ attr_reader :controller_name,
5
+ :controller_class_path,
6
+ :controller_file_path,
7
+ :controller_class_nesting,
8
+ :controller_class_nesting_depth,
9
+ :controller_class_name,
10
+ :controller_underscore_name,
11
+ :controller_singular_name,
12
+ :controller_plural_name
13
+ alias_method :controller_file_name, :controller_underscore_name
14
+ alias_method :controller_table_name, :controller_plural_name
15
+
16
+ def initialize(runtime_args, runtime_options = {})
17
+ super
18
+
19
+ @controller_name = @name.pluralize
20
+
21
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
22
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
23
+
24
+ @name = base_name.singularize.downcase
25
+
26
+ if @controller_class_nesting.empty?
27
+ @controller_class_name = @controller_class_name_without_nesting
28
+ else
29
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
30
+ end
31
+
32
+ end
33
+
34
+ def manifest
35
+ record do |m|
36
+ # Check for class naming collisions.
37
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
38
+ m.class_collisions(class_path, "#{class_name}")
39
+
40
+ # Controller, helper, views, test and stylesheets directories.
41
+ m.directory(File.join('app/controllers', controller_class_path))
42
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
43
+ m.directory(File.join('test/functional', controller_class_path))
44
+
45
+ for action in scaffold_views
46
+ m.template(
47
+ "view_#{action}.html.erb",
48
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.haml")
49
+ )
50
+ end
51
+
52
+
53
+ m.template(
54
+ "_form.html.erb",
55
+ File.join('app/views', controller_class_path, controller_file_name, "_form.html.haml")
56
+ )
57
+
58
+ m.template(
59
+ "_object.html.erb",
60
+ File.join('app/views', controller_class_path, controller_file_name, "_#{file_name}.html.haml"))
61
+
62
+ m.template(
63
+ 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb"))
64
+
65
+
66
+ m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
67
+ m.template('helper.rb', File.join('app/helpers', "#{controller_file_name}_helper.rb"))
68
+
69
+ m.route_resources class_nesting, controller_file_name
70
+
71
+ m.dependency 'model', [file_name] + @args, :collision => :skip
72
+ end
73
+ end
74
+
75
+ protected
76
+ # Override with your own usage banner.
77
+ def banner
78
+ "Usage: #{$0} scaffold ModelName [field:type, field:type]"
79
+ end
80
+
81
+ def add_options!(opt)
82
+ opt.separator ''
83
+ opt.separator 'Options:'
84
+ opt.on("--skip-timestamps",
85
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
86
+ opt.on("--skip-migration",
87
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
88
+ end
89
+
90
+ def scaffold_views
91
+ %w[ index show new edit ]
92
+ end
93
+
94
+ def model_name
95
+ class_name.demodulize
96
+ end
97
+
98
+ def path_name(options = {})
99
+ if class_nesting_depth == 0
100
+ "#{"@" unless options[:var_without_at]}#{singular_name}"
101
+ else
102
+ if options[:index]
103
+ "[#{namespaces}, #{singular_name.capitalize}.new]"
104
+ else
105
+ "[#{namespaces}, #{"@" unless options[:var_without_at]}#{singular_name}]"
106
+ end
107
+ end
108
+ end
109
+
110
+ def namespaces
111
+ class_path.collect{|namespace| ":#{namespace.downcase}"}.join(", ")
112
+ end
113
+ end
114
+
115
+ class Rails::Generator::Commands::Create
116
+ def route_resources(namespace, *resources)
117
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
118
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
119
+
120
+ logger.route "map.resources #{resource_list}"
121
+ unless options[:pretend]
122
+ if namespace.length > 0
123
+ route_to_add = route_nested(namespace.split('::'), resource_list)
124
+ else
125
+ route_to_add = " map.resources #{resource_list}"
126
+ end
127
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
128
+ "#{match}\n#{route_to_add}\n"
129
+ end
130
+ end
131
+ end
132
+
133
+ private
134
+
135
+ def route_nested(splitted_namespace, resource_list, parent_namespace = 'map', level = 1)
136
+ namespace = splitted_namespace.shift
137
+ route_to_add = tabulator(level) + "#{parent_namespace}.namespace :#{namespace.underscore} do |#{namespace.underscore}|\n"
138
+
139
+ if splitted_namespace.size > 0
140
+ route_to_add += route_nested(splitted_namespace, resource_list, namespace.underscore, level + 1)
141
+ else
142
+ route_to_add += tabulator(level + 1) + "#{namespace.underscore}.resources #{resource_list}\n"
143
+ end
144
+ route_to_add += tabulator(level) + "end\n"
145
+ return route_to_add
146
+ end
147
+
148
+ def tabulator(level)
149
+ " " * level
150
+ end
151
+ end
@@ -0,0 +1,10 @@
1
+ - form_for(<%= path_name %>) do |f|
2
+ = f.error_messages
3
+ <% for attribute in attributes -%>
4
+ %p
5
+ = f.label :<%= attribute.name %>
6
+ %br
7
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
8
+ <% end -%>
9
+ %p
10
+ = f.submit "Submit"
@@ -0,0 +1,10 @@
1
+ = content_tag_for :div, <%= singular_name %> do
2
+ %ul
3
+ <% for attribute in attributes -%>
4
+ %li
5
+ %strong <%= attribute.column.human_name %>:
6
+ =h <%= singular_name %>.<%= attribute.name %>
7
+ <% end -%>
8
+ = link_to 'Show', polymorphic_path(<%= path_name(:var_without_at => true) %>)
9
+ = link_to 'Edit', edit_polymorphic_path(<%= path_name(:var_without_at => true) %>)
10
+ = link_to 'Destroy', polymorphic_path(<%= path_name(:var_without_at => true) %>),:confirm => 'Are you sure?', :method => :delete
@@ -0,0 +1,80 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+
3
+ before_filter :find_<%= file_name %>
4
+
5
+ <%= plural_name.upcase %>_PER_PAGE = 20
6
+
7
+ def create
8
+ @<%= file_name %> = <%= model_name %>.new(params[:<%= file_name %>])
9
+ respond_to do |format|
10
+ if @<%= file_name %>.save
11
+ flash[:notice] = '<%= model_name %> was successfully created.'
12
+ format.html { redirect_to polymorphic_path(<%= path_name(:index => true) %>) }
13
+ format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
14
+ else
15
+ format.html { render :action => "new" }
16
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
17
+ end
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ respond_to do |format|
23
+ if @<%= file_name %>.destroy
24
+ flash[:notice] = '<%= name %> was successfully destroyed.'
25
+ format.html { redirect_to polymorphic_path(<%= path_name(:index => true) %>) }
26
+ format.xml { head :ok }
27
+ else
28
+ flash[:error] = '<%= name %> could not be destroyed.'
29
+ format.html { redirect_to polymorphic_path(<%= path_name %>) }
30
+ format.xml { head :unprocessable_entity }
31
+ end
32
+ end
33
+ end
34
+
35
+ def index
36
+ @<%= plural_name %> = <%= model_name %>.paginate(:page => params[:page], :per_page => <%= plural_name.upcase %>_PER_PAGE)
37
+
38
+ respond_to do |format|
39
+ format.html
40
+ format.xml { render :xml => @<%= plural_name %> }
41
+ end
42
+ end
43
+
44
+ def edit
45
+ end
46
+
47
+ def new
48
+ @<%= file_name %> = <%= model_name %>.new
49
+ respond_to do |format|
50
+ format.html
51
+ format.xml { render :xml => @<%= file_name %> }
52
+ end
53
+ end
54
+
55
+ def show
56
+ respond_to do |format|
57
+ format.html
58
+ format.xml { render :xml => @<%= file_name %> }
59
+ end
60
+ end
61
+
62
+ def update
63
+ respond_to do |format|
64
+ if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
65
+ flash[:notice] = '<%= name %> was successfully updated.'
66
+ format.html { redirect_to polymorphic_path(<%= path_name %>) }
67
+ format.xml { head :ok }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ def find_<%= file_name %>
78
+ @<%= file_name %> = params[:id].nil? ? <%= model_name %>.new : <%= model_name %>.find(params[:id])
79
+ end
80
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+
5
+ def test_create
6
+ <%= model_name %>.any_instance.expects(:save).returns(true)
7
+ post :create, :<%= file_name %> => { }
8
+ assert_response :redirect
9
+ end
10
+
11
+ def test_create_with_failure
12
+ <%= model_name %>.any_instance.expects(:save).returns(false)
13
+ post :create, :<%= file_name %> => { }
14
+ assert_template "new"
15
+ end
16
+
17
+ def test_destroy
18
+ <%= model_name %>.any_instance.expects(:destroy).returns(true)
19
+ delete :destroy, :id => <%= plural_name %>(:one).to_param
20
+ assert_not_nil flash[:notice]
21
+ assert_response :redirect
22
+ end
23
+
24
+ def test_destroy_with_failure
25
+ <%= model_name %>.any_instance.expects(:destroy).returns(false)
26
+ delete :destroy, :id => <%= plural_name %>(:one).to_param
27
+ assert_not_nil flash[:error]
28
+ assert_response :redirect
29
+ end
30
+
31
+ def test_edit
32
+ get :edit, :id => <%= plural_name %>(:one).to_param
33
+ assert_response :success
34
+ end
35
+
36
+ def test_index
37
+ get :index
38
+ assert_response :success
39
+ assert_not_nil assigns(:<%= plural_name %>)
40
+ end
41
+
42
+ def test_new
43
+ get :new
44
+ assert_response :success
45
+ end
46
+
47
+ def test_show
48
+ get :show, :id => <%= plural_name %>(:one).to_param
49
+ assert_response :success
50
+ end
51
+
52
+ def test_update
53
+ <%= model_name %>.any_instance.expects(:save).returns(true)
54
+ put :update, :id => <%= plural_name %>(:one).to_param, :<%= file_name %> => { }
55
+ assert_response :redirect
56
+ end
57
+
58
+ def test_update_with_failure
59
+ <%= model_name %>.any_instance.expects(:save).returns(false)
60
+ put :update, :id => <%= plural_name %>(:one).to_param, :<%= file_name %> => { }
61
+ assert_template "edit"
62
+ end
63
+
64
+ end
@@ -0,0 +1,2 @@
1
+ module <%= model_name.pluralize %>Helper
2
+ end
@@ -0,0 +1,5 @@
1
+ %h2 Editing <%= singular_name %>
2
+ = render :partial => "form", :locals => {:<%= singular_name %> => @<%= singular_name %>}
3
+ %ul
4
+ %li= link_to 'Show', polymorphic_path(<%= path_name %>)
5
+ %li= link_to 'Back', polymorphic_path(<%= path_name(:index => true) %>)
@@ -0,0 +1,8 @@
1
+ %h2 Listing <%= plural_name %>
2
+ - if !@<%= plural_name %>.empty?
3
+ .<%= plural_name %>
4
+ = render :partial => "<%= singular_name %>", :collection => @<%= plural_name %>
5
+ = will_paginate(@<%= plural_name %>)
6
+ - else
7
+ %p There are no <%= plural_name %> to show yet.
8
+ = link_to 'New <%= singular_name %>', new_polymorphic_path(<%= path_name %>)
@@ -0,0 +1,4 @@
1
+ %h2 New <%= singular_name %>
2
+ = render :partial => "form", :locals => {:<%= singular_name %> => @<%= singular_name %>}
3
+ %ul
4
+ %li= link_to 'Back', polymorphic_path(<%= path_name(:index => true) %>)
@@ -0,0 +1,11 @@
1
+ %h2= "<%= class_name %> \"#{@<%= singular_name %>.to_param}\""
2
+ - content_tag_for :div, @<%= singular_name %> do
3
+ %ul
4
+ <% for attribute in attributes -%>
5
+ %li
6
+ %strong <%= attribute.column.human_name %>:
7
+ =h @<%= singular_name %>.<%= attribute.name %>
8
+ <% end -%>
9
+ %ul
10
+ %li= link_to 'Edit', edit_polymorphic_path(<%= path_name %>)
11
+ %li= link_to 'Back', polymorphic_path(<%= path_name(:index => true) %>)
data/init.rb ADDED
File without changes
@@ -0,0 +1,80 @@
1
+ class PostsController < ApplicationController
2
+
3
+ before_filter :find_post
4
+
5
+ POSTS_PER_PAGE = 20
6
+
7
+ def create
8
+ @post = Post.new(params[:post])
9
+ respond_to do |format|
10
+ if @post.save
11
+ flash[:notice] = 'Post was successfully created.'
12
+ format.html { redirect_to @post }
13
+ format.xml { render :xml => @post, :status => :created, :location => @post }
14
+ else
15
+ format.html { render :action => "new" }
16
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
17
+ end
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ respond_to do |format|
23
+ if @post.destroy
24
+ flash[:notice] = 'Post was successfully destroyed.'
25
+ format.html { redirect_to posts_path }
26
+ format.xml { head :ok }
27
+ else
28
+ flash[:error] = 'Post could not be destroyed.'
29
+ format.html { redirect_to @post }
30
+ format.xml { head :unprocessable_entity }
31
+ end
32
+ end
33
+ end
34
+
35
+ def index
36
+ @posts = Post.paginate(:page => params[:page], :per_page => POSTS_PER_PAGE)
37
+ respond_to do |format|
38
+ format.html
39
+ format.xml { render :xml => @posts }
40
+ end
41
+ end
42
+
43
+ def edit
44
+ end
45
+
46
+ def new
47
+ @post = Post.new
48
+ respond_to do |format|
49
+ format.html
50
+ format.xml { render :xml => @post }
51
+ end
52
+ end
53
+
54
+ def show
55
+ respond_to do |format|
56
+ format.html
57
+ format.xml { render :xml => @post }
58
+ end
59
+ end
60
+
61
+ def update
62
+ respond_to do |format|
63
+ if @post.update_attributes(params[:post])
64
+ flash[:notice] = 'Post was successfully updated.'
65
+ format.html { redirect_to @post }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def find_post
77
+ @post = Post.find(params[:id]) if params[:id]
78
+ end
79
+
80
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class PostsControllerTest < ActionController::TestCase
4
+
5
+ def test_create
6
+ Post.any_instance.expects(:save).returns(true)
7
+ post :create, :post => { }
8
+ assert_response :redirect
9
+ end
10
+
11
+ def test_create_with_failure
12
+ Post.any_instance.expects(:save).returns(false)
13
+ post :create, :post => { }
14
+ assert_template "new"
15
+ end
16
+
17
+ def test_destroy
18
+ Post.any_instance.expects(:destroy).returns(true)
19
+ delete :destroy, :id => posts(:one).to_param
20
+ assert_not_nil flash[:notice]
21
+ assert_response :redirect
22
+ end
23
+
24
+ def test_destroy_with_failure
25
+ Post.any_instance.expects(:destroy).returns(false)
26
+ delete :destroy, :id => posts(:one).to_param
27
+ assert_not_nil flash[:error]
28
+ assert_response :redirect
29
+ end
30
+
31
+ def test_edit
32
+ get :edit, :id => posts(:one).to_param
33
+ assert_response :success
34
+ end
35
+
36
+ def test_index
37
+ get :index
38
+ assert_response :success
39
+ assert_not_nil assigns(:posts)
40
+ end
41
+
42
+ def test_new
43
+ get :new
44
+ assert_response :success
45
+ end
46
+
47
+ def test_show
48
+ get :show, :id => posts(:one).to_param
49
+ assert_response :success
50
+ end
51
+
52
+ def test_update
53
+ Post.any_instance.expects(:save).returns(true)
54
+ put :update, :id => posts(:one).to_param, :post => { }
55
+ assert_response :redirect
56
+ end
57
+
58
+ def test_update_with_failure
59
+ Post.any_instance.expects(:save).returns(false)
60
+ put :update, :id => posts(:one).to_param, :post => { }
61
+ assert_template "edit"
62
+ end
63
+
64
+ end
@@ -0,0 +1,16 @@
1
+ - form_for(post) do |f|
2
+ = f.error_messages
3
+ %p
4
+ = f.label :title
5
+ %br
6
+ = f.text_field :title
7
+ %p
8
+ = f.label :author
9
+ %br
10
+ = f.text_field :author
11
+ %p
12
+ = f.label :content
13
+ %br
14
+ = f.text_area :content
15
+ %p
16
+ = f.submit "Submit"
@@ -0,0 +1,14 @@
1
+ = content_tag_for :div, post do
2
+ %ul
3
+ %li
4
+ %strong Title:
5
+ =h post.title
6
+ %li
7
+ %strong Author:
8
+ =h post.author
9
+ %li
10
+ %strong Content:
11
+ =h post.content
12
+ = link_to 'Show', post
13
+ = link_to 'Edit', edit_post_path(post)
14
+ = link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete
@@ -0,0 +1,5 @@
1
+ %h2 Editing post
2
+ = render :partial => "form", :locals => {:post => @post}
3
+ %ul
4
+ %li= link_to 'Show', @post
5
+ %li= link_to 'Back', posts_path
@@ -0,0 +1,8 @@
1
+ %h2 Listing posts
2
+ - if !@posts.empty?
3
+ .posts
4
+ = render :partial => "post", :collection => @posts
5
+ = will_paginate(@posts)
6
+ - else
7
+ %p There are no posts to show yet.
8
+ = link_to 'New post', new_post_path
@@ -0,0 +1,4 @@
1
+ %h2 New post
2
+ = render :partial => "form", :locals => {:post => @post}
3
+ %ul
4
+ %li= link_to 'Back', posts_path
@@ -0,0 +1,15 @@
1
+ %h2= "Post \"#{@post.to_param}\""
2
+ = content_tag_for :div, @post do
3
+ %ul
4
+ %li
5
+ %strong Title:
6
+ =h @post.title
7
+ %li
8
+ %strong Author:
9
+ =h @post.author
10
+ %li
11
+ %strong Content:
12
+ =h @post.content
13
+ %ul
14
+ %li= link_to 'Edit', edit_post_path(@post)
15
+ %li= link_to 'Back', posts_path
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nickel-haml_scaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Norman Clarke
8
+ - Juan Gallego
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-10-22 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: will_paginate
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ version_requirement:
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ version:
34
+ description: An improved Rails scaffold that uses HAML.
35
+ email: norman@randomba.org
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - MIT-LICENSE
44
+ - README.textile
45
+ - init.rb
46
+ - generators/haml_scaffold/haml_scaffold_generator.rb
47
+ - generators/haml_scaffold/templates/_form.html.erb
48
+ - generators/haml_scaffold/templates/_object.html.erb
49
+ - generators/haml_scaffold/templates/controller.rb
50
+ - generators/haml_scaffold/templates/functional_test.rb
51
+ - generators/haml_scaffold/templates/helper.rb
52
+ - generators/haml_scaffold/templates/view_edit.html.erb
53
+ - generators/haml_scaffold/templates/view_index.html.erb
54
+ - generators/haml_scaffold/templates/view_new.html.erb
55
+ - generators/haml_scaffold/templates/view_show.html.erb
56
+ - samples/posts_controller.rb
57
+ - samples/posts_controller_test.rb
58
+ - samples/views/_form.html.haml
59
+ - samples/views/_post.html.haml
60
+ - samples/views/edit.html.haml
61
+ - samples/views/index.html.haml
62
+ - samples/views/new.html.haml
63
+ - samples/views/show.html.haml
64
+ has_rdoc: false
65
+ homepage: http://randomba.org
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.2.0
87
+ signing_key:
88
+ specification_version: 2
89
+ summary: An improved Rails scaffold that uses HAML.
90
+ test_files: []
91
+