dust-generators 0.2.4 → 0.2.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 CHANGED
@@ -2,7 +2,7 @@ class Dust
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 4
5
+ PATCH = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -14,6 +14,7 @@ module Dust
14
14
  class_option :skip_model, :desc => 'Don\'t generate a model or migration file.', :type => :boolean
15
15
  class_option :skip_migration, :desc => 'Dont generate migration file for model.', :type => :boolean
16
16
  class_option :skip_timestamps, :desc => 'Don\'t add timestamps to migration file.', :type => :boolean
17
+ class_option :skip_frontend, :desc => 'Don\'t generate a front end controller or views.', :type => :boolean
17
18
  class_option :skip_controller, :desc => 'Don\'t generate controller, helper, or views.', :type => :boolean
18
19
  class_option :invert, :desc => 'Generate all controller actions except these mentioned.', :type => :boolean
19
20
  class_option :haml, :desc => 'Generate HAML views instead of ERB.', :type => :boolean
@@ -103,6 +104,16 @@ module Dust
103
104
  template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
104
105
  end
105
106
 
107
+ unless options[:skip_frontend]
108
+ template "view_controller.rb", "app/controllers/view_#{plural_name}_controller.rb"
109
+
110
+ route("match \"all-#{plural_name}\" => \"view_#{plural_name}#index\", :as => :view_#{plural_name}")
111
+ route("match \"#{singular_name}/:filename\" => \"view_#{plural_name}#show\", :as => :view_#{singular_name}")
112
+
113
+ template "views/front_end/index.html.erb", "app/views/view_#{plural_name}/index.html.erb"
114
+ template "views/front_end/show.html.erb", "app/views/view_#{plural_name}/show.html.erb"
115
+ end
116
+
106
117
  route "resources #{plural_name.to_sym.inspect}"
107
118
 
108
119
  if test_framework == :rspec
@@ -11,7 +11,8 @@ class Create<%= plural_class_name %> < ActiveRecord::Migration
11
11
  end
12
12
 
13
13
  CmsMenuItem.create({:title =>"<%= plural_class_name %>", :controller_name => "<%= plural_name %>", :url => "/<%= plural_name %>"})
14
-
14
+ MenuItem.create({:title => "All <%=plural_class_name%>", :url => "/all-<%=plural_name%>", :active => true})
15
+
15
16
  def self.down
16
17
  drop_table :<%= plural_name %>
17
18
  end
@@ -0,0 +1,17 @@
1
+ <%- first_attribute = model_attributes.first -%>
2
+ class View<%= plural_class_name %>Controller < ApplicationController
3
+
4
+ def index
5
+ @<%= plural_name %> = <%= class_name %>.page(params[:search], params[:page])
6
+ end
7
+
8
+ def show
9
+ if <%= class_name %>.find_by_<%= first_attribute.name %>(params[:filename]) == nil
10
+ @<%= singular_name %> = <%= class_name %>.find(:first)
11
+ render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
12
+ else
13
+ @<%= singular_name %> = <%= class_name %>.find_by_<%= first_attribute.name %>(params[:filename])
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,14 @@
1
+ <%% title "<%= plural_name.titleize %>" %>
2
+ <%- first_attribute = model_attributes.first -%>
3
+
4
+ <%%= will_paginate @<%= plural_name %> %>
5
+
6
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
7
+ <div class="item">
8
+
9
+ <h3><%%= link_to <%= singular_name %>.<%= first_attribute.name %>, view_<%= singular_name %>_path(<%= singular_name %>.<%= first_attribute.name %>) %></h3>
10
+
11
+ </div>
12
+ <%% end -%>
13
+
14
+ <%%= will_paginate @<%= plural_name %> %>
@@ -0,0 +1,17 @@
1
+ <%- first_attribute = model_attributes.first -%>
2
+ <%% title @<%= singular_name %>.title %>
3
+
4
+ <%% content_tag :div, :class => "page_#{@<%= singular_name %>.id}" do %>
5
+
6
+ <%% heading @<%= singular_name %>.<%= first_attribute.name %> %>
7
+ <%%= @<%= singular_name %>.<%= first_attribute.name %> %>
8
+
9
+ <%% end %>
10
+
11
+ <%% if permitted_to? :manage, :<%= plural_name %> %>
12
+ <p>
13
+ <%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
14
+ <%%= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
15
+ <%%= link_to "View All", <%= plural_name %>_path %>
16
+ </p>
17
+ <%% end %>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 4
9
- version: 0.2.4
8
+ - 5
9
+ version: 0.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - rossnelson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-28 00:00:00 -05:00
17
+ date: 2011-05-01 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -180,12 +180,15 @@ files:
180
180
  - lib/generators/dust/scaffold/templates/tests/testunit/actions/update.rb
181
181
  - lib/generators/dust/scaffold/templates/tests/testunit/controller.rb
182
182
  - lib/generators/dust/scaffold/templates/tests/testunit/model.rb
183
+ - lib/generators/dust/scaffold/templates/view_controller.rb
183
184
  - lib/generators/dust/scaffold/templates/views/erb/_form.html.erb
184
185
  - lib/generators/dust/scaffold/templates/views/erb/_search.html.erb
185
186
  - lib/generators/dust/scaffold/templates/views/erb/edit.html.erb
186
187
  - lib/generators/dust/scaffold/templates/views/erb/index.html.erb
187
188
  - lib/generators/dust/scaffold/templates/views/erb/new.html.erb
188
189
  - lib/generators/dust/scaffold/templates/views/erb/show.html.erb
190
+ - lib/generators/dust/scaffold/templates/views/front_end/index.html.erb
191
+ - lib/generators/dust/scaffold/templates/views/front_end/show.html.erb
189
192
  - lib/generators/dust/scaffold/templates/views/haml/_form.html.haml
190
193
  - lib/generators/dust/scaffold/templates/views/haml/edit.html.haml
191
194
  - lib/generators/dust/scaffold/templates/views/haml/index.html.haml
@@ -307,7 +310,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
310
  requirements:
308
311
  - - ">="
309
312
  - !ruby/object:Gem::Version
310
- hash: 2622332876329258479
313
+ hash: 2438788916249452408
311
314
  segments:
312
315
  - 0
313
316
  version: "0"