base-generators 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.2.3.textile +33 -0
- data/README.3.textile +35 -0
- data/README.textile +5 -31
- data/VERSION +1 -1
- data/base-generators.gemspec +35 -5
- data/lib/common_generators.rb +3 -0
- data/lib/generators/common.rb +15 -0
- data/lib/generators/common/layout/layout_generator.rb +90 -0
- data/lib/generators/common/layout/templates/_block.html.haml +9 -0
- data/lib/generators/common/layout/templates/_flashes.html.haml +5 -0
- data/lib/generators/common/layout/templates/_header.html.haml +16 -0
- data/lib/generators/common/layout/templates/_secondary_navigation.html.haml +12 -0
- data/lib/generators/common/layout/templates/_sidebar.html.haml +15 -0
- data/lib/generators/common/layout/templates/base_helper.rb +58 -0
- data/lib/generators/common/layout/templates/bootstrap.rake +23 -0
- data/lib/generators/common/layout/templates/compass_config.rb +14 -0
- data/lib/generators/common/layout/templates/layout.html.haml +28 -0
- data/lib/generators/common/layout/templates/settings.yml +12 -0
- data/lib/generators/common/scaffold/scaffold_generator.rb +122 -0
- data/lib/generators/common/scaffold/templates/controller.rb +7 -0
- data/lib/generators/common/scaffold/templates/helper.rb +2 -0
- data/lib/generators/common/scaffold/templates/migration.rb +15 -0
- data/lib/generators/common/scaffold/templates/model.rb +5 -0
- data/lib/generators/common/scaffold/templates/rspec/model.rb +9 -0
- data/lib/generators/common/scaffold/templates/views/_collection.html.haml +22 -0
- data/lib/generators/common/scaffold/templates/views/_form.html.haml +4 -0
- data/lib/generators/common/scaffold/templates/views/edit.html.haml +8 -0
- data/lib/generators/common/scaffold/templates/views/index.html.haml +7 -0
- data/lib/generators/common/scaffold/templates/views/index.js.haml +1 -0
- data/lib/generators/common/scaffold/templates/views/new.html.haml +7 -0
- data/lib/generators/common/scaffold/templates/views/show.html.haml +8 -0
- metadata +44 -5
data/README.2.3.textile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
h1. Using Generators On Rails 2.3
|
2
|
+
|
3
|
+
h2. Installation
|
4
|
+
|
5
|
+
Easy, dude.
|
6
|
+
<pre>
|
7
|
+
gem install base-generators
|
8
|
+
</pre>
|
9
|
+
|
10
|
+
or
|
11
|
+
<pre>
|
12
|
+
ruby script/plugin install git://github.com/lucasefe/base-generators.git
|
13
|
+
</pre>
|
14
|
+
|
15
|
+
h2. Generators
|
16
|
+
|
17
|
+
It provides two generators (so far)
|
18
|
+
|
19
|
+
h3. base_bootstrap
|
20
|
+
|
21
|
+
This generator copies all the templates and helper methods needed for the base_scaffold generator to work.
|
22
|
+
|
23
|
+
<pre>
|
24
|
+
ruby script/generate base_bootstrap layout_name
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
h3. base_scaffold
|
28
|
+
|
29
|
+
This generator provides a scaffold structure that implements "ajax":http://github.com/jquery/jquery/ "pagination":http://github.com/mislav/will_paginate, "search":http://github.com/binarylogic/searchlogic, and "base html style":http://github.com/pilu/web-app-theme. Most of the functionality is built with standard ruby gems. Clearly, I am not trying to reinvent the wheel, but to embrace our wonderful community.
|
30
|
+
|
31
|
+
<pre>
|
32
|
+
ruby script/generate base_scaffold Product name:string price:decimal notes:text enabled:boolean
|
33
|
+
</pre>
|
data/README.3.textile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
h1. Using Generators On Rails 3
|
2
|
+
|
3
|
+
h2. Installation
|
4
|
+
|
5
|
+
Add this to your Gemfile:
|
6
|
+
|
7
|
+
<pre>
|
8
|
+
gem "base-generators"
|
9
|
+
</pre>
|
10
|
+
|
11
|
+
and do a simple:
|
12
|
+
|
13
|
+
<pre>
|
14
|
+
bundle install
|
15
|
+
</pre>
|
16
|
+
|
17
|
+
h2. Generators
|
18
|
+
|
19
|
+
I have chosen not to go with the older base_ prefix, because it is too generic. Instead, the new prefix is common, so you get the following two creatures.
|
20
|
+
|
21
|
+
h3. common:layout
|
22
|
+
|
23
|
+
This generator copies all the templates and helper methods needed for the base_scaffold generator to work.
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
rails generate common:layout layout_name
|
27
|
+
</pre>
|
28
|
+
|
29
|
+
h3. common:scaffold
|
30
|
+
|
31
|
+
This generator provides a scaffold structure that implements "ajax":http://github.com/jquery/jquery/ "pagination":http://github.com/mislav/will_paginate, "search":http://github.com/binarylogic/searchlogic, and "base html style":http://github.com/pilu/web-app-theme. Most of the functionality is built with standard ruby gems. Clearly, I am not trying to reinvent the wheel, but to embrace our wonderful community.
|
32
|
+
|
33
|
+
<pre>
|
34
|
+
rails generate common:scaffold Product name:string price:decimal notes:text enabled:boolean
|
35
|
+
</pre>
|
data/README.textile
CHANGED
@@ -1,34 +1,9 @@
|
|
1
1
|
h1. BaseGenerators
|
2
2
|
|
3
|
-
BaseGenerators tries to ease the pain of starting a new app from scratch by automating tasks with generators.
|
3
|
+
BaseGenerators tries to ease the pain of starting a new app from scratch by automating tasks with generators. So far, it provides them for Rails 2.3 and Rails 3. Sadly, the interface for writing generators in Rails 3 has changed, so for that version everything is pretty different.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Easy, dude.
|
8
|
-
|
9
|
-
<pre>
|
10
|
-
ruby script/plugin install git://github.com/lucasefe/base-generators.git
|
11
|
-
</pre>
|
12
|
-
|
13
|
-
h2. Generators
|
14
|
-
|
15
|
-
It provides two generators (so far)
|
16
|
-
|
17
|
-
h3. base_bootstrap
|
18
|
-
|
19
|
-
This generator copies all the templates and helper methods needed for the base_scaffold generator to work.
|
20
|
-
|
21
|
-
<pre>
|
22
|
-
ruby script/generate base_bootstrap layout_name
|
23
|
-
</pre>
|
24
|
-
|
25
|
-
h3. base_scaffold
|
26
|
-
|
27
|
-
This generator provides a scaffold structure that implements "ajax":http://github.com/jquery/jquery/ "pagination":http://github.com/mislav/will_paginate, "search":http://github.com/binarylogic/searchlogic, and "base html style":http://github.com/pilu/web-app-theme. Most of the functionality is built with standard ruby gems. Clearly, I am not trying to reinvent the wheel, but to embrace our wonderful community.
|
28
|
-
|
29
|
-
<pre>
|
30
|
-
ruby script/generate base_scaffold Product name:string price:decimal notes:text enabled:boolean
|
31
|
-
</pre>
|
5
|
+
* "Using the generators on Rails 2.3":http://github.com/lucasefe/base-generators/blob/master/README.2.3.textile
|
6
|
+
* "Using the generators on Rails 3":http://github.com/lucasefe/base-generators/blob/master/README.3.textile
|
32
7
|
|
33
8
|
h2. Dependencies
|
34
9
|
|
@@ -49,8 +24,7 @@ h2. Dependencies
|
|
49
24
|
** "jrails":http://github.com/aaronchi/jrails/raw/master/javascripts/jrails.js
|
50
25
|
** "livequery":http://github.com/brandonaaron/livequery/raw/master/jquery.livequery.js
|
51
26
|
|
52
|
-
|
53
|
-
h2. PLUS: Easy bootstrap of your new app!
|
27
|
+
h2. PLUS: Easy bootstrap of your new app! (recommended only on Rails 2.3)
|
54
28
|
|
55
29
|
If your starting with a new app, then you can rely on my own rails template to install the dependencies.
|
56
30
|
*Warning*: Although it's base on other rails templates, it also includes my personal choices, so you may not agree with it.
|
@@ -63,4 +37,4 @@ h2. Disclaimer
|
|
63
37
|
|
64
38
|
This is a work in progress, so don't complain about it. If you don't like something, contribute to fix it.
|
65
39
|
|
66
|
-
(c) Copyright 2009 Lucas Florio.
|
40
|
+
(c) Copyright 2008-2009-2010 Lucas Florio. Do whatever you want. MIT licensed.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/base-generators.gemspec
CHANGED
@@ -5,19 +5,23 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{base-generators}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Lucas Efe"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-02}
|
13
13
|
s.description = %q{BaseGenerators tries to ease the pain of starting a new app from scratch by automating tasks with generators.}
|
14
14
|
s.email = %q{lucasefe@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"README.textile"
|
16
|
+
"README.2.3.textile",
|
17
|
+
"README.3.textile",
|
18
|
+
"README.textile"
|
17
19
|
]
|
18
20
|
s.files = [
|
19
21
|
".gitignore",
|
20
22
|
"MIT-LICENSE",
|
23
|
+
"README.2.3.textile",
|
24
|
+
"README.3.textile",
|
21
25
|
"README.textile",
|
22
26
|
"Rakefile",
|
23
27
|
"VERSION",
|
@@ -45,6 +49,32 @@ Gem::Specification.new do |s|
|
|
45
49
|
"generators/base_scaffold/templates/view_index.js.haml",
|
46
50
|
"generators/base_scaffold/templates/view_new.haml",
|
47
51
|
"generators/base_scaffold/templates/view_show.haml",
|
52
|
+
"lib/common_generators.rb",
|
53
|
+
"lib/generators/common.rb",
|
54
|
+
"lib/generators/common/layout/layout_generator.rb",
|
55
|
+
"lib/generators/common/layout/templates/_block.html.haml",
|
56
|
+
"lib/generators/common/layout/templates/_flashes.html.haml",
|
57
|
+
"lib/generators/common/layout/templates/_header.html.haml",
|
58
|
+
"lib/generators/common/layout/templates/_secondary_navigation.html.haml",
|
59
|
+
"lib/generators/common/layout/templates/_sidebar.html.haml",
|
60
|
+
"lib/generators/common/layout/templates/base_helper.rb",
|
61
|
+
"lib/generators/common/layout/templates/bootstrap.rake",
|
62
|
+
"lib/generators/common/layout/templates/compass_config.rb",
|
63
|
+
"lib/generators/common/layout/templates/layout.html.haml",
|
64
|
+
"lib/generators/common/layout/templates/settings.yml",
|
65
|
+
"lib/generators/common/scaffold/scaffold_generator.rb",
|
66
|
+
"lib/generators/common/scaffold/templates/controller.rb",
|
67
|
+
"lib/generators/common/scaffold/templates/helper.rb",
|
68
|
+
"lib/generators/common/scaffold/templates/migration.rb",
|
69
|
+
"lib/generators/common/scaffold/templates/model.rb",
|
70
|
+
"lib/generators/common/scaffold/templates/rspec/model.rb",
|
71
|
+
"lib/generators/common/scaffold/templates/views/_collection.html.haml",
|
72
|
+
"lib/generators/common/scaffold/templates/views/_form.html.haml",
|
73
|
+
"lib/generators/common/scaffold/templates/views/edit.html.haml",
|
74
|
+
"lib/generators/common/scaffold/templates/views/index.html.haml",
|
75
|
+
"lib/generators/common/scaffold/templates/views/index.js.haml",
|
76
|
+
"lib/generators/common/scaffold/templates/views/new.html.haml",
|
77
|
+
"lib/generators/common/scaffold/templates/views/show.html.haml",
|
48
78
|
"rails/init.rb",
|
49
79
|
"rails_template.rb",
|
50
80
|
"tasks/scaffold_it_tasks.rake",
|
@@ -55,7 +85,7 @@ Gem::Specification.new do |s|
|
|
55
85
|
s.homepage = %q{http://github.com/lucasefe/base-generators}
|
56
86
|
s.rdoc_options = ["--charset=UTF-8"]
|
57
87
|
s.require_paths = ["lib"]
|
58
|
-
s.rubygems_version = %q{1.3.6}
|
88
|
+
s.rubygems_version = %q{1.3.6.1}
|
59
89
|
s.summary = %q{Rails Generators using SearchLogic, Formtastic, jquery and many more.}
|
60
90
|
s.test_files = [
|
61
91
|
"test/scaffold_it_test.rb",
|
@@ -66,7 +96,7 @@ Gem::Specification.new do |s|
|
|
66
96
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
67
97
|
s.specification_version = 3
|
68
98
|
|
69
|
-
if Gem::Version.new(Gem::
|
99
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
100
|
s.add_runtime_dependency(%q<searchlogic>, [">= 2.4.19"])
|
71
101
|
s.add_runtime_dependency(%q<inherited_resources>, ["= 1.0.6"])
|
72
102
|
s.add_runtime_dependency(%q<formtastic>, ["= 0.9.8"])
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Common
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::Base #:nodoc:
|
6
|
+
def self.source_root
|
7
|
+
@_common_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'common', generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.banner
|
11
|
+
"#{$0} common:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'generators/common'
|
2
|
+
|
3
|
+
module Common
|
4
|
+
module Generators
|
5
|
+
class LayoutGenerator < Base
|
6
|
+
argument :layout_name,
|
7
|
+
:type => :string,
|
8
|
+
:banner => 'Layout name',
|
9
|
+
:default => 'application'
|
10
|
+
|
11
|
+
def copy_layout
|
12
|
+
template 'layout.html.haml', "app/views/layouts/#{layout_name}.html.haml"
|
13
|
+
template 'base_helper.rb', "app/helpers/#{layout_name}_helper.rb"
|
14
|
+
end
|
15
|
+
def copy_misc
|
16
|
+
template 'bootstrap.rake', "lib/tasks/bootstrap.rake"
|
17
|
+
template 'settings.yml', "config/settings.yml"
|
18
|
+
end
|
19
|
+
def copy_partials_to_common_directory
|
20
|
+
%w(
|
21
|
+
block
|
22
|
+
header
|
23
|
+
flashes
|
24
|
+
secondary_navigation
|
25
|
+
sidebar
|
26
|
+
).each do |partial|
|
27
|
+
template "_#{partial}.html.haml", "app/views/common/_#{partial}.html.haml"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
def create_initializers
|
31
|
+
template 'compass_config.rb', 'config/compass.rb'
|
32
|
+
initializer('load_settings.rb', %q(APP_CONFIG = YAML.load(ERB.new(File.read("#{Rails.root}/config/settings.yml")).result)[Rails.env].symbolize_keys))
|
33
|
+
initializer 'requires.rb',
|
34
|
+
%q{
|
35
|
+
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
|
36
|
+
require f
|
37
|
+
end
|
38
|
+
}
|
39
|
+
|
40
|
+
initializer('compass.rb', %q(
|
41
|
+
# encoding: utf-8
|
42
|
+
require 'compass'
|
43
|
+
rails_root = (defined?(Rails) ? Rails.root : Rails.root).to_s
|
44
|
+
Compass.add_project_configuration(File.join(rails_root, "config", "compass.rb"))
|
45
|
+
Compass.configure_sass_plugin!
|
46
|
+
Compass.handle_configuration_change!
|
47
|
+
))
|
48
|
+
end
|
49
|
+
def delete_unneeded_files
|
50
|
+
run "rm README"
|
51
|
+
run "rm public/index.html"
|
52
|
+
run "rm public/favicon.ico"
|
53
|
+
run "rm public/robots.txt"
|
54
|
+
run "rm -f public/javascripts/*"
|
55
|
+
|
56
|
+
run "cp config/database.yml config/database.yml.example"
|
57
|
+
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
|
58
|
+
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
|
59
|
+
end
|
60
|
+
def set_dependencies
|
61
|
+
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
|
62
|
+
run "curl -L http://github.com/malsup/form/raw/master/jquery.form.js?v2.40 > public/javascripts/jquery.form.js"
|
63
|
+
run "curl -L http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js > public/javascripts/jquery-ui.js"
|
64
|
+
run "curl -L http://github.com/brandonaaron/livequery/raw/master/jquery.livequery.js > public/javascripts/jquery.livequery.js"
|
65
|
+
|
66
|
+
gem "inherited_resources", ">= 1.1.0"
|
67
|
+
gem 'formtastic', :branch => 'rails3', :git => 'git://github.com/justinfrench/formtastic.git'
|
68
|
+
gem "web-app-theme", :git => "git://github.com/lucasefe/web-app-theme.git"
|
69
|
+
gem 'validation_reflection'
|
70
|
+
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => 'rails3'
|
71
|
+
gem 'show_for'
|
72
|
+
|
73
|
+
gem 'webrat', :group => :test
|
74
|
+
gem "cucumber", ">= 0.6.2", :group => :test
|
75
|
+
gem 'faker', :group => :test
|
76
|
+
gem 'factory_girl', :group => :test
|
77
|
+
|
78
|
+
gem "haml", "3.0.0.rc.2"
|
79
|
+
gem 'compass', '0.10.0.rc4'
|
80
|
+
gem 'compass-960-plugin'
|
81
|
+
|
82
|
+
in_root { run "bundle install" }
|
83
|
+
|
84
|
+
generate("responders_install")
|
85
|
+
generate("web_app_theme:theme --no-layout --theme=reidb-greenish")
|
86
|
+
generate("formtastic:install")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#header
|
2
|
+
%h1= link_to APP_CONFIG[:site_name]
|
3
|
+
#user-navigation
|
4
|
+
%ul
|
5
|
+
%li= link_to "Profile"
|
6
|
+
%li.logout= link_to "Logout"
|
7
|
+
.clear
|
8
|
+
#main-navigation
|
9
|
+
%ul
|
10
|
+
%li= link_to "Dashboard"
|
11
|
+
%li= link_to "Menu 1"
|
12
|
+
%li= link_to "Menu 2"
|
13
|
+
%li= link_to "Menu 3"
|
14
|
+
.clear
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- show_content_if yield(:actions) do |content|
|
2
|
+
.block
|
3
|
+
%h3.toggle-block Actions
|
4
|
+
.sidebar-block
|
5
|
+
%ul.navigation
|
6
|
+
= content
|
7
|
+
.clear
|
8
|
+
|
9
|
+
- show_content_if yield(:search) do |content|
|
10
|
+
.block
|
11
|
+
%h3.toggle-block
|
12
|
+
%a{:title => "Click to show/hide search box"} Search
|
13
|
+
.sidebar-block{:style => 'display:none;'}
|
14
|
+
= content
|
15
|
+
.clear
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module <%= layout_name.classify %>Helper
|
2
|
+
mattr_accessor :default_secondary_navigation_path
|
3
|
+
@@default_secondary_navigation_path = 'common/secondary_navigation'
|
4
|
+
def title(page_title, show_title = true)
|
5
|
+
@content_for_title = page_title.to_s
|
6
|
+
@show_title = show_title
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_title?
|
10
|
+
@show_title
|
11
|
+
end
|
12
|
+
def nav_link(title, url, options = {})
|
13
|
+
link = link_to(title, url)
|
14
|
+
# solo si LockDown me deja!
|
15
|
+
unless link.blank?
|
16
|
+
# Activo el item?
|
17
|
+
options = params[:controller].include?(options[:controller] || title.underscore) ? {:class => "active"} : {}
|
18
|
+
haml_tag :li, options do
|
19
|
+
haml_concat link
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def stylesheet(*args)
|
24
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def javascript(*args)
|
28
|
+
content_for(:head) { javascript_include_tag(*args) }
|
29
|
+
end
|
30
|
+
def show_content_if(content, &block)
|
31
|
+
if content.present?
|
32
|
+
yield(content)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def sidebar_link(name, options = {}, html_options = nil)
|
36
|
+
content_tag(:li, link_to(name, options, html_options))
|
37
|
+
end
|
38
|
+
def navigation_block(nav = nil)
|
39
|
+
render(:partial => (nav||@@default_secondary_navigation_path))
|
40
|
+
end
|
41
|
+
def flashes
|
42
|
+
render :partial => 'common/flashes'
|
43
|
+
end
|
44
|
+
def block(title, options = {}, &block)
|
45
|
+
content = capture(&block)
|
46
|
+
out = render :partial => 'common/block', :locals => {
|
47
|
+
:title => title,
|
48
|
+
:content => content,
|
49
|
+
:options => options
|
50
|
+
}
|
51
|
+
out
|
52
|
+
end
|
53
|
+
def block_form(title, &block)
|
54
|
+
content = capture(&block)
|
55
|
+
out = render :partial => 'common/block_form', :locals => { :title => title, :content => content}
|
56
|
+
out
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :app do
|
2
|
+
namespace :development do
|
3
|
+
desc "Resets the environment!"
|
4
|
+
task :reset => [ "db:drop", "db:create", "db:migrate", :bootstrap ]
|
5
|
+
desc "Bootstrap"
|
6
|
+
task :bootstrap => [ :environment ]
|
7
|
+
end
|
8
|
+
namespace :staging do
|
9
|
+
desc "Resets the environment!"
|
10
|
+
task :reset => [ "db:drop", "db:create", "db:migrate", :bootstrap ]
|
11
|
+
desc "Bootstrap"
|
12
|
+
task :bootstrap => [ :environment ]
|
13
|
+
end
|
14
|
+
namespace :production do
|
15
|
+
desc "Resets the environment!"
|
16
|
+
task :reset => [ "db:drop", "db:create", "db:migrate", :bootstrap ]
|
17
|
+
desc "Bootstrap"
|
18
|
+
task :bootstrap => [ :environment ]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Alias de app:development:reset"
|
23
|
+
task :adr => [ "app:development:reset" ]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This configuration file works with both the Compass command line tool and within Rails.
|
2
|
+
require 'ninesixty'
|
3
|
+
# Require any additional compass plugins here.
|
4
|
+
|
5
|
+
project_type = :rails
|
6
|
+
project_path = Rails.root if defined?(Rails.root)
|
7
|
+
# Set this to the root of your project when deployed:
|
8
|
+
http_path = "/"
|
9
|
+
css_dir = "public/stylesheets/compiled"
|
10
|
+
sass_dir = "app/stylesheets"
|
11
|
+
environment = Compass::AppIntegration::Rails.env
|
12
|
+
# To enable relative paths to assets via compass helper functions. Uncomment:
|
13
|
+
# relative_assets = true
|
14
|
+
preferred_syntax = :sass
|
@@ -0,0 +1,28 @@
|
|
1
|
+
!!! Strict
|
2
|
+
%html{ :lang => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
|
3
|
+
%head
|
4
|
+
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" }
|
5
|
+
%title
|
6
|
+
= h(yield(:title) || APP_CONFIG[:site_name] || "APP Name")
|
7
|
+
= stylesheet_link_tag 'web_app_theme', "themes/reidb-greenish/style"
|
8
|
+
= stylesheet_link_tag 'formtastic', "formtastic_changes"
|
9
|
+
= javascript_include_tag 'jquery'
|
10
|
+
= javascript_include_tag 'jquery-ui'
|
11
|
+
= javascript_include_tag 'jquery.form'
|
12
|
+
= javascript_include_tag 'jrails'
|
13
|
+
= javascript_include_tag 'jquery.livequery'
|
14
|
+
= yield(:head)
|
15
|
+
= javascript_include_tag 'application'
|
16
|
+
%body
|
17
|
+
#container
|
18
|
+
= render :partial => 'common/header'
|
19
|
+
#wrapper
|
20
|
+
#main
|
21
|
+
= yield
|
22
|
+
#footer
|
23
|
+
.block
|
24
|
+
%p
|
25
|
+
Copyright © 2009 Your Site.
|
26
|
+
#sidebar
|
27
|
+
= render :partial => 'common/sidebar'
|
28
|
+
.clear
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'generators/common'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails/generators/generated_attribute'
|
4
|
+
|
5
|
+
module Common
|
6
|
+
module Generators
|
7
|
+
class ScaffoldGenerator < Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
no_tasks { attr_accessor :model_name, :model_attributes, :controller_actions }
|
10
|
+
|
11
|
+
class_option :skip_model, :desc => 'Don\'t generate a model or migration file.', :type => :boolean
|
12
|
+
class_option :skip_controller, :desc => 'Don\'t generate controller, helper, or views.', :type => :boolean
|
13
|
+
class_option :skip_migration, :desc => 'Dont generate migration file for model.', :type => :boolean
|
14
|
+
|
15
|
+
argument :model_name, :type => :string, :required => true, :banner => 'ModelName'
|
16
|
+
argument :args_for_c_m, :type => :array, :default => [], :banner => 'controller_actions and model:attributes'
|
17
|
+
|
18
|
+
# complete:scaffold Admin:User login:string email:string time_zone:string
|
19
|
+
|
20
|
+
def initialize(*args, &block)
|
21
|
+
super
|
22
|
+
@controller_actions = []
|
23
|
+
args_for_c_m.each do |arg|
|
24
|
+
if arg == '!'
|
25
|
+
options[:invert] = true
|
26
|
+
elsif arg.include?(':')
|
27
|
+
model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
|
28
|
+
else
|
29
|
+
@controller_actions << arg
|
30
|
+
@controller_actions << 'create' if arg == 'new'
|
31
|
+
@controller_actions << 'update' if arg == 'edit'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
if options.invert? || @controller_actions.empty?
|
35
|
+
@controller_actions = all_actions - @controller_actions
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def create_model
|
39
|
+
unless options.skip_model?
|
40
|
+
template 'model.rb', "app/models/#{singular_name_path}.rb"
|
41
|
+
template "rspec/model.rb", "spec/models/#{singular_name_path}_spec.rb"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
def create_controller
|
45
|
+
unless options.skip_controller?
|
46
|
+
template 'controller.rb', "app/controllers/#{plural_name_path}_controller.rb"
|
47
|
+
template 'helper.rb', "app/helpers/#{plural_name_path}_helper.rb"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
def create_views
|
51
|
+
unless options.skip_controller?
|
52
|
+
@controller_actions.each do |action|
|
53
|
+
if %w[index show new edit].include?(action) # Actions with templates
|
54
|
+
template "views/#{action}.html.haml", "app/views/#{plural_name_path}/#{action}.html.haml"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
template "views/_form.html.haml", "app/views/#{plural_name_path}/_form.html.haml"
|
58
|
+
template "views/_collection.html.haml", "app/views/#{plural_name_path}/_#{collection_name}.html.haml"
|
59
|
+
route "resources #{plural_name.to_sym.inspect}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
def create_migrations
|
63
|
+
unless options.skip_model? || options.skip_migration?
|
64
|
+
migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def namespaced?
|
70
|
+
class_name.include?("::")
|
71
|
+
end
|
72
|
+
# Admin::User
|
73
|
+
def class_name
|
74
|
+
model_name.camelize
|
75
|
+
end
|
76
|
+
def plural_class_name
|
77
|
+
class_name.pluralize
|
78
|
+
end
|
79
|
+
# admin/user
|
80
|
+
def singular_name_path
|
81
|
+
model_name.gsub("::", "/").underscore
|
82
|
+
end
|
83
|
+
# user
|
84
|
+
def singular_name
|
85
|
+
singular_name_path.gsub("/", "_")
|
86
|
+
end
|
87
|
+
# admin/users
|
88
|
+
def plural_name
|
89
|
+
singular_name.pluralize
|
90
|
+
end
|
91
|
+
# users
|
92
|
+
def plural_name_path
|
93
|
+
singular_name_path.pluralize
|
94
|
+
end
|
95
|
+
def instance_name
|
96
|
+
model_name.split("::").last.underscore
|
97
|
+
end
|
98
|
+
def collection_name
|
99
|
+
instance_name.pluralize
|
100
|
+
end
|
101
|
+
def model_attributes
|
102
|
+
@model_attributes ||= []
|
103
|
+
end
|
104
|
+
def all_actions
|
105
|
+
%w[ index show new create edit update destroy ]
|
106
|
+
end
|
107
|
+
def all_partials
|
108
|
+
%w[ _collection ]
|
109
|
+
end
|
110
|
+
def spec_helper_path
|
111
|
+
"/.." * class_name.split("::").size + 'spec_helper'
|
112
|
+
end
|
113
|
+
def self.next_migration_number(dirname) #:nodoc:
|
114
|
+
if ActiveRecord::Base.timestamped_migrations
|
115
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
116
|
+
else
|
117
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Create<%= plural_class_name.gsub("::", "") %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= plural_name %>, :force => true do |t|
|
4
|
+
<% model_attributes.each do |attribute| -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :<%= plural_name %>
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#results
|
2
|
+
%table.table
|
3
|
+
%tr
|
4
|
+
<% for attribute in model_attributes -%>
|
5
|
+
%th<%= (attribute == model_attributes.first) ? ".first" : "" %> <%= attribute.name.humanize %>
|
6
|
+
<% end -%>
|
7
|
+
%th.last
|
8
|
+
- <%= collection_name %>.each do |<%= instance_name %>|
|
9
|
+
%tr{:class => cycle('odd', 'even')}
|
10
|
+
<%- for attribute in model_attributes %>
|
11
|
+
%td= h <%= instance_name %>.<%= attribute.name %>
|
12
|
+
<%- end -%>
|
13
|
+
%td.last
|
14
|
+
= link_to 'Show', resource_url(<%= instance_name %>)
|
15
|
+
= link_to 'Edit', edit_resource_url(<%= instance_name %>)
|
16
|
+
= link_to 'Destroy', resource_url(<%= instance_name %>), :confirm => 'Are you sure?', :method => :delete
|
17
|
+
|
18
|
+
.actions-bar
|
19
|
+
= will_paginate <%= collection_name %>
|
20
|
+
.clear
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
= block "Editing <%= singular_name.underscore.humanize %>" do
|
2
|
+
- semantic_form_for(@<%= instance_name %>, :url => resource_url, :html => { :method => :put}) do |f|
|
3
|
+
= render :partial => "form", :locals => { :f => f }
|
4
|
+
= f.buttons
|
5
|
+
|
6
|
+
- content_for :actions do
|
7
|
+
= sidebar_link 'Show', resource_url
|
8
|
+
= sidebar_link 'View All', collection_url
|
@@ -0,0 +1,7 @@
|
|
1
|
+
- javascript 'common'
|
2
|
+
|
3
|
+
= block '<%= plural_name.underscore.humanize %>' do
|
4
|
+
= render :partial => '<%= collection_name %>', :locals => { :<%= collection_name %> => @<%= collection_name %> }
|
5
|
+
|
6
|
+
- content_for :actions do
|
7
|
+
= sidebar_link 'New <%= singular_name.underscore.humanize %>', new_resource_url
|
@@ -0,0 +1 @@
|
|
1
|
+
= render :partial => '<%= collection_name %>', :locals => { :<%= collection_name %> => @<%= collection_name %> }
|
@@ -0,0 +1,7 @@
|
|
1
|
+
= block "New <%= singular_name.underscore.humanize %>" do
|
2
|
+
- semantic_form_for(@<%= instance_name %>, :url => collection_url) do |f|
|
3
|
+
= render :partial => "form", :locals => { :f => f }
|
4
|
+
= f.buttons
|
5
|
+
|
6
|
+
- content_for :actions do
|
7
|
+
= sidebar_link 'View All', collection_url
|
@@ -0,0 +1,8 @@
|
|
1
|
+
= block "<%= singular_name.underscore.humanize %>" do
|
2
|
+
= show_for @<%= singular_name %> do |a|
|
3
|
+
<% for attribute in model_attributes %>
|
4
|
+
= a.attribute :<%= attribute.name %>
|
5
|
+
<% end -%>
|
6
|
+
- content_for :actions do
|
7
|
+
= sidebar_link 'Edit', edit_resource_url
|
8
|
+
= sidebar_link 'View All', collection_url
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Lucas Efe
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-02 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: searchlogic
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -35,6 +36,7 @@ dependencies:
|
|
35
36
|
name: inherited_resources
|
36
37
|
prerelease: false
|
37
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
38
40
|
requirements:
|
39
41
|
- - "="
|
40
42
|
- !ruby/object:Gem::Version
|
@@ -49,6 +51,7 @@ dependencies:
|
|
49
51
|
name: formtastic
|
50
52
|
prerelease: false
|
51
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
52
55
|
requirements:
|
53
56
|
- - "="
|
54
57
|
- !ruby/object:Gem::Version
|
@@ -63,6 +66,7 @@ dependencies:
|
|
63
66
|
name: validation_reflection
|
64
67
|
prerelease: false
|
65
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
66
70
|
requirements:
|
67
71
|
- - "="
|
68
72
|
- !ruby/object:Gem::Version
|
@@ -77,6 +81,7 @@ dependencies:
|
|
77
81
|
name: show_for
|
78
82
|
prerelease: false
|
79
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
80
85
|
requirements:
|
81
86
|
- - "="
|
82
87
|
- !ruby/object:Gem::Version
|
@@ -91,6 +96,7 @@ dependencies:
|
|
91
96
|
name: will_paginate
|
92
97
|
prerelease: false
|
93
98
|
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
94
100
|
requirements:
|
95
101
|
- - "="
|
96
102
|
- !ruby/object:Gem::Version
|
@@ -105,6 +111,7 @@ dependencies:
|
|
105
111
|
name: haml
|
106
112
|
prerelease: false
|
107
113
|
requirement: &id007 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
108
115
|
requirements:
|
109
116
|
- - "="
|
110
117
|
- !ruby/object:Gem::Version
|
@@ -122,10 +129,14 @@ executables: []
|
|
122
129
|
extensions: []
|
123
130
|
|
124
131
|
extra_rdoc_files:
|
132
|
+
- README.2.3.textile
|
133
|
+
- README.3.textile
|
125
134
|
- README.textile
|
126
135
|
files:
|
127
136
|
- .gitignore
|
128
137
|
- MIT-LICENSE
|
138
|
+
- README.2.3.textile
|
139
|
+
- README.3.textile
|
129
140
|
- README.textile
|
130
141
|
- Rakefile
|
131
142
|
- VERSION
|
@@ -153,6 +164,32 @@ files:
|
|
153
164
|
- generators/base_scaffold/templates/view_index.js.haml
|
154
165
|
- generators/base_scaffold/templates/view_new.haml
|
155
166
|
- generators/base_scaffold/templates/view_show.haml
|
167
|
+
- lib/common_generators.rb
|
168
|
+
- lib/generators/common.rb
|
169
|
+
- lib/generators/common/layout/layout_generator.rb
|
170
|
+
- lib/generators/common/layout/templates/_block.html.haml
|
171
|
+
- lib/generators/common/layout/templates/_flashes.html.haml
|
172
|
+
- lib/generators/common/layout/templates/_header.html.haml
|
173
|
+
- lib/generators/common/layout/templates/_secondary_navigation.html.haml
|
174
|
+
- lib/generators/common/layout/templates/_sidebar.html.haml
|
175
|
+
- lib/generators/common/layout/templates/base_helper.rb
|
176
|
+
- lib/generators/common/layout/templates/bootstrap.rake
|
177
|
+
- lib/generators/common/layout/templates/compass_config.rb
|
178
|
+
- lib/generators/common/layout/templates/layout.html.haml
|
179
|
+
- lib/generators/common/layout/templates/settings.yml
|
180
|
+
- lib/generators/common/scaffold/scaffold_generator.rb
|
181
|
+
- lib/generators/common/scaffold/templates/controller.rb
|
182
|
+
- lib/generators/common/scaffold/templates/helper.rb
|
183
|
+
- lib/generators/common/scaffold/templates/migration.rb
|
184
|
+
- lib/generators/common/scaffold/templates/model.rb
|
185
|
+
- lib/generators/common/scaffold/templates/rspec/model.rb
|
186
|
+
- lib/generators/common/scaffold/templates/views/_collection.html.haml
|
187
|
+
- lib/generators/common/scaffold/templates/views/_form.html.haml
|
188
|
+
- lib/generators/common/scaffold/templates/views/edit.html.haml
|
189
|
+
- lib/generators/common/scaffold/templates/views/index.html.haml
|
190
|
+
- lib/generators/common/scaffold/templates/views/index.js.haml
|
191
|
+
- lib/generators/common/scaffold/templates/views/new.html.haml
|
192
|
+
- lib/generators/common/scaffold/templates/views/show.html.haml
|
156
193
|
- rails/init.rb
|
157
194
|
- rails_template.rb
|
158
195
|
- tasks/scaffold_it_tasks.rake
|
@@ -169,6 +206,7 @@ rdoc_options:
|
|
169
206
|
require_paths:
|
170
207
|
- lib
|
171
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
172
210
|
requirements:
|
173
211
|
- - ">="
|
174
212
|
- !ruby/object:Gem::Version
|
@@ -176,6 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
214
|
- 0
|
177
215
|
version: "0"
|
178
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
179
218
|
requirements:
|
180
219
|
- - ">="
|
181
220
|
- !ruby/object:Gem::Version
|
@@ -185,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
224
|
requirements: []
|
186
225
|
|
187
226
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.3.6
|
227
|
+
rubygems_version: 1.3.6.1
|
189
228
|
signing_key:
|
190
229
|
specification_version: 3
|
191
230
|
summary: Rails Generators using SearchLogic, Formtastic, jquery and many more.
|