playmo 0.0.6 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -0
- data/Gemfile +1 -1
- data/README.md +9 -45
- data/TODO.md +65 -9
- data/bin/playmo +6 -0
- data/lib/generators/rails/controller_generator.rb +5 -0
- data/lib/generators/rails/layout_generator.rb +26 -0
- data/lib/generators/rails/scaffold_controller_generator.rb +13 -0
- data/lib/generators/rails/templates/controller.rb +11 -0
- data/lib/generators/rails/templates/layout.html.erb +46 -0
- data/lib/generators/rails/templates/layout.html.haml +26 -0
- data/lib/generators/rails/templates/layout.html.slim +26 -0
- data/lib/generators/rails/templates/scaffold_controller.rb +56 -0
- data/lib/playmo.rb +45 -7
- data/lib/playmo/answer.rb +18 -0
- data/lib/playmo/choice.rb +52 -0
- data/lib/playmo/cli.rb +25 -0
- data/lib/playmo/cookbook.rb +83 -0
- data/lib/playmo/event.rb +7 -0
- data/lib/playmo/options.rb +17 -0
- data/lib/playmo/question.rb +59 -0
- data/lib/playmo/recipe.rb +50 -0
- data/lib/playmo/recipes/_/sample_recipe.rb +46 -0
- data/lib/playmo/recipes/application_controller_recipe.rb +24 -0
- data/lib/playmo/recipes/application_helper_recipe.rb +18 -0
- data/lib/playmo/recipes/assets_recipe.rb +19 -0
- data/lib/playmo/recipes/can_can_recipe.rb +0 -0
- data/lib/playmo/recipes/capistrano_recipe.rb +25 -0
- data/lib/playmo/recipes/compass_recipe.rb +19 -0
- data/lib/playmo/recipes/congrats_recipe.rb +20 -0
- data/lib/playmo/recipes/devise_recipe.rb +172 -0
- data/lib/playmo/recipes/forms_recipe.rb +42 -0
- data/lib/playmo/recipes/git_recipe.rb +31 -0
- data/lib/playmo/recipes/home_controller_recipe.rb +86 -0
- data/lib/playmo/recipes/javascript_framework_recipe.rb +69 -0
- data/lib/playmo/recipes/layout_recipe.rb +21 -0
- data/lib/playmo/recipes/markup_recipe.rb +34 -0
- data/lib/playmo/recipes/rspec_recipe.rb +25 -0
- data/lib/playmo/recipes/rvm_recipe.rb +17 -0
- data/lib/playmo/recipes/setup_database_recipe.rb +21 -0
- data/lib/playmo/recipes/templates/application_controller_recipe/application_controller.rb +54 -0
- data/lib/playmo/recipes/templates/application_controller_recipe/internal_error.html.erb +5 -0
- data/lib/playmo/recipes/templates/application_controller_recipe/not_found.html.erb +5 -0
- data/lib/playmo/recipes/templates/application_helper_recipe/application_helper.rb +118 -0
- data/lib/playmo/recipes/templates/assets_recipe/images/bg.jpg +0 -0
- data/lib/playmo/recipes/templates/assets_recipe/images/input-bg.gif +0 -0
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/application.css.scss +29 -0
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/media.css.scss +0 -0
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_constants.css.scss +11 -0
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_forms.css.scss +134 -0
- data/{stylesheets/_playmo_rails.sass → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_html5-boilerplate.css.scss} +1 -1
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_layout.css.scss +264 -0
- data/{templates/project/playmo/playmo.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_overrides.css.scss} +14 -23
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/_simple_form.css.scss +7 -0
- data/{stylesheets/playmo-rails/_fonts.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_fonts.css.scss} +5 -6
- data/{stylesheets/playmo-rails/_helpers.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_helpers.css.scss} +6 -1
- data/{stylesheets/playmo-rails/_media.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_media.css.scss} +10 -9
- data/lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_reset.css.scss +47 -0
- data/{stylesheets/playmo-rails/_styles.scss → lib/playmo/recipes/templates/assets_recipe/stylesheets/partials/html5-boilerplate/_styles.css.scss} +24 -24
- data/lib/playmo/recipes/templates/capistrano_recipe/.gitkeep +0 -0
- data/lib/playmo/recipes/templates/devise_recipe/.gitkeep +0 -0
- data/lib/playmo/recipes/templates/forms_recipe/.gitkeep +0 -0
- data/lib/playmo/recipes/templates/home_controller_recipe/_sidebar.html.erb +3 -0
- data/lib/playmo/recipes/templates/layout_recipe/application.html.erb +40 -0
- data/lib/playmo/recipes/templates/rspec_recipe/.gitkeep +0 -0
- data/lib/playmo/recipes/templates/rvm_recipe/.gitkeep +0 -0
- data/lib/playmo/silent.rb +17 -0
- data/playmo.gemspec +6 -2
- data/spec/cookbook_spec.rb +23 -0
- data/spec/recipes/home_controller_recipe_spec.rb +13 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/.gitkeep +0 -0
- metadata +144 -79
- data/lib/app/helpers/playmo_helper.rb +0 -54
- data/lib/generators/playmo/USAGE +0 -8
- data/lib/generators/playmo/install_generator.rb +0 -166
- data/lib/generators/playmo/templates/application.html.erb +0 -56
- data/lib/generators/playmo/templates/application_controller.rb +0 -9
- data/lib/generators/playmo/templates/application_helper.rb +0 -21
- data/lib/generators/playmo/templates/assets.yml +0 -32
- data/lib/generators/playmo/templates/deploy.rb +0 -50
- data/lib/generators/playmo/templates/jquery/jquery-1.5.2.min.js +0 -16
- data/lib/generators/playmo/templates/jquery/rails.js +0 -157
- data/lib/generators/playmo/templates/mootools/mootools-core-1.3.1.js +0 -485
- data/lib/generators/playmo/templates/mootools/mootools-more-1.3.1.1.js +0 -741
- data/lib/generators/playmo/templates/mootools/rails.js +0 -161
- data/lib/generators/playmo/templates/tasks/assets.rake +0 -10
- data/lib/generators/playmo/templates/tasks/sass.rake +0 -8
- data/stylesheets/playmo-rails/_handheld.scss +0 -8
- data/stylesheets/playmo-rails/_reset.scss +0 -56
- data/templates/project/boilerplate/css/handheld.scss +0 -7
- data/templates/project/boilerplate/css/style.scss +0 -141
- data/templates/project/boilerplate/files/apple-touch-icon.png +0 -0
- data/templates/project/boilerplate/files/crossdomain.xml +0 -25
- data/templates/project/boilerplate/files/favicon.ico +0 -0
- data/templates/project/boilerplate/files/robots.txt +0 -5
- data/templates/project/boilerplate/js/libs/dd_belatedpng.js +0 -13
- data/templates/project/boilerplate/js/libs/modernizr-1.7.min.js +0 -2
- data/templates/project/google/google.yml +0 -22
- data/templates/project/manifest.rb +0 -34
- data/templates/project/playmo/article.scss +0 -69
- data/templates/project/playmo/icons/outgoing.png +0 -0
- data/templates/project/rails/public/stylesheets/layout.scss +0 -20
- data/templates/project/rails/public/stylesheets/print.scss +0 -11
- data/templates/project/rails/public/stylesheets/screen.scss +0 -14
- data/templates/project/rails/public/stylesheets/wysiwyg.scss +0 -19
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class CongratsRecipe < Playmo::Recipe
|
|
4
|
+
def setup
|
|
5
|
+
# TODO: need silently block
|
|
6
|
+
Playmo::Event.events.listen(:after_playmo_install) do |event_data|
|
|
7
|
+
say "\n"
|
|
8
|
+
say "*******************************************************************"
|
|
9
|
+
say "Congratulations! All files has been installed successfully."
|
|
10
|
+
say "You can read some docs on https://github.com/tanraya/playmo"
|
|
11
|
+
say "\n"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Write down this recipe to our Cookbook if it's available
|
|
19
|
+
require File.dirname(__FILE__) + '/git_recipe'
|
|
20
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::GitRecipe, Playmo::Recipes::CongratsRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class DeviseRecipe < Playmo::Recipe
|
|
4
|
+
source_root File.expand_path('../templates/devise_recipe', __FILE__)
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
question "Would you like to use Devise in this project?" => :install_devise
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def install_devise
|
|
11
|
+
gem 'devise'
|
|
12
|
+
|
|
13
|
+
Event.events.listen(:after_install) do |event_data|
|
|
14
|
+
# Generate Devise stuff
|
|
15
|
+
generate "devise:install"
|
|
16
|
+
generate "devise User"
|
|
17
|
+
generate "devise:views"
|
|
18
|
+
|
|
19
|
+
# Add sign_up/login links into layout
|
|
20
|
+
add_layout_links
|
|
21
|
+
|
|
22
|
+
# Process Devise views to choosen markup
|
|
23
|
+
process_views
|
|
24
|
+
|
|
25
|
+
# Add :name accessor to default accessors
|
|
26
|
+
# Also add some specific methods
|
|
27
|
+
gsub_file 'app/models/user.rb', 'attr_accessible :email, :password, :password_confirmation, :remember_me' do
|
|
28
|
+
<<-CONTENT.gsub(/^ {12}/, '')
|
|
29
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
|
|
30
|
+
cattr_accessor :current
|
|
31
|
+
|
|
32
|
+
# Return user name or user name from email address
|
|
33
|
+
def username
|
|
34
|
+
name.blank? ? email.match(/^[^@]+/)[0] : name
|
|
35
|
+
end
|
|
36
|
+
CONTENT
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Create migration that adds name field to users table
|
|
40
|
+
filename = "db/migrate/#{(Time.now - 3600).strftime("%Y%m%d%H%M%S")}_add_name_to_users.rb"
|
|
41
|
+
|
|
42
|
+
create_file filename, <<-CONTENT.gsub(/^ {12}/, '')
|
|
43
|
+
class AddNameToUsers < ActiveRecord::Migration
|
|
44
|
+
def change
|
|
45
|
+
add_column :users, :name, :string
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
CONTENT
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Create default user
|
|
52
|
+
append_to_file 'db/seeds.rb' do
|
|
53
|
+
<<-CONTENT.gsub(/^ {12}/, '')
|
|
54
|
+
user = User.create!(
|
|
55
|
+
:email => 'johndoe@example.com',
|
|
56
|
+
:password => 'secret',
|
|
57
|
+
:password_confirmation => 'secret'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
user2 = User.create!(
|
|
61
|
+
:email => 'annadoe@example.com',
|
|
62
|
+
:password => 'secret',
|
|
63
|
+
:password_confirmation => 'secret'
|
|
64
|
+
)
|
|
65
|
+
CONTENT
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
# Add links into layout
|
|
73
|
+
def add_layout_links
|
|
74
|
+
case retrieve(:markup)
|
|
75
|
+
when :erb then add_layout_links_with_erb
|
|
76
|
+
when :haml then add_layout_links_with_haml
|
|
77
|
+
when :slim then add_layout_links_with_slim
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Process Devise views to choosen markup
|
|
82
|
+
def process_views
|
|
83
|
+
case retrieve(:markup)
|
|
84
|
+
when :haml then process_views_with_haml
|
|
85
|
+
when :slim then process_views_with_slim
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def add_layout_links_with_erb
|
|
90
|
+
gsub_file 'app/views/layouts/application.html.erb', '</header>' do
|
|
91
|
+
<<-CONTENT.gsub(/^ {10}/, '')
|
|
92
|
+
<div id="user-info">
|
|
93
|
+
<ul>
|
|
94
|
+
<% if user_signed_in? %>
|
|
95
|
+
<li>
|
|
96
|
+
Hello, Dear <strong><%= current_user.username %></strong>!
|
|
97
|
+
Maybe, you want to <%= link_to 'logout', destroy_user_session_path %>?
|
|
98
|
+
</li>
|
|
99
|
+
<% else %>
|
|
100
|
+
<li>
|
|
101
|
+
Hello Guest, maybe you want to <%= link_to 'Join us', new_user_registration_path %> or <%= link_to 'login', new_user_session_path %>?
|
|
102
|
+
</li>
|
|
103
|
+
<% end %>
|
|
104
|
+
</ul>
|
|
105
|
+
</div>
|
|
106
|
+
</header>
|
|
107
|
+
CONTENT
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def add_layout_links_with_haml
|
|
112
|
+
gsub_file 'app/views/layouts/application.html.haml', ' #body' do
|
|
113
|
+
<<-'CONTENT'.gsub(/^ {6}/, '')
|
|
114
|
+
#user-info
|
|
115
|
+
%ul
|
|
116
|
+
- if user_signed_in?
|
|
117
|
+
%li
|
|
118
|
+
Hello, Dear
|
|
119
|
+
= succeed "!" do
|
|
120
|
+
%strong= current_user.username
|
|
121
|
+
Maybe, you want to #{link_to 'logout', destroy_user_session_path}?
|
|
122
|
+
- else
|
|
123
|
+
%li
|
|
124
|
+
Hello Guest, maybe you want to #{link_to 'Join us', new_user_registration_path} or #{link_to 'login', new_user_session_path}?
|
|
125
|
+
#body
|
|
126
|
+
CONTENT
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def add_layout_links_with_slim
|
|
131
|
+
gsub_file 'app/views/layouts/application.html.slim', ' #body' do
|
|
132
|
+
<<-'CONTENT'.gsub(/^ {6}/, '')
|
|
133
|
+
#user-info
|
|
134
|
+
ul
|
|
135
|
+
- if user_signed_in?
|
|
136
|
+
li
|
|
137
|
+
' Hello, Dear
|
|
138
|
+
strong= current_user.username
|
|
139
|
+
' ! Maybe, you want to #{link_to 'logout', destroy_user_session_path}?
|
|
140
|
+
- else
|
|
141
|
+
li
|
|
142
|
+
| Hello Guest, maybe you want to #{link_to 'Join us', new_user_registration_path} or #{link_to 'login', new_user_session_path}?
|
|
143
|
+
#body
|
|
144
|
+
CONTENT
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def process_views_with_haml
|
|
149
|
+
Dir["#{destination_root}/app/views/devise/**/*.erb"].each do |erb_file|
|
|
150
|
+
haml_file = erb_file.gsub(/\.erb$/, '.haml')
|
|
151
|
+
run "html2haml #{erb_file} #{haml_file}"
|
|
152
|
+
run "rm #{erb_file}"
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def process_views_with_slim
|
|
157
|
+
process_views_with_haml
|
|
158
|
+
|
|
159
|
+
Dir["#{destination_root}/app/views/devise/**/*.haml"].each do |haml_file|
|
|
160
|
+
slim_file = haml_file.gsub(/\.haml$/, '.slim')
|
|
161
|
+
run "haml2slim #{haml_file} #{slim_file}"
|
|
162
|
+
run "rm #{haml_file}"
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Write down this recipe to our Cookbook if it's available
|
|
171
|
+
require File.dirname(__FILE__) + '/layout_recipe'
|
|
172
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::LayoutRecipe, Playmo::Recipes::DeviseRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class FormsRecipe < Playmo::Recipe
|
|
4
|
+
source_root File.expand_path('../templates/forms_recipe', __FILE__)
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
question "Which form builder you prefer?" do
|
|
8
|
+
answer "Use default form_for helper" => :use_default
|
|
9
|
+
answer "Simple Form" => :install_simple_form
|
|
10
|
+
answer "Formtastic" => :install_formtastic
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
def use_default
|
|
17
|
+
# do nothing
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def install_simple_form
|
|
21
|
+
gem 'simple_form'
|
|
22
|
+
|
|
23
|
+
Event.events.listen(:after_install) do |event_data|
|
|
24
|
+
# generate
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def install_formtastic
|
|
29
|
+
gem 'formtastic'
|
|
30
|
+
|
|
31
|
+
Event.events.listen(:after_install) do |event_data|
|
|
32
|
+
# generate
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Write down this recipe to our Cookbook if it's available
|
|
41
|
+
require File.dirname(__FILE__) + '/compass_recipe'
|
|
42
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::CompassRecipe, Playmo::Recipes::FormsRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class GitRecipe < Playmo::Recipe
|
|
4
|
+
def setup
|
|
5
|
+
silently do
|
|
6
|
+
Event.events.listen(:before_exit) do |event_data|
|
|
7
|
+
remove_file '.gitignore'
|
|
8
|
+
|
|
9
|
+
create_file '.gitignore', <<-CONTENT.gsub(/^ {14}/, '')
|
|
10
|
+
.DS_Store
|
|
11
|
+
log/*.log
|
|
12
|
+
tmp/**/*
|
|
13
|
+
db/*.sqlite3
|
|
14
|
+
.idea/
|
|
15
|
+
public/uploads/*
|
|
16
|
+
.sass-cache/
|
|
17
|
+
CONTENT
|
|
18
|
+
|
|
19
|
+
git :init
|
|
20
|
+
git :add => '.'
|
|
21
|
+
git :commit => "-am 'Initial commit for #{application_name}'"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Write down this recipe to our Cookbook if it's available
|
|
30
|
+
require File.dirname(__FILE__) + '/setup_database_recipe'
|
|
31
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::SetupDatabaseRecipe, Playmo::Recipes::GitRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class HomeControllerRecipe < Playmo::Recipe
|
|
4
|
+
source_root File.expand_path('../templates/home_controller_recipe', __FILE__)
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
question "Would you want to create HomeController in this project?" => :install_home_controller
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def install_home_controller
|
|
11
|
+
# Generate home_controller
|
|
12
|
+
Event.events.listen(:after_install) do |event_data|
|
|
13
|
+
generate :controller, :home, :index
|
|
14
|
+
|
|
15
|
+
# Change generated routes
|
|
16
|
+
gsub_file 'config/routes.rb', 'get "home/index"' do
|
|
17
|
+
'root :to => "home#index"'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Make changes in index view
|
|
21
|
+
change_index_view
|
|
22
|
+
|
|
23
|
+
# Copy sidebar template
|
|
24
|
+
empty_directory "app/views/shared"
|
|
25
|
+
copy_file "_sidebar.html.erb", "app/views/shared/_sidebar.html.erb"
|
|
26
|
+
|
|
27
|
+
# Remove default rails index file
|
|
28
|
+
remove_file 'public/index.html'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# Make changes in index view
|
|
35
|
+
def change_index_view
|
|
36
|
+
case retrieve(:markup)
|
|
37
|
+
when :erb then change_index_view_with_erb
|
|
38
|
+
when :haml then change_index_view_with_haml
|
|
39
|
+
when :slim then change_index_view_with_slim
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def change_index_view_with_erb
|
|
44
|
+
gsub_file 'app/views/home/index.html.erb', '<h1>Home#index</h1>' do
|
|
45
|
+
<<-CONTENT.gsub(/^ {12}/, '')
|
|
46
|
+
<%= heading_with_title("Home#index") %>
|
|
47
|
+
|
|
48
|
+
<% content_for :sidebar do %>
|
|
49
|
+
<%= heading "Sidebar" %>
|
|
50
|
+
<p>Content for sidebar.</p>
|
|
51
|
+
<p>This content displayed only at home page.</p>
|
|
52
|
+
<% end %>
|
|
53
|
+
CONTENT
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def change_index_view_with_haml
|
|
58
|
+
gsub_file 'app/views/home/index.html.haml', '%h1 Home#index' do
|
|
59
|
+
<<-'CONTENT'.gsub(/^ {12}/, '')
|
|
60
|
+
= heading_with_title("Home#index")
|
|
61
|
+
- content_for :sidebar do
|
|
62
|
+
= heading "Sidebar"
|
|
63
|
+
%p Content for sidebar.
|
|
64
|
+
%p This content displayed only at home page.
|
|
65
|
+
CONTENT
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def change_index_view_with_slim
|
|
70
|
+
gsub_file 'app/views/home/index.html.slim', 'h1 Home#index' do
|
|
71
|
+
<<-'CONTENT'.gsub(/^ {12}/, '')
|
|
72
|
+
= heading_with_title("Home#index")
|
|
73
|
+
- content_for :sidebar do
|
|
74
|
+
= heading "Sidebar"
|
|
75
|
+
p Content for sidebar.
|
|
76
|
+
p This content displayed only at home page.
|
|
77
|
+
CONTENT
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Write down this recipe to our Cookbook if it's available
|
|
85
|
+
require File.dirname(__FILE__) + '/layout_recipe'
|
|
86
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::LayoutRecipe, Playmo::Recipes::HomeControllerRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class JavascriptFrameworkRecipe < Playmo::Recipe
|
|
4
|
+
def setup
|
|
5
|
+
question "Please choose JS framework you prefer to install" do
|
|
6
|
+
answer "JQuery (with Jquery UI)" => :install_jquery
|
|
7
|
+
answer "Mootools Core (with More)" => :install_mootools
|
|
8
|
+
answer "Prototype (with Scriptaculous and RJS)" => :install_prototype
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
# See https://github.com/rails/jquery-rails for detailt
|
|
15
|
+
def install_jquery
|
|
16
|
+
gem "jquery-rails"
|
|
17
|
+
|
|
18
|
+
Event.events.listen(:after_install) do |event_data|
|
|
19
|
+
gsub_file 'app/assets/javascripts/application.js', '//= require_tree .' do
|
|
20
|
+
<<-CONTENT.gsub(/^ {16}/, '')
|
|
21
|
+
//= require jquery
|
|
22
|
+
//= require jquery_ui
|
|
23
|
+
//= require jquery_ujs
|
|
24
|
+
//= require_tree .
|
|
25
|
+
CONTENT
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# See https://github.com/neonlex/mootools-rails for detailt
|
|
31
|
+
def install_mootools
|
|
32
|
+
gem 'mootools-rails'
|
|
33
|
+
|
|
34
|
+
Event.events.listen(:after_install) do |event_data|
|
|
35
|
+
gsub_file 'app/assets/javascripts/application.js', '//= require_tree .' do
|
|
36
|
+
<<-CONTENT.gsub(/^ {16}/, '')
|
|
37
|
+
//= require mootools
|
|
38
|
+
//= require mootools-more
|
|
39
|
+
//= require mootools_ujs
|
|
40
|
+
//= require_tree .
|
|
41
|
+
CONTENT
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# See https://github.com/rails/prototype-rails for details
|
|
47
|
+
def install_prototype
|
|
48
|
+
gem "prototype-rails"
|
|
49
|
+
|
|
50
|
+
Event.events.listen(:after_install) do |event_data|
|
|
51
|
+
gsub_file 'app/assets/javascripts/application.js', '//= require_tree .' do
|
|
52
|
+
<<-CONTENT.gsub(/^ {16}/, '')
|
|
53
|
+
//= require prototype
|
|
54
|
+
//= require prototype_ujs
|
|
55
|
+
//= require effects
|
|
56
|
+
//= require dragdrop
|
|
57
|
+
//= require controls
|
|
58
|
+
//= require_tree .
|
|
59
|
+
CONTENT
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Write down this recipe to our Cookbook if it's available
|
|
68
|
+
require File.dirname(__FILE__) + '/forms_recipe'
|
|
69
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::FormsRecipe, Playmo::Recipes::JavascriptFrameworkRecipe) if defined?(Playmo::Cookbook)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Playmo
|
|
2
|
+
module Recipes
|
|
3
|
+
class LayoutRecipe < Playmo::Recipe
|
|
4
|
+
source_root File.expand_path('../templates/layout_recipe', __FILE__)
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
silently do
|
|
8
|
+
remove_file 'app/views/layouts/application.html.erb'
|
|
9
|
+
|
|
10
|
+
Event.events.listen(:after_install) do |event_data|
|
|
11
|
+
generate :layout, "application #{retrieve(:markup)}"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Write down this recipe to our Cookbook if it's available
|
|
20
|
+
require File.dirname(__FILE__) + '/javascript_framework_recipe'
|
|
21
|
+
Playmo::Cookbook.instance.insert_after(Playmo::Recipes::JavascriptFrameworkRecipe, Playmo::Recipes::LayoutRecipe) if defined?(Playmo::Cookbook)
|