msimkins-haml_scaffold 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +21 -0
- data/README.rdoc +88 -0
- data/Rakefile +24 -0
- data/generators/haml_scaffold/haml_scaffold_generator.rb +102 -0
- data/generators/haml_scaffold/templates/_form.html.haml.erb +7 -0
- data/generators/haml_scaffold/templates/_object.feature.erb +43 -0
- data/generators/haml_scaffold/templates/_object.html.haml.erb +10 -0
- data/generators/haml_scaffold/templates/_object_factory.rb.erb +5 -0
- data/generators/haml_scaffold/templates/_object_steps.rb.erb +12 -0
- data/generators/haml_scaffold/templates/controller.rb.erb +80 -0
- data/generators/haml_scaffold/templates/helper.rb.erb +2 -0
- data/generators/haml_scaffold/templates/layout.html.haml.erb +19 -0
- data/generators/haml_scaffold/templates/stylesheet.sass +11 -0
- data/generators/haml_scaffold/templates/view_edit.html.haml.erb +7 -0
- data/generators/haml_scaffold/templates/view_index.html.haml.erb +9 -0
- data/generators/haml_scaffold/templates/view_new.html.haml.erb +5 -0
- data/generators/haml_scaffold/templates/view_show.html.haml.erb +12 -0
- data/init.rb +0 -0
- data/lib/haml_scaffold/version.rb +8 -0
- metadata +172 -0
data/History.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
=== 1.1.0 / 2009-07-30
|
2
|
+
|
3
|
+
* 3 major enhancements
|
4
|
+
|
5
|
+
* Upated generator code to Rails 2.3.2.
|
6
|
+
* Haml Scaffold now generates layout and a SASS stylesheet.
|
7
|
+
* Tests now use 'test "name" do' syntax.
|
8
|
+
|
9
|
+
=== 1.0.0 / 2009-02-10
|
10
|
+
|
11
|
+
* 1 major enhancement
|
12
|
+
|
13
|
+
* First rubyforge release.
|
14
|
+
|
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/Manifest.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
History.txt
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
generators/haml_scaffold/haml_scaffold_generator.rb
|
7
|
+
generators/haml_scaffold/templates/_form.html.haml.erb
|
8
|
+
generators/haml_scaffold/templates/_object.feature.erb
|
9
|
+
generators/haml_scaffold/templates/_object.html.haml.erb
|
10
|
+
generators/haml_scaffold/templates/_object_factory.rb.erb
|
11
|
+
generators/haml_scaffold/templates/_object_steps.rb.erb
|
12
|
+
generators/haml_scaffold/templates/controller.rb.erb
|
13
|
+
generators/haml_scaffold/templates/helper.rb.erb
|
14
|
+
generators/haml_scaffold/templates/layout.html.haml.erb
|
15
|
+
generators/haml_scaffold/templates/stylesheet.sass
|
16
|
+
generators/haml_scaffold/templates/view_edit.html.haml.erb
|
17
|
+
generators/haml_scaffold/templates/view_index.html.haml.erb
|
18
|
+
generators/haml_scaffold/templates/view_new.html.haml.erb
|
19
|
+
generators/haml_scaffold/templates/view_show.html.haml.erb
|
20
|
+
init.rb
|
21
|
+
lib/haml_scaffold/version.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
= 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
|
+
== Differences from Rails Scaffolding:
|
12
|
+
|
13
|
+
* Haml not ERB.
|
14
|
+
|
15
|
+
=== 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
|
+
=== Controller Test
|
23
|
+
|
24
|
+
* Tests error conditions, not just the "happy path."
|
25
|
+
* Has 100% code coverage with RCov.
|
26
|
+
* Uses very simple mocking with mocha to limit calls to the DB.
|
27
|
+
|
28
|
+
=== Views
|
29
|
+
|
30
|
+
* Have cleaner, more semantic XHTML that's easier to quickly replace with your own markup.
|
31
|
+
* Are broken up into a couple of partials to be DRYer.
|
32
|
+
* Use will_paginate.
|
33
|
+
|
34
|
+
=== Misc
|
35
|
+
|
36
|
+
* Generates Haml layout and SASS stylesheet.
|
37
|
+
|
38
|
+
== Samples
|
39
|
+
|
40
|
+
{View them here}[http://github.com/norman/haml-scaffold/tree/master/samples].
|
41
|
+
|
42
|
+
== Installation
|
43
|
+
|
44
|
+
Haml Scaffold is available on RubyForge as a gem:
|
45
|
+
|
46
|
+
sudo gem install msimkins-haml_scaffold
|
47
|
+
|
48
|
+
You can also install it as a Rails plugin if you wish:
|
49
|
+
|
50
|
+
./script/plugin install git://github.com/msimkins/haml-scaffold.git
|
51
|
+
|
52
|
+
== Dependencies
|
53
|
+
|
54
|
+
The generated code will depend on:
|
55
|
+
|
56
|
+
* haml[http://haml.hamptoncatlin.com/] (of course!)
|
57
|
+
* will_paginate[http://github.com/mislav/will_paginate/]
|
58
|
+
* mocha[http://mocha.rubyforge.org/]
|
59
|
+
* formtastic[http://github.com/justinfrench/formtastic]
|
60
|
+
|
61
|
+
You'll need to add the gem dependencies to your config/environment.rb
|
62
|
+
manually:
|
63
|
+
|
64
|
+
config.gem "haml"
|
65
|
+
config.gem "will_paginate"
|
66
|
+
config.gem "mocha"
|
67
|
+
config.gem "formtastic"
|
68
|
+
|
69
|
+
Also, don't forget to Hamlize your Rails app:
|
70
|
+
|
71
|
+
$ cd my_rails_app
|
72
|
+
$ haml --rails .
|
73
|
+
|
74
|
+
== Other stuff you might be interested in:
|
75
|
+
|
76
|
+
* Haml[http://haml.hamptoncatlin.com/]
|
77
|
+
* {RSpec Haml scaffold generator}[http://github.com/dfischer/rspec-haml-scaffold-generator]
|
78
|
+
|
79
|
+
== Author
|
80
|
+
|
81
|
+
{Norman Clarke}[mailto:norman@njclarke.com], modifications by {Mike Simkins}[mailto:software@g7obs.com]
|
82
|
+
|
83
|
+
== Contributors
|
84
|
+
{Caleb Harrelson}[mailto:atrophic@gmail.com]
|
85
|
+
== License
|
86
|
+
|
87
|
+
This work is derived from code in {Ruby on Rails}[http://rubyonrails.org/] and
|
88
|
+
is released under its same license, the MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'newgem'
|
2
|
+
require File.dirname(__FILE__) + "/lib/haml_scaffold/version"
|
3
|
+
$hoe = Hoe.new("haml_scaffold", HamlScaffold::Version::STRING) do |p|
|
4
|
+
p.rubyforge_name = "haml-scaffold"
|
5
|
+
p.author = ['Norman Clarke']
|
6
|
+
p.email = ['norman@njclarke.com']
|
7
|
+
p.summary = "Rails scaffolding with Haml rather than ERB"
|
8
|
+
p.description = "Rails scaffolding with Haml rather than ERB, and various other improvements."
|
9
|
+
p.url = 'http://haml-scaffold.rubyforge.org/'
|
10
|
+
p.extra_deps << ['haml', '>= 2.0.6']
|
11
|
+
p.extra_deps << ['will_paginate', '>= 2.2.2']
|
12
|
+
p.extra_deps << ['mocha', '>= 0.9.0']
|
13
|
+
p.extra_dev_deps << ['newgem', ">= #{::Newgem::VERSION}"]
|
14
|
+
p.remote_rdoc_dir = "/"
|
15
|
+
end
|
16
|
+
require 'newgem/tasks'
|
17
|
+
|
18
|
+
desc 'Publish RDoc to RubyForge.'
|
19
|
+
task :publish_docs => [:clean, :docs] do
|
20
|
+
host = "compay@rubyforge.org"
|
21
|
+
remote_dir = "/var/www/gforge-projects/haml-scaffold"
|
22
|
+
local_dir = 'doc'
|
23
|
+
sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
|
24
|
+
end
|
@@ -0,0 +1,102 @@
|
|
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
|
+
:application_name
|
14
|
+
alias_method :controller_file_name, :controller_underscore_name
|
15
|
+
alias_method :controller_table_name, :controller_plural_name
|
16
|
+
|
17
|
+
def initialize(runtime_args, runtime_options = {})
|
18
|
+
super
|
19
|
+
|
20
|
+
if @name == @name.pluralize && !options[:force_plural]
|
21
|
+
logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
|
22
|
+
@name = @name.singularize
|
23
|
+
end
|
24
|
+
|
25
|
+
@controller_name = @name.pluralize
|
26
|
+
@application_name = File.basename(Rails.root.to_s).humanize
|
27
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
28
|
+
@controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
|
29
|
+
@controller_singular_name = base_name.singularize
|
30
|
+
if @controller_class_nesting.empty?
|
31
|
+
@controller_class_name = @controller_class_name_without_nesting
|
32
|
+
else
|
33
|
+
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def manifest
|
38
|
+
record do |m|
|
39
|
+
|
40
|
+
# Check for class naming collisions.
|
41
|
+
m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
|
42
|
+
m.class_collisions(class_path, "#{class_name}")
|
43
|
+
|
44
|
+
# Controller, helper, views, test and stylesheets directories.
|
45
|
+
m.directory(File.join('app/models', class_path))
|
46
|
+
m.directory(File.join('app/controllers', controller_class_path))
|
47
|
+
m.directory(File.join('app/helpers', controller_class_path))
|
48
|
+
m.directory(File.join('app/views', controller_class_path, controller_file_name))
|
49
|
+
|
50
|
+
for action in scaffold_views
|
51
|
+
m.template("view_#{action}.html.haml.erb", File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.haml"))
|
52
|
+
end
|
53
|
+
|
54
|
+
m.template("_form.html.haml.erb", File.join('app/views', controller_class_path, controller_file_name, "_form.html.haml"))
|
55
|
+
m.template("_object.html.haml.erb", File.join('app/views', controller_class_path, controller_file_name, "_#{name}.html.haml"))
|
56
|
+
m.template('controller.rb.erb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb"))
|
57
|
+
m.template('helper.rb.erb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
|
58
|
+
m.directory('app/views/layouts')
|
59
|
+
m.template('layout.html.haml.erb', 'app/views/layouts/application.html.haml', :collision => :skip, :assigns => {:application_name => @application_name})
|
60
|
+
m.directory('public/stylesheets/sass')
|
61
|
+
m.template('stylesheet.sass', 'public/stylesheets/sass/application.sass', :collision => :skip)
|
62
|
+
m.route_resources controller_file_name
|
63
|
+
m.dependency 'rspec_model', [name] + @args + ['--skip-fixture'], :collision => :skip
|
64
|
+
|
65
|
+
# Cucumber feature
|
66
|
+
m.directory('features/step_definitions')
|
67
|
+
m.template("_object.feature.erb", File.join('features', "#{name}.feature"))
|
68
|
+
m.template("_object_steps.rb.erb", File.join('features', 'step_definitions', "#{name}_steps.rb"))
|
69
|
+
|
70
|
+
# Factory_Girl factory
|
71
|
+
m.directory('spec/factories')
|
72
|
+
m.template("_object_factory.rb.erb", File.join('spec', 'factories', "#{name}_factory.rb"))
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
# Override with your own usage banner.
|
80
|
+
def banner
|
81
|
+
"Usage: #{$0} haml_scaffold ModelName [field:type, field:type]"
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_options!(opt)
|
85
|
+
opt.separator ''
|
86
|
+
opt.separator 'Options:'
|
87
|
+
opt.on("--skip-timestamps",
|
88
|
+
"Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
|
89
|
+
opt.on("--skip-migration",
|
90
|
+
"Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
|
91
|
+
opt.on("--force-plural",
|
92
|
+
"Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
|
93
|
+
end
|
94
|
+
|
95
|
+
def scaffold_views
|
96
|
+
%w[ index show new edit ]
|
97
|
+
end
|
98
|
+
|
99
|
+
def model_name
|
100
|
+
class_name.demodulize
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: <%= singular_name.capitalize %>
|
2
|
+
In order to not look like a bloody fool
|
3
|
+
As a competent developer
|
4
|
+
I want to change several bits of this feature *before* I check it in
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given "sharon" a logged in user
|
8
|
+
|
9
|
+
Scenario: Create a new <%= singular_name.capitalize %>
|
10
|
+
When I go to the <%= plural_name.capitalize %> page
|
11
|
+
And I follow "New <%= singular_name.capitalize %>"
|
12
|
+
Then I should be on the new <%= singular_name.capitalize %> page
|
13
|
+
And I should not see "Untitled"
|
14
|
+
And I should not see "translation_missing"
|
15
|
+
When I fill in "Attributes" with "Relevant Text"
|
16
|
+
And I press "Create <%= singular_name.capitalize %>"
|
17
|
+
Then I should be on the show <%= singular_name.capitalize %> page
|
18
|
+
And I should see "Relevant Text"
|
19
|
+
|
20
|
+
Scenario: List all <%= plural_name.capitalize %>
|
21
|
+
Given The <%= singular_name.capitalize %> "My New <%= singular_name.capitalize %>" exists
|
22
|
+
And The <%= singular_name.capitalize %> "My Other <%= singular_name.capitalize %>" exists
|
23
|
+
And The <%= singular_name.capitalize %> "This Other <%= singular_name.capitalize %>" exists
|
24
|
+
When I go to the <%= plural_name.capitalize %> page
|
25
|
+
Then I should not see "Untitled"
|
26
|
+
And I should not see "translation_missing"
|
27
|
+
And I should see "My New <%= singular_name.capitalize %>"
|
28
|
+
And I should see "My Other <%= singular_name.capitalize %>"
|
29
|
+
And I should see "This Other <%= singular_name.capitalize %>"
|
30
|
+
And There should be exactly "3" <%= plural_name.capitalize %>
|
31
|
+
|
32
|
+
Scenario: Edit a <%= singular_name.capitalize %>
|
33
|
+
Given The <%= singular_name.capitalize %> "My New <%= singular_name.capitalize %>" exists
|
34
|
+
When I visit the <%= singular_name.capitalize %> edit screen for "My New <%= singular_name.capitalize %>"
|
35
|
+
Then I should not see "Untitled"
|
36
|
+
And I should not see "translation_missing"
|
37
|
+
When I fill in "Attributes" with "Some Relevant Text"
|
38
|
+
And I press "Update <%= singular_name.capitalize %>"
|
39
|
+
Then I should be on the show <%= singular_name.capitalize %> page
|
40
|
+
And I should see "Some Relevant Text"
|
41
|
+
And I should not see "Old And Irrelevant Text"
|
42
|
+
|
43
|
+
|
@@ -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', <%= singular_name %>
|
9
|
+
= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
|
10
|
+
= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Given /^I visit the <%= singular_name.capitalize %> edit screen for "([^\"]*)"$/ do |<%= singular_name %>_name|
|
2
|
+
visit edit_<%= singular_name %>_path(<%= singular_name.capitalize %>.find_by_name(<%= singular_name %>_name))
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^The <%= singular_name.capitalize %> "([^\"]*)" exists$/ do |<%= singular_name %>_name|
|
6
|
+
Factory.create(:<%= singular_name %>, :name => <%= singular_name %>_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^There should be exactly "([^\"]*)" <%= plural_name.capitalize %>$/ do |num|
|
10
|
+
<%= singular_name.capitalize %>.all.size.should == num.to_i
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
|
3
|
+
before_filter :find_<%= file_name %>
|
4
|
+
|
5
|
+
<%= file_name.pluralize.upcase %>_PER_PAGE = 20
|
6
|
+
|
7
|
+
def create
|
8
|
+
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
9
|
+
respond_to do |format|
|
10
|
+
if @<%= file_name %>.save
|
11
|
+
flash[:notice] = '<%= class_name %> was successfully created.'
|
12
|
+
format.html { redirect_to @<%= file_name %> }
|
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] = '<%= class_name %> was successfully destroyed.'
|
25
|
+
format.html { redirect_to <%= file_name.pluralize %>_path }
|
26
|
+
format.xml { head :ok }
|
27
|
+
else
|
28
|
+
flash[:error] = '<%= class_name %> could not be destroyed.'
|
29
|
+
format.html { redirect_to @<%= file_name %> }
|
30
|
+
format.xml { head :unprocessable_entity }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def index
|
36
|
+
@<%= table_name %> = <%= class_name %>.paginate(:page => params[:page], :per_page => <%= file_name.pluralize.upcase %>_PER_PAGE)
|
37
|
+
respond_to do |format|
|
38
|
+
format.html
|
39
|
+
format.xml { render :xml => @<%= table_name %> }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def edit
|
44
|
+
end
|
45
|
+
|
46
|
+
def new
|
47
|
+
@<%= file_name %> = <%= class_name %>.new
|
48
|
+
respond_to do |format|
|
49
|
+
format.html
|
50
|
+
format.xml { render :xml => @<%= file_name %> }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def show
|
55
|
+
respond_to do |format|
|
56
|
+
format.html
|
57
|
+
format.xml { render :xml => @<%= file_name %> }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
respond_to do |format|
|
63
|
+
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
|
64
|
+
flash[:notice] = '<%= class_name %> was successfully updated.'
|
65
|
+
format.html { redirect_to @<%= file_name %> }
|
66
|
+
format.xml { head :ok }
|
67
|
+
else
|
68
|
+
format.html { render :action => "edit" }
|
69
|
+
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def find_<%= file_name %>
|
77
|
+
@<%= file_name %> = <%= class_name %>.find(params[:id]) if params[:id]
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
!!!
|
2
|
+
%html{ :'xml:lang' => "en", :lang => "en" }
|
3
|
+
%head
|
4
|
+
%title= "#{controller.class.to_s}: #{controller.action_name}"
|
5
|
+
%meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" }
|
6
|
+
%link{ :rel => "shortcut icon", :href => "/favicon.ico" }
|
7
|
+
= stylesheet_link_tag "application", "formtastic", "formtastic_changes", :cache => "styles"
|
8
|
+
= javascript_include_tag :defaults
|
9
|
+
%body
|
10
|
+
#wrapper
|
11
|
+
#content
|
12
|
+
%h1 <%= application_name %>
|
13
|
+
#flash
|
14
|
+
- unless flash.empty?
|
15
|
+
-flash.each do |key, msg|
|
16
|
+
= content_tag :div, msg, :id => key, :class => key
|
17
|
+
:javascript
|
18
|
+
#{visual_effect :highlight, "flash"}
|
19
|
+
= yield
|
@@ -0,0 +1,7 @@
|
|
1
|
+
- title
|
2
|
+
%h2 Editing <%= singular_name.capitalize %>
|
3
|
+
= render :partial => "form", :locals => {:<%= singular_name %> => @<%= singular_name %>}
|
4
|
+
%ul
|
5
|
+
%li= link_to 'Show', @<%= singular_name %>
|
6
|
+
%li= link_to 'Back', <%= plural_name %>_path
|
7
|
+
%li= link_to 'Destroy', @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- title
|
2
|
+
%h2 Listing <%= plural_name.capitalize %>
|
3
|
+
- if !@<%= plural_name %>.empty?
|
4
|
+
.<%= plural_name %>
|
5
|
+
= render :partial => "<%= singular_name %>", :collection => @<%= plural_name %>
|
6
|
+
= will_paginate(@<%= plural_name %>)
|
7
|
+
- else
|
8
|
+
%p There are no <%= plural_name %> to show yet.
|
9
|
+
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- title
|
2
|
+
%h2= "<%= class_name %> \"#{@<%= singular_name %>.to_param}\""
|
3
|
+
- content_tag_for :div, @<%= singular_name %> do
|
4
|
+
%ul
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
%li
|
7
|
+
%strong <%= attribute.column.human_name %>:
|
8
|
+
=h @<%= singular_name %>.<%= attribute.name %>
|
9
|
+
<% end -%>
|
10
|
+
%ul
|
11
|
+
%li= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>)
|
12
|
+
%li= link_to 'Back', <%= plural_name %>_path
|
data/init.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: msimkins-haml_scaffold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Norman Clarke
|
14
|
+
- Caleb Harrelson
|
15
|
+
- Mike Simkins
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-06-19 00:00:00 +01:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: haml
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
32
|
+
segments:
|
33
|
+
- 2
|
34
|
+
- 0
|
35
|
+
- 6
|
36
|
+
version: 2.0.6
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: will_paginate
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 2
|
50
|
+
- 2
|
51
|
+
- 2
|
52
|
+
version: 2.2.2
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 59
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
- 9
|
67
|
+
- 0
|
68
|
+
version: 0.9.0
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id003
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: newgem
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 5
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 4
|
83
|
+
- 1
|
84
|
+
version: 1.4.1
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: hoe
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 55
|
96
|
+
segments:
|
97
|
+
- 1
|
98
|
+
- 8
|
99
|
+
- 0
|
100
|
+
version: 1.8.0
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id005
|
103
|
+
description: Rails scaffolding with Haml rather than ERB, and various other improvements.
|
104
|
+
email:
|
105
|
+
- software@g7obs.com
|
106
|
+
executables: []
|
107
|
+
|
108
|
+
extensions: []
|
109
|
+
|
110
|
+
extra_rdoc_files:
|
111
|
+
- History.txt
|
112
|
+
- Manifest.txt
|
113
|
+
- README.rdoc
|
114
|
+
files:
|
115
|
+
- History.txt
|
116
|
+
- MIT-LICENSE
|
117
|
+
- Manifest.txt
|
118
|
+
- README.rdoc
|
119
|
+
- Rakefile
|
120
|
+
- generators/haml_scaffold/haml_scaffold_generator.rb
|
121
|
+
- generators/haml_scaffold/templates/_form.html.haml.erb
|
122
|
+
- generators/haml_scaffold/templates/_object.feature.erb
|
123
|
+
- generators/haml_scaffold/templates/_object.html.haml.erb
|
124
|
+
- generators/haml_scaffold/templates/_object_factory.rb.erb
|
125
|
+
- generators/haml_scaffold/templates/_object_steps.rb.erb
|
126
|
+
- generators/haml_scaffold/templates/controller.rb.erb
|
127
|
+
- generators/haml_scaffold/templates/helper.rb.erb
|
128
|
+
- generators/haml_scaffold/templates/layout.html.haml.erb
|
129
|
+
- generators/haml_scaffold/templates/stylesheet.sass
|
130
|
+
- generators/haml_scaffold/templates/view_edit.html.haml.erb
|
131
|
+
- generators/haml_scaffold/templates/view_index.html.haml.erb
|
132
|
+
- generators/haml_scaffold/templates/view_new.html.haml.erb
|
133
|
+
- generators/haml_scaffold/templates/view_show.html.haml.erb
|
134
|
+
- init.rb
|
135
|
+
- lib/haml_scaffold/version.rb
|
136
|
+
has_rdoc: true
|
137
|
+
homepage: http://haml-scaffold.rubyforge.org/
|
138
|
+
licenses: []
|
139
|
+
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options:
|
142
|
+
- --main
|
143
|
+
- README.rdoc
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
requirements: []
|
165
|
+
|
166
|
+
rubyforge_project: haml-scaffold
|
167
|
+
rubygems_version: 1.3.7
|
168
|
+
signing_key:
|
169
|
+
specification_version: 3
|
170
|
+
summary: Rails scaffolding with Haml rather than ERB
|
171
|
+
test_files: []
|
172
|
+
|