dust-generators 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/README.rdoc +18 -6
  2. data/TODO.txt +5 -0
  3. data/lib/dust/version.rb +2 -2
  4. data/lib/generators/dust/albums/USAGE +2 -4
  5. data/lib/generators/dust/albums/albums_generator.rb +138 -138
  6. data/lib/generators/dust/albums/templates/app/controllers/albums_controller.rb +18 -18
  7. data/lib/generators/dust/albums/templates/app/controllers/photos_controller.rb +37 -37
  8. data/lib/generators/dust/albums/templates/app/controllers/view_albums_controller.rb +9 -9
  9. data/lib/generators/dust/albums/templates/app/models/album.rb +50 -48
  10. data/lib/generators/dust/albums/templates/app/models/photo.rb +21 -21
  11. data/lib/generators/dust/albums/templates/app/views/albums/_form.html.haml +35 -0
  12. data/lib/generators/dust/albums/templates/app/views/albums/_search.html.haml +4 -0
  13. data/lib/generators/dust/albums/templates/app/views/albums/_upload_script.html.haml +39 -0
  14. data/lib/generators/dust/albums/templates/app/views/albums/edit.html.haml +4 -0
  15. data/lib/generators/dust/albums/templates/app/views/albums/index.html.haml +35 -0
  16. data/lib/generators/dust/albums/templates/app/views/albums/manage.html.haml +47 -0
  17. data/lib/generators/dust/albums/templates/app/views/albums/new.html.haml +6 -0
  18. data/lib/generators/dust/albums/templates/app/views/albums/show.html.haml +42 -0
  19. data/lib/generators/dust/albums/templates/app/views/albums/show.js.haml +1 -0
  20. data/lib/generators/dust/albums/templates/app/views/photos/_form.html.haml +17 -0
  21. data/lib/generators/dust/albums/templates/app/views/photos/_photo.html.haml +22 -0
  22. data/lib/generators/dust/albums/templates/app/views/photos/_search.html.haml +5 -0
  23. data/lib/generators/dust/albums/templates/app/views/photos/array.js.haml +3 -0
  24. data/lib/generators/dust/albums/templates/app/views/photos/edit.html.haml +27 -0
  25. data/lib/generators/dust/albums/templates/app/views/photos/index.html.haml +85 -0
  26. data/lib/generators/dust/albums/templates/app/views/photos/new.html.haml +7 -0
  27. data/lib/generators/dust/albums/templates/app/views/photos/show.html.haml +24 -0
  28. data/lib/generators/dust/albums/templates/app/views/photos/show.js.haml +10 -0
  29. data/lib/generators/dust/albums/templates/app/views/view_albums/index.html.haml +25 -0
  30. data/lib/generators/dust/albums/templates/app/views/view_albums/show.html.haml +32 -0
  31. data/lib/generators/dust/albums/templates/javascripts/dust_album.js +22 -22
  32. data/lib/generators/dust/albums/templates/migration/albums_migration.rb +23 -21
  33. data/lib/generators/dust/albums/templates/stylesheets/dust_album.css +15 -3
  34. data/lib/generators/dust/albums/templates/stylesheets/dust_album_app.css +54 -3
  35. data/lib/generators/dust/scaffold/scaffold_generator.rb +20 -20
  36. data/lib/generators/dust/scaffold/templates/controller.rb +6 -6
  37. data/lib/generators/dust/scaffold/templates/migration.rb +2 -0
  38. data/lib/generators/dust/scaffold/templates/model.rb +10 -10
  39. data/lib/generators/dust/scaffold/templates/view_controller.rb +8 -8
  40. data/lib/generators/dust/scaffold/templates/views/erb/_search.html.erb +5 -5
  41. data/lib/generators/dust/scaffold/templates/views/front_end/{index.html.erb → erb/index.html.erb} +6 -6
  42. data/lib/generators/dust/scaffold/templates/views/front_end/erb/show.html.erb +17 -0
  43. data/lib/generators/dust/scaffold/templates/views/front_end/haml/index.html.haml +10 -0
  44. data/lib/generators/dust/scaffold/templates/views/front_end/haml/show.html.haml +15 -0
  45. data/lib/generators/dust/scaffold/templates/views/haml/_form.html.haml +7 -4
  46. data/lib/generators/dust/scaffold/templates/views/haml/_search.html.haml +5 -0
  47. data/lib/generators/dust/scaffold/templates/views/haml/edit.html.haml +1 -11
  48. data/lib/generators/dust/scaffold/templates/views/haml/index.html.haml +18 -23
  49. data/lib/generators/dust/scaffold/templates/views/haml/new.html.haml +1 -3
  50. data/lib/generators/dust/scaffold/templates/views/haml/show.html.haml +15 -13
  51. data/rails_generators/dust_albums/USAGE +2 -4
  52. data/rails_generators/dust_config/USAGE +3 -3
  53. data/rails_generators/dust_scaffold/USAGE +5 -5
  54. metadata +30 -26
  55. data/lib/generators/dust/albums/templates/app/views/albums/_form.html.erb +0 -52
  56. data/lib/generators/dust/albums/templates/app/views/albums/_search.html.erb +0 -6
  57. data/lib/generators/dust/albums/templates/app/views/albums/_upload_script.html.erb +0 -39
  58. data/lib/generators/dust/albums/templates/app/views/albums/edit.html.erb +0 -5
  59. data/lib/generators/dust/albums/templates/app/views/albums/index.html.erb +0 -61
  60. data/lib/generators/dust/albums/templates/app/views/albums/manage.html.erb +0 -65
  61. data/lib/generators/dust/albums/templates/app/views/albums/new.html.erb +0 -6
  62. data/lib/generators/dust/albums/templates/app/views/albums/show.html.erb +0 -56
  63. data/lib/generators/dust/albums/templates/app/views/albums/show.js.erb +0 -1
  64. data/lib/generators/dust/albums/templates/app/views/photos/_form.html.erb +0 -23
  65. data/lib/generators/dust/albums/templates/app/views/photos/_photo.html.erb +0 -25
  66. data/lib/generators/dust/albums/templates/app/views/photos/_search.html.erb +0 -6
  67. data/lib/generators/dust/albums/templates/app/views/photos/array.js.erb +0 -3
  68. data/lib/generators/dust/albums/templates/app/views/photos/edit.html.erb +0 -28
  69. data/lib/generators/dust/albums/templates/app/views/photos/index.html.erb +0 -85
  70. data/lib/generators/dust/albums/templates/app/views/photos/new.html.erb +0 -7
  71. data/lib/generators/dust/albums/templates/app/views/photos/show.html.erb +0 -26
  72. data/lib/generators/dust/albums/templates/app/views/photos/show.js.erb +0 -9
  73. data/lib/generators/dust/albums/templates/app/views/view_albums/index.html.erb +0 -31
  74. data/lib/generators/dust/albums/templates/app/views/view_albums/show.html.erb +0 -31
  75. data/lib/generators/dust/scaffold/templates/views/front_end/show.html.erb +0 -17
data/README.rdoc CHANGED
@@ -1,12 +1,24 @@
1
1
  = dust-generators
2
2
 
3
3
  Collection of generators for the Dust CMS
4
- * Albums
5
- ** Creates ablum and photo scaffolds along with uploadify integration
6
- * Scaffold
7
- ** Creates scaffold with views customized for dust admin pages
8
- * Config
9
- ** The dust_config generator creates YAML file in your config directory and an initializer to load this config.
4
+ * Albums - Creates album and photo scaffolds along with uploadify integration
5
+ * Scaffold - Creates scaffold with views customized for dust admin pages
6
+ * Config - The dust_config generator creates YAML file in your config directory and an initializer to load this config.
7
+
8
+ = Usage
9
+
10
+ - Rails 3
11
+
12
+ include dust-generators in your Gemfile
13
+ rails g
14
+ to view available commands
15
+
16
+ - Rails 2
17
+ script/generate dust_album --help
18
+ script/generate dust_config --help
19
+ script/generate dust_scaffold --help
20
+
21
+ This will walk you through the various commands
10
22
 
11
23
  == Contributing to dust-generators
12
24
 
data/TODO.txt ADDED
@@ -0,0 +1,5 @@
1
+ albums/show edit and delete icons are not visible
2
+
3
+ scaffold
4
+ convert erbs to haml
5
+ jquery ui edit and delete links
data/lib/dust/version.rb CHANGED
@@ -2,8 +2,8 @@ class Dust
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 6
5
+ PATCH = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
9
- end
9
+ end
@@ -1,8 +1,6 @@
1
1
  Description:
2
- Explain the generator
2
+ Create Parent and Child scaffold with uploadify paperclip uploads
3
3
 
4
4
  Example:
5
- rails generate install Thing
5
+ rails dust:albums Parent Child
6
6
 
7
- This will create:
8
- what/will/it/create
@@ -5,141 +5,141 @@ require 'rails/generators/generated_attribute'
5
5
  module Dust
6
6
  module Generators
7
7
  class AlbumsGenerator < Base
8
- include Rails::Generators::Migration
9
- desc "Create all migrations and copy all files for Dust Albums."
10
-
11
- argument :parent_model_name, :type => :string, :required => true, :banner => 'ParentModelName'
12
- argument :child_model_name, :type => :string, :required => true, :banner => 'ChildModelName'
13
-
14
- def source_root
15
- @source_root ||= File.expand_path('../templates', __FILE__)
16
- end
17
-
18
- def create_migration
19
- migration_template "migration/albums_migration.rb", "db/migrate/create_#{parent_plural_name}.rb"
20
- end
21
-
22
- def routes
23
- route("match \"all/#{parent_plural_name}\" => \"view_#{parent_plural_name}#index\", :as => :view_#{parent_plural_name}")
24
- route("match \"#{child_plural_name}-for/:filename\" => \"view_#{parent_plural_name}#show\", :as => :view_#{parent_singular_name}")
25
- route("match \"manage-#{child_plural_name}/:id\" => \"#{parent_plural_name}#manage\", :as => :manage_#{child_plural_name}")
26
- route("match \"#{child_plural_name}/array\" => \"#{child_plural_name}#array\", :as => :#{child_plural_name}_sort")
27
- route("match \"destroy-#{child_plural_name}\" => \"#{child_plural_name}#destroy\", :as => :#{child_plural_name}_bulk_delete")
28
-
29
- route("resources :#{parent_plural_name}")
30
- route("resources :#{child_plural_name}")
31
- end
32
-
33
- def app
34
- template "app/controllers/albums_controller.rb", "app/controllers/#{parent_plural_name}_controller.rb"
35
- template "app/controllers/photos_controller.rb", "app/controllers/#{child_plural_name}_controller.rb"
36
- template "app/controllers/view_albums_controller.rb", "app/controllers/view_#{parent_plural_name}_controller.rb"
37
-
38
- template "app/helpers/albums_helper.rb", "app/helpers/#{parent_plural_name}_helper.rb"
39
- template "app/helpers/photos_helper.rb", "app/helpers/#{child_plural_name}_helper.rb"
40
- template "app/helpers/view_albums_helper.rb", "app/helpers/view_#{parent_plural_name}_helper.rb"
41
-
42
- template "app/models/album.rb", "app/models/#{parent_singular_name}.rb"
43
- template "app/models/photo.rb", "app/models/#{child_singular_name}.rb"
44
-
45
- template "app/views/albums/_form.html.erb", "app/views/#{parent_plural_name}/_form.html.erb"
46
- template "app/views/albums/_search.html.erb", "app/views/#{parent_plural_name}/_search.html.erb"
47
- template "app/views/albums/_upload_script.html.erb", "app/views/#{parent_plural_name}/_upload_script.html.erb"
48
- template "app/views/albums/edit.html.erb", "app/views/#{parent_plural_name}/edit.html.erb"
49
- template "app/views/albums/index.html.erb", "app/views/#{parent_plural_name}/index.html.erb"
50
- template "app/views/albums/manage.html.erb", "app/views/#{parent_plural_name}/manage.html.erb"
51
- template "app/views/albums/new.html.erb", "app/views/#{parent_plural_name}/new.html.erb"
52
- template "app/views/albums/show.html.erb", "app/views/#{parent_plural_name}/show.html.erb"
53
- template "app/views/albums/show.js.erb", "app/views/#{parent_plural_name}/show.js.erb"
54
-
55
- template "app/views/photos/_form.html.erb", "app/views/#{child_plural_name}/_form.html.erb"
56
- template "app/views/photos/_search.html.erb", "app/views/#{child_plural_name}/_search.html.erb"
57
- template "app/views/photos/_photo.html.erb", "app/views/#{child_plural_name}/_#{child_singular_name}.html.erb"
58
- template "app/views/photos/array.js.erb", "app/views/#{child_plural_name}/array.js.erb"
59
- template "app/views/photos/edit.html.erb", "app/views/#{child_plural_name}/edit.html.erb"
60
- template "app/views/photos/index.html.erb", "app/views/#{child_plural_name}/index.html.erb"
61
- template "app/views/photos/new.html.erb", "app/views/#{child_plural_name}/new.html.erb"
62
- template "app/views/photos/show.html.erb", "app/views/#{child_plural_name}/show.html.erb"
63
- template "app/views/photos/show.js.erb", "app/views/#{child_plural_name}/show.js.erb"
64
-
65
- template "app/views/view_albums/index.html.erb", "app/views/view_#{parent_plural_name}/index.html.erb"
66
- template "app/views/view_albums/show.html.erb", "app/views/view_#{parent_plural_name}/show.html.erb"
67
- end
68
-
69
- def css
70
- template "stylesheets/dust_album.css", "public/stylesheets/dust_#{parent_singular_name}.css"
71
- template "stylesheets/uploadify.css", "public/stylesheets/#{parent_singular_name}_uploadify.css"
72
- template "stylesheets/dust_album_app.css", "public/stylesheets/dust_#{parent_singular_name}_app.css"
73
- end
74
-
75
- def javascript
76
- template "javascripts/dragsort.js", "public/javascripts/dragsort.js"
77
- template "javascripts/dust_album.js", "public/javascripts/dust_#{parent_singular_name}.js"
78
-
79
- src_dir = File.join(source_root, 'javascripts', 'uploadify')
80
- dst_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
81
-
82
- FileUtils.cp_r src_dir, dst_dir, :verbose => true
83
- end
84
-
85
- def images
86
- template "images/cancel.png", "public/images/cancel.png"
87
- template "images/browse.png", "public/images/browse.png"
88
- template "images/upload.png", "public/images/upload.png"
89
- template "images/save_position.png", "public/images/save_position.png"
90
- end
91
-
92
- def initializers
93
- template "initializers/flash_session_cookie_middleware.rb", "config/initializers/flash_session_cookie_middleware.rb"
94
- template "initializers/session_store_middleware.rb", "config/initializers/session_store_middleware.rb"
95
- end
96
-
97
- def rake_migrations
98
- rake("db:migrate")
99
- end
100
-
101
- #NAMING METHODS
102
- def parent
103
- parent_model_name.downcase.singularize
104
- end
105
-
106
- def child
107
- child_model_name.downcase.singularize
108
- end
109
-
110
- def parent_singular_name
111
- parent.underscore
112
- end
113
-
114
- def child_singular_name
115
- child.underscore
116
- end
117
-
118
- def parent_plural_name
119
- parent.underscore.pluralize
120
- end
121
-
122
- def child_plural_name
123
- child.underscore.pluralize
124
- end
125
-
126
- def parent_class_name
127
- parent.camelize
128
- end
129
-
130
- def child_class_name
131
- child.camelize
132
- end
133
-
134
- def parent_plural_class_name
135
- parent_plural_name.camelize
136
- end
137
-
138
- def child_plural_class_name
139
- child_plural_name.camelize
140
- end
141
-
142
- # FIXME: Should be proxied to ActiveRecord::Generators::Base
8
+ include Rails::Generators::Migration
9
+ desc "Create all migrations and copy all files for Dust Albums."
10
+
11
+ argument :parent_model_name, :type => :string, :required => true, :banner => 'ParentModelName'
12
+ argument :child_model_name, :type => :string, :required => true, :banner => 'ChildModelName'
13
+
14
+ def source_root
15
+ @source_root ||= File.expand_path('../templates', __FILE__)
16
+ end
17
+
18
+ def create_migration
19
+ migration_template "migration/albums_migration.rb", "db/migrate/create_#{parent_plural_name}.rb"
20
+ end
21
+
22
+ def routes
23
+ route("match \"all/#{parent_plural_name}\" => \"view_#{parent_plural_name}#index\", :as => :view_#{parent_plural_name}")
24
+ route("match \"#{child_plural_name}-for/:filename\" => \"view_#{parent_plural_name}#show\", :as => :view_#{parent_singular_name}")
25
+ route("match \"manage-#{child_plural_name}/:id\" => \"#{parent_plural_name}#manage\", :as => :manage_#{child_plural_name}")
26
+ route("match \"#{child_plural_name}/array\" => \"#{child_plural_name}#array\", :as => :#{child_plural_name}_sort")
27
+ route("match \"destroy-#{child_plural_name}\" => \"#{child_plural_name}#destroy\", :as => :#{child_plural_name}_bulk_delete")
28
+
29
+ route("resources :#{parent_plural_name}")
30
+ route("resources :#{child_plural_name}")
31
+ end
32
+
33
+ def app
34
+ template "app/controllers/albums_controller.rb", "app/controllers/#{parent_plural_name}_controller.rb"
35
+ template "app/controllers/photos_controller.rb", "app/controllers/#{child_plural_name}_controller.rb"
36
+ template "app/controllers/view_albums_controller.rb", "app/controllers/view_#{parent_plural_name}_controller.rb"
37
+
38
+ template "app/helpers/albums_helper.rb", "app/helpers/#{parent_plural_name}_helper.rb"
39
+ template "app/helpers/photos_helper.rb", "app/helpers/#{child_plural_name}_helper.rb"
40
+ template "app/helpers/view_albums_helper.rb", "app/helpers/view_#{parent_plural_name}_helper.rb"
41
+
42
+ template "app/models/album.rb", "app/models/#{parent_singular_name}.rb"
43
+ template "app/models/photo.rb", "app/models/#{child_singular_name}.rb"
44
+
45
+ template "app/views/albums/_form.html.haml", "app/views/#{parent_plural_name}/_form.html.haml"
46
+ template "app/views/albums/_search.html.haml", "app/views/#{parent_plural_name}/_search.html.haml"
47
+ template "app/views/albums/_upload_script.html.haml", "app/views/#{parent_plural_name}/_upload_script.html.haml"
48
+ template "app/views/albums/edit.html.haml", "app/views/#{parent_plural_name}/edit.html.haml"
49
+ template "app/views/albums/index.html.haml", "app/views/#{parent_plural_name}/index.html.haml"
50
+ template "app/views/albums/manage.html.haml", "app/views/#{parent_plural_name}/manage.html.haml"
51
+ template "app/views/albums/new.html.haml", "app/views/#{parent_plural_name}/new.html.haml"
52
+ template "app/views/albums/show.html.haml", "app/views/#{parent_plural_name}/show.html.haml"
53
+ template "app/views/albums/show.js.haml", "app/views/#{parent_plural_name}/show.js.haml"
54
+
55
+ template "app/views/photos/_form.html.haml", "app/views/#{child_plural_name}/_form.html.haml"
56
+ template "app/views/photos/_search.html.haml", "app/views/#{child_plural_name}/_search.html.haml"
57
+ template "app/views/photos/_photo.html.haml", "app/views/#{child_plural_name}/_#{child_singular_name}.html.haml"
58
+ template "app/views/photos/array.js.haml", "app/views/#{child_plural_name}/array.js.haml"
59
+ template "app/views/photos/edit.html.haml", "app/views/#{child_plural_name}/edit.html.haml"
60
+ template "app/views/photos/index.html.haml", "app/views/#{child_plural_name}/index.html.haml"
61
+ template "app/views/photos/new.html.haml", "app/views/#{child_plural_name}/new.html.haml"
62
+ template "app/views/photos/show.html.haml", "app/views/#{child_plural_name}/show.html.haml"
63
+ template "app/views/photos/show.js.haml", "app/views/#{child_plural_name}/show.js.haml"
64
+
65
+ template "app/views/view_albums/index.html.haml", "app/views/view_#{parent_plural_name}/index.html.haml"
66
+ template "app/views/view_albums/show.html.haml", "app/views/view_#{parent_plural_name}/show.html.haml"
67
+ end
68
+
69
+ def css
70
+ template "stylesheets/dust_album.css", "public/stylesheets/dust_#{parent_singular_name}.css"
71
+ template "stylesheets/uploadify.css", "public/stylesheets/#{parent_singular_name}_uploadify.css"
72
+ template "stylesheets/dust_album_app.css", "public/stylesheets/dust_#{parent_singular_name}_app.css"
73
+ end
74
+
75
+ def javascript
76
+ template "javascripts/dragsort.js", "public/javascripts/dragsort.js"
77
+ template "javascripts/dust_album.js", "public/javascripts/dust_#{parent_singular_name}.js"
78
+
79
+ src_dir = File.join(source_root, 'javascripts', 'uploadify')
80
+ dst_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
81
+
82
+ FileUtils.cp_r src_dir, dst_dir, :verbose => true
83
+ end
84
+
85
+ def images
86
+ template "images/cancel.png", "public/images/cancel.png"
87
+ template "images/browse.png", "public/images/browse.png"
88
+ template "images/upload.png", "public/images/upload.png"
89
+ template "images/save_position.png", "public/images/save_position.png"
90
+ end
91
+
92
+ def initializers
93
+ template "initializers/flash_session_cookie_middleware.rb", "config/initializers/flash_session_cookie_middleware.rb"
94
+ template "initializers/session_store_middleware.rb", "config/initializers/session_store_middleware.rb"
95
+ end
96
+
97
+ def rake_migrations
98
+ rake("db:migrate")
99
+ end
100
+
101
+ #NAMING METHODS
102
+ def parent
103
+ parent_model_name.downcase.singularize
104
+ end
105
+
106
+ def child
107
+ child_model_name.downcase.singularize
108
+ end
109
+
110
+ def parent_singular_name
111
+ parent.underscore
112
+ end
113
+
114
+ def child_singular_name
115
+ child.underscore
116
+ end
117
+
118
+ def parent_plural_name
119
+ parent.underscore.pluralize
120
+ end
121
+
122
+ def child_plural_name
123
+ child.underscore.pluralize
124
+ end
125
+
126
+ def parent_class_name
127
+ parent.camelize
128
+ end
129
+
130
+ def child_class_name
131
+ child.camelize
132
+ end
133
+
134
+ def parent_plural_class_name
135
+ parent_plural_name.camelize
136
+ end
137
+
138
+ def child_plural_class_name
139
+ child_plural_name.camelize
140
+ end
141
+
142
+ # FIXME: Should be proxied to ActiveRecord::Generators::Base
143
143
  # Implement the required interface for Rails::Generators::Migration.
144
144
  def self.next_migration_number(dirname) #:nodoc:
145
145
  if ActiveRecord::Base.timestamped_migrations
@@ -148,6 +148,6 @@ module Dust
148
148
  "%.3d" % (current_migration_number(dirname) + 1)
149
149
  end
150
150
  end
151
- end
152
- end
153
- end
151
+ end
152
+ end
153
+ end
@@ -1,22 +1,22 @@
1
1
  class <%=parent_plural_class_name%>Controller < ApplicationController
2
-
3
- filter_resource_access
4
-
5
- layout 'cms'
6
-
2
+
3
+ filter_resource_access
4
+
5
+ layout 'cms'
6
+
7
7
  def index
8
- @<%=parent_plural_name%> = <%=parent_class_name%>.page(params[:search], params[:page])
8
+ @<%=parent_plural_name%> = <%=parent_class_name%>.roots.page(params[:search], params[:page])
9
9
  end
10
-
10
+
11
11
  def show
12
12
  @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
13
- @new_<%=child_singular_name%> = <%=child_class_name%>.new(:<%=parent_singular_name%>_id => @<%=parent_singular_name%>.id)
13
+ @new_<%=child_singular_name%> = <%=child_class_name%>.new(:<%=parent_singular_name%>_id => @<%=parent_singular_name%>.id)
14
14
  end
15
-
15
+
16
16
  def new
17
17
  @<%=parent_singular_name%> = <%=parent_class_name%>.new
18
18
  end
19
-
19
+
20
20
  def create
21
21
  @<%=parent_singular_name%> = <%=parent_class_name%>.new(params[:<%=parent_singular_name%>])
22
22
  if @<%=parent_singular_name%>.save
@@ -26,11 +26,11 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
26
26
  render :action => 'new'
27
27
  end
28
28
  end
29
-
29
+
30
30
  def edit
31
31
  @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
32
32
  end
33
-
33
+
34
34
  def update
35
35
  @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
36
36
  if @<%=parent_singular_name%>.update_attributes(params[:<%=parent_singular_name%>])
@@ -40,7 +40,7 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
40
40
  render :action => 'edit'
41
41
  end
42
42
  end
43
-
43
+
44
44
  def destroy
45
45
  @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
46
46
  @<%=parent_singular_name%>.destroy
@@ -48,9 +48,9 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
48
48
  redirect_to <%=parent_plural_name%>_url
49
49
  end
50
50
 
51
- def manage
52
- @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
53
- @<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>
54
- render :layout => false
55
- end
51
+ def manage
52
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
53
+ @<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>
54
+ render :layout => false
55
+ end
56
56
  end
@@ -1,27 +1,27 @@
1
1
  class <%=child_plural_class_name%>Controller < ApplicationController
2
-
3
- filter_access_to :index, :new, :create, :destroy
4
- filter_access_to :edit, :update, :attribute_check => true
5
-
6
- layout 'cms'
7
-
2
+
3
+ filter_access_to :index, :new, :create, :destroy
4
+ filter_access_to :edit, :update, :attribute_check => true
5
+
6
+ layout 'cms'
7
+
8
8
  def index
9
9
  @<%=child_plural_name%> = <%=child_class_name%>.page(params[:search], params[:page])
10
- @<%=child_singular_name%>_<%=parent_plural_name%> = @<%=child_plural_name%>.group_by { |<%=child_singular_name%>| <%=child_singular_name%>.<%=parent_singular_name%>.title }
10
+ @<%=child_singular_name%>_<%=parent_plural_name%> = @<%=child_plural_name%>.group_by { |<%=child_singular_name%>| <%=child_singular_name%>.<%=parent_singular_name%>.title }
11
11
  end
12
-
12
+
13
13
  def show
14
14
  @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id], :include => :<%=parent_singular_name%>)
15
- @total_uploads = <%=child_class_name%>.find(:all, :conditions => { :<%=parent_singular_name%>_id => @<%=child_singular_name%>.<%=parent_singular_name%>.id})
16
- @<%=parent_singular_name%> = @<%=child_singular_name%>.<%=parent_singular_name%>
15
+ @total_uploads = <%=child_class_name%>.find(:all, :conditions => { :<%=parent_singular_name%>_id => @<%=child_singular_name%>.<%=parent_singular_name%>.id})
16
+ @<%=parent_singular_name%> = @<%=child_singular_name%>.<%=parent_singular_name%>
17
17
  end
18
-
18
+
19
19
  def new
20
20
  @<%=child_singular_name%> = <%=child_class_name%>.new
21
21
  end
22
-
22
+
23
23
  def create
24
- newparams = coerce(params)
24
+ newparams = coerce(params)
25
25
  @<%=child_singular_name%> = <%=child_class_name%>.new(newparams[:<%=child_singular_name%>])
26
26
  if @<%=child_singular_name%>.save
27
27
  flash[:notice] = "Successfully created <%=child_singular_name%>."
@@ -33,16 +33,16 @@ class <%=child_plural_class_name%>Controller < ApplicationController
33
33
  render :action => 'new'
34
34
  end
35
35
  end
36
-
36
+
37
37
  def edit
38
- if params[:edit] == '<%=child_singular_name%>'
39
- render :layout => false
40
- @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
41
- else
42
- @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
43
- end
38
+ if params[:edit] == '<%=child_singular_name%>'
39
+ render :layout => false
40
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
41
+ else
42
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
43
+ end
44
44
  end
45
-
45
+
46
46
  def update
47
47
  @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
48
48
  if @<%=child_singular_name%>.update_attributes(params[:<%=child_singular_name%>])
@@ -52,32 +52,32 @@ class <%=child_plural_class_name%>Controller < ApplicationController
52
52
  render :action => 'edit'
53
53
  end
54
54
  end
55
-
56
- def destroy
55
+
56
+ def destroy
57
57
  if request.post?
58
- if params[:<%=child_singular_name%>_ids]
59
- params[:<%=child_singular_name%>_ids].each do |<%=child_singular_name%>|
60
- @<%=child_singular_name%> = <%=child_class_name%>.find <%=child_singular_name%>
61
- @<%=child_singular_name%>.destroy
62
- end
63
- flash[:notice] = "<%=child_plural_class_name%> Successfully deleted!"
64
- end
65
- redirect_to(<%=parent_singular_name%>_path(@<%=child_singular_name%>.<%=parent_singular_name%>))
66
- end
58
+ if params[:<%=child_singular_name%>_ids]
59
+ params[:<%=child_singular_name%>_ids].each do |<%=child_singular_name%>|
60
+ @<%=child_singular_name%> = <%=child_class_name%>.find <%=child_singular_name%>
61
+ @<%=child_singular_name%>.destroy
62
+ end
63
+ flash[:notice] = "<%=child_plural_class_name%> Successfully deleted!"
64
+ end
65
+ redirect_to(<%=parent_singular_name%>_path(@<%=child_singular_name%>.<%=parent_singular_name%>))
66
+ end
67
67
  end
68
68
 
69
- def array
70
- menu_sort(params[:ul])
69
+ def array
70
+ menu_sort(params[:ul])
71
71
  flash[:notice] = "Successfully Sorted <%=child_plural_class_name%>."
72
- end
72
+ end
73
73
 
74
- private
74
+ private
75
75
  def coerce(params)
76
76
  if params[:<%=child_singular_name%>].nil?
77
77
  h = Hash.new
78
78
  h[:<%=child_singular_name%>] = Hash.new
79
79
  h[:<%=child_singular_name%>][:<%=parent_singular_name%>_id] = params[:<%=parent_singular_name%>_id]
80
- h[:<%=child_singular_name%>][:title] = params[:title]
80
+ h[:<%=child_singular_name%>][:title] = params[:title]
81
81
  h[:<%=child_singular_name%>][:file] = params[:Filedata]
82
82
  h[:<%=child_singular_name%>][:file].content_type = MIME::Types.type_for(h[:<%=child_singular_name%>][:file].original_filename).to_s
83
83
  h
@@ -1,17 +1,17 @@
1
1
  class View<%=parent_plural_class_name%>Controller < ApplicationController
2
-
2
+
3
3
  def index
4
- @<%=parent_plural_name%> = <%=parent_class_name%>.view(params[:page])
4
+ @<%=parent_plural_name%> = <%=parent_class_name%>.view(params[:page])
5
5
  end
6
6
 
7
7
  def show
8
- if <%=parent_class_name%>.find_by_filename(params[:filename]) == nil
9
- @<%=parent_singular_name%> = <%=parent_class_name%>.find(:first)
10
- render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
11
- else
12
- @<%=parent_singular_name%> = <%=parent_class_name%>.find_by_filename(params[:filename])
13
- @<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>.<%=parent_singular_name%>_page(params[:page])
14
- end
8
+ if <%=parent_class_name%>.find_by_filename(params[:filename]) == nil
9
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(:first)
10
+ render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
11
+ else
12
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find_by_filename(params[:filename])
13
+ @<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>.<%=parent_singular_name%>_page(params[:page])
14
+ end
15
15
  end
16
16
 
17
17
  end