dust-generators 0.1.4 → 0.1.5
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/lib/dust/version.rb +1 -1
- data/rails_generators/dust_scaffold/templates/actions/create.rb +1 -1
- data/rails_generators/dust_scaffold/templates/actions/destroy.rb +1 -1
- data/rails_generators/dust_scaffold/templates/actions/index.rb +1 -1
- data/rails_generators/dust_scaffold/templates/actions/update.rb +1 -1
- data/rails_generators/dust_scaffold/templates/controller.rb +7 -1
- data/rails_generators/dust_scaffold/templates/fixtures.yml +2 -2
- data/rails_generators/dust_scaffold/templates/migration.rb +4 -2
- data/rails_generators/dust_scaffold/templates/model.rb +35 -1
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/create.rb +1 -1
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/update.rb +1 -1
- data/rails_generators/dust_scaffold/templates/tests/rspec/controller.rb +3 -3
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/create.rb +1 -1
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/update.rb +1 -1
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/create.rb +1 -1
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/update.rb +1 -1
- data/rails_generators/dust_scaffold/templates/views/erb/_form.html.erb +12 -6
- data/rails_generators/dust_scaffold/templates/views/erb/_search.html.erb +6 -0
- data/rails_generators/dust_scaffold/templates/views/erb/edit.html.erb +2 -12
- data/rails_generators/dust_scaffold/templates/views/erb/index.html.erb +21 -26
- data/rails_generators/dust_scaffold/templates/views/erb/new.html.erb +1 -3
- data/rails_generators/dust_scaffold/templates/views/erb/show.html.erb +21 -18
- data/rails_generators/dust_scaffold/templates/views/haml/_form.html.haml +1 -1
- data/rails_generators/dust_scaffold/templates/views/haml/index.html.haml +4 -4
- data/rails_generators/dust_scaffold/templates/views/haml/show.html.haml +3 -3
- metadata +4 -3
data/lib/dust/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
def create
|
2
2
|
@<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
|
3
3
|
if @<%= singular_name %>.save
|
4
|
-
flash[:notice] = "Successfully created <%=
|
4
|
+
flash[:notice] = "Successfully created <%= model_name.underscore.humanize.downcase %>."
|
5
5
|
redirect_to <%= item_path('url') %>
|
6
6
|
else
|
7
7
|
render :action => 'new'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
def destroy
|
2
2
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
3
3
|
@<%= singular_name %>.destroy
|
4
|
-
flash[:notice] = "Successfully destroyed <%=
|
4
|
+
flash[:notice] = "Successfully destroyed <%= model_name.underscore.humanize.downcase %>."
|
5
5
|
redirect_to <%= items_path('url') %>
|
6
6
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
def update
|
2
2
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
3
3
|
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
4
|
-
flash[:notice] = "Successfully updated <%=
|
4
|
+
flash[:notice] = "Successfully updated <%= model_name.underscore.humanize.downcase %>."
|
5
5
|
redirect_to <%= item_path('url') %>
|
6
6
|
else
|
7
7
|
render :action => 'edit'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
one:
|
2
|
-
<%- for attribute in
|
2
|
+
<%- for attribute in model_attributes -%>
|
3
3
|
<%= attribute.name %>: <%= attribute.default %>
|
4
4
|
<%- end -%>
|
5
5
|
|
6
6
|
two:
|
7
|
-
<%- for attribute in
|
7
|
+
<%- for attribute in model_attributes -%>
|
8
8
|
<%= attribute.name %>: <%= attribute.default %>
|
9
9
|
<%- end -%>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Create<%= plural_class_name %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table :<%= plural_name %> do |t|
|
4
|
-
<%- for attribute in
|
4
|
+
<%- for attribute in model_attributes -%>
|
5
5
|
t.<%= attribute.type %> :<%= attribute.name %>
|
6
6
|
<%- end -%>
|
7
7
|
<%- unless options[:skip_timestamps] -%>
|
@@ -9,7 +9,9 @@ class Create<%= plural_class_name %> < ActiveRecord::Migration
|
|
9
9
|
<%- end -%>
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
|
+
CmsMenuItem.create({:title =>"<%= plural_class_name %>", :controller_name => "<%= plural_name %>", :url => "/<%= plural_name %>"})
|
14
|
+
|
13
15
|
def self.down
|
14
16
|
drop_table :<%= plural_name %>
|
15
17
|
end
|
@@ -1,3 +1,37 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Base
|
2
|
-
attr_accessible <%=
|
2
|
+
attr_accessible <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>
|
3
|
+
|
4
|
+
<%- first_attribute = model_attributes.first -%>
|
5
|
+
def self.page(search, page)
|
6
|
+
paginate :per_page => 10, :page => page,
|
7
|
+
:order => 'name',
|
8
|
+
:conditions => ["<%= first_attribute.name %> LIKE ? OR content LIKE ?", "%#{search}%", "%#{search}%"]
|
9
|
+
end
|
10
|
+
|
11
|
+
has_one :menu_item, :as => :linkable, :dependent => :destroy
|
12
|
+
|
13
|
+
after_create :create_menu_item
|
14
|
+
after_update :update_menu_item
|
15
|
+
|
16
|
+
def update_menu_item
|
17
|
+
@menu_item = self.menu_item
|
18
|
+
if @menu_item == nil
|
19
|
+
self.create_menu_item
|
20
|
+
else
|
21
|
+
@menu_item.update_attributes(
|
22
|
+
:title => self.<%= first_attribute.name %>,
|
23
|
+
:url => "/#{self.<%= first_attribute.name %>}",
|
24
|
+
:active => self.<%= first_attribute.name %>
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_menu_item
|
30
|
+
@menu_item = self.build_menu_item(
|
31
|
+
:title => self.<%= first_attribute.name %>,
|
32
|
+
:url => "/#{<%= first_attribute.name %>}",
|
33
|
+
:active => self.<%= first_attribute.name %>
|
34
|
+
)
|
35
|
+
@menu_item.save
|
36
|
+
end
|
3
37
|
end
|
@@ -1,10 +1,16 @@
|
|
1
|
-
|
1
|
+
<%%= content_for :head do -%>
|
2
|
+
<%%= javascript_include_tag :ckeditor %>
|
3
|
+
<%% end -%>
|
4
|
+
|
5
|
+
<%%= form_for @<%= singular_name %>, :validations => true do |f| %>
|
2
6
|
<%%= f.error_messages %>
|
3
|
-
<%- for attribute in
|
4
|
-
<
|
7
|
+
<%- for attribute in model_attributes -%>
|
8
|
+
<div class="item">
|
5
9
|
<%%= f.label :<%= attribute.name %> %><br />
|
6
|
-
<%%= f.<%= attribute.field_type %> :<%= attribute.name
|
7
|
-
</
|
10
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %>, :class => 'field' %>
|
11
|
+
</div>
|
8
12
|
<%- end -%>
|
9
|
-
|
13
|
+
<div class="item">
|
14
|
+
<p><%%= f.submit %></p>
|
15
|
+
</div>
|
10
16
|
<%% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div id="searchbox">
|
2
|
+
<%%= form_tag <%= plural_name %>_path, :method => 'get' do %>
|
3
|
+
<%%= text_field_tag :search, params[:search], :class => "input-text", :placeholder => 'Search <%= plural_name.capitalize %>' %>
|
4
|
+
<%%= image_submit_tag "admin/blank.png", :class => "image-submit"%>
|
5
|
+
<%% end %>
|
6
|
+
</div>
|
@@ -1,14 +1,4 @@
|
|
1
1
|
<%% title "Edit <%= singular_name.titleize %>" %>
|
2
|
+
<%% heading "Edit <%= singular_name.titleize %>" %>
|
2
3
|
|
3
|
-
<%= render_form %>
|
4
|
-
|
5
|
-
<%- if actions? :show, :index -%>
|
6
|
-
<p>
|
7
|
-
<%- if action? :show -%>
|
8
|
-
<%%= link_to "Show", @<%= singular_name %> %> |
|
9
|
-
<%- end -%>
|
10
|
-
<%- if action? :index -%>
|
11
|
-
<%%= link_to "View All", <%= plural_name %>_path %>
|
12
|
-
<%- end -%>
|
13
|
-
</p>
|
14
|
-
<%- end -%>
|
4
|
+
<%= render_form %>
|
@@ -1,29 +1,24 @@
|
|
1
1
|
<%% title "<%= plural_name.titleize %>" %>
|
2
|
+
<%- first_attribute = model_attributes.first -%>
|
3
|
+
<div class="button_bar">
|
4
|
+
<%%= render :partial => 'search' %>
|
5
|
+
<%%= link_to 'new page', new_<%= singular_name %>_path, :class => 'newfile tip', :title => "New <%= singular_name.titleize %>" %>
|
6
|
+
</div>
|
2
7
|
|
3
|
-
|
4
|
-
<tr>
|
5
|
-
<%- for attribute in attributes -%>
|
6
|
-
<th><%= attribute.column.human_name.titleize %></th>
|
7
|
-
<%- end -%>
|
8
|
-
</tr>
|
9
|
-
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
10
|
-
<tr>
|
11
|
-
<%- for attribute in attributes -%>
|
12
|
-
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
13
|
-
<%- end -%>
|
14
|
-
<%- if action? :show -%>
|
15
|
-
<td><%%= link_to "Show", <%= singular_name %> %></td>
|
16
|
-
<%- end -%>
|
17
|
-
<%- if action? :edit -%>
|
18
|
-
<td><%%= link_to "Edit", edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
19
|
-
<%- end -%>
|
20
|
-
<%- if action? :destroy -%>
|
21
|
-
<td><%%= link_to "Destroy", <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
22
|
-
<%- end -%>
|
23
|
-
</tr>
|
24
|
-
<%% end %>
|
25
|
-
</table>
|
8
|
+
<%%= will_paginate @<%= plural_name %> %>
|
26
9
|
|
27
|
-
|
28
|
-
<
|
29
|
-
|
10
|
+
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
11
|
+
<div class="item">
|
12
|
+
<div style='float:right'>
|
13
|
+
<%%= link_to '', edit_<%= singular_name %>_path(<%= singular_name %>), :class => 'edit tip', :title => "Edit This Item" %>
|
14
|
+
<%%= link_to '', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete, :class => 'destroy tip', :title => "Destroy This Item" %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<h3><%%= link_to <%= singular_name %>.<%= first_attribute.name %>, <%= singular_name %> %></h3>
|
18
|
+
<p>
|
19
|
+
<%%= link_to "Preview <%= singular_name.titleize %>", <%= singular_name %>, :class => 'remote_iframe' %>
|
20
|
+
</p>
|
21
|
+
</div>
|
22
|
+
<%% end -%>
|
23
|
+
|
24
|
+
<%%= will_paginate @<%= plural_name %> %>
|
@@ -1,20 +1,23 @@
|
|
1
1
|
<%% title "<%= singular_name.titleize %>" %>
|
2
|
+
<%- first_attribute = model_attributes.first -%>
|
2
3
|
|
3
|
-
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<%-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<%-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
</p>
|
4
|
+
<div class="item">
|
5
|
+
<div style='float:right'>
|
6
|
+
<%- if action? :edit -%>
|
7
|
+
<%%=link_to '', edit_<%= singular_name %>_path(@<%= singular_name %>), :class => 'edit tip', :title => "Edit This Item" %>
|
8
|
+
<%- end -%>
|
9
|
+
<%- if action? :destroy -%>
|
10
|
+
<%%=link_to "", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete, :class => 'destroy tip', :title => "Destroy This Item" %>
|
11
|
+
<%- end -%>
|
12
|
+
</div>
|
13
|
+
<h3><%%= link_to @<%= singular_name %>.<%= first_attribute.name %>, @<%= singular_name %> %></h3>
|
14
|
+
<p>
|
15
|
+
<%%= link_to "Preview <%= singular_name.titleize %>", @<%= singular_name %>, :class => 'remote_iframe' %>
|
16
|
+
</p>
|
17
|
+
<%- for attribute in model_attributes -%>
|
18
|
+
<p>
|
19
|
+
<strong><%= attribute.human_name.titleize %>:</strong>
|
20
|
+
<%%= @<%= singular_name %>.<%= attribute.name %> %>
|
21
|
+
</p>
|
22
|
+
<%- end -%>
|
23
|
+
</div>
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
%table
|
4
4
|
%tr
|
5
|
-
<%- for attribute in
|
6
|
-
%th <%= attribute.
|
5
|
+
<%- for attribute in model_attributes -%>
|
6
|
+
%th <%= attribute.human_name %>
|
7
7
|
<%- end -%>
|
8
8
|
- for <%= singular_name %> in @<%= plural_name %>
|
9
9
|
%tr
|
10
|
-
<%- for attribute in
|
11
|
-
%td=
|
10
|
+
<%- for attribute in model_attributes -%>
|
11
|
+
%td= <%= singular_name %>.<%= attribute.name %>
|
12
12
|
<%- end -%>
|
13
13
|
<%- if action? :show -%>
|
14
14
|
%td= link_to 'Show', <%= singular_name %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
- title "<%= singular_name.titleize %>"
|
2
2
|
|
3
|
-
<%- for attribute in
|
3
|
+
<%- for attribute in model_attributes -%>
|
4
4
|
%p
|
5
|
-
%strong <%= attribute.
|
6
|
-
=
|
5
|
+
%strong <%= attribute.human_name.titleize %>:
|
6
|
+
= @<%= singular_name %>.<%= attribute.name %>
|
7
7
|
<%- end -%>
|
8
8
|
|
9
9
|
%p
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dust-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- rossnelson
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- rails_generators/dust_scaffold/templates/tests/testunit/controller.rb
|
284
284
|
- rails_generators/dust_scaffold/templates/tests/testunit/model.rb
|
285
285
|
- rails_generators/dust_scaffold/templates/views/erb/_form.html.erb
|
286
|
+
- rails_generators/dust_scaffold/templates/views/erb/_search.html.erb
|
286
287
|
- rails_generators/dust_scaffold/templates/views/erb/edit.html.erb
|
287
288
|
- rails_generators/dust_scaffold/templates/views/erb/index.html.erb
|
288
289
|
- rails_generators/dust_scaffold/templates/views/erb/new.html.erb
|