nsweb-generators 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,10 +1,2 @@
1
1
  source 'http://rubygems.org'
2
2
  gemspec
3
-
4
- #gem 'rails', '3.0.3'
5
- #gem 'sqlite3-ruby', :require => 'sqlite3'
6
- #
7
- #group :test, :development do
8
- # gem 'rspec-rails', '~> 2.0.1'
9
- # gem 'cucumber', '~> 0.9.2'
10
- #end
@@ -34,14 +34,15 @@ module Nsweb
34
34
  "#{plural_file_path}_helper.rb")
35
35
  end
36
36
 
37
- #controller_actions.each do |action|
38
- # if %w[index show new edit].include?(action)
39
- # template "views/#{action}.html.erb", File.join(plugin_path,
40
- # "app/views/#{file_name}/#{action}.html.erb")
37
+ controller_actions.each do |action|
38
+ if %w[index show new edit].include?(action)
39
+ template "views/#{action}.html.erb", File.join(plugin_path,
40
+ "app/views/#{file_name}/#{action}.html.erb")
41
41
 
42
42
 
43
- # end
44
- #end
43
+ end
44
+ end
45
+ template 'views/_form.html.erb', File.join(plugin_path, "app/views/#{file_name}/_form.html.erb")
45
46
 
46
47
  if class_path.length < 0
47
48
  plugin_route("resources #{plural_file_name.to_sym.inspect},
@@ -68,6 +69,14 @@ module Nsweb
68
69
  def all_actions
69
70
  %w[index show new create edit update destroy]
70
71
  end
72
+
73
+ def action?(name)
74
+ controller_actions.include? name.to_s
75
+ end
76
+
77
+ def actions?(*names)
78
+ names.all? { |name| action? name }
79
+ end
71
80
  end
72
81
  end
73
82
  end
@@ -0,0 +1,12 @@
1
+ <%%= form_for @<%= singular_name %> do |f| %>
2
+ <%% f.error_messages %>
3
+ <fieldset>
4
+ <dl class="formfields clearfix">
5
+ <dt><%%= f.label :<%= singular_name %>_CHANGEME %></dt>
6
+ <dd><%%= f.CHANGEME :CHANGEME, :id => '<%= singular_name %>_CHANGEME' %></dd>
7
+ </dl>
8
+ <p class="centertext"
9
+ <%%= f.submit %>
10
+ </p>
11
+ </fieldset>
12
+ <%% end %>
@@ -0,0 +1,14 @@
1
+ <h2>Edit <%= singular_name.titleize %></h2>
2
+
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 -%>
@@ -1 +1,34 @@
1
- <h2>Template for <%= engine_name.titleize %><%= plural_file_name.titleize %>.index</h2>
1
+ <h2><%= plural_name.titleize %></h2>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>CHANGEME</th>
7
+ <th><%= I18n.t 'actions' %></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <%% for <%= singular_name %> in @<%= plural_name %> %>
12
+ <tr>
13
+ <td><%%= <%= singular_name %>.CHANGEME %></td>
14
+ <td>
15
+ <%- if action? :show -%>
16
+ <%%= link_to "Show", <%= singular_name %> %> |
17
+ <%- end -%>
18
+ <%- if action? :edit -%>
19
+ <%%= link_to "Edit", edit_<%= singular_name %>_path(<%= singular_name %>) %> |
20
+ <%- end -%>
21
+ <%- if action? :destroy -%>
22
+ <%%= link_to "Destroy", <%= singular_name %>, :confirm => I18n.t('Are you sure?'), :method => :delete %>
23
+ <%- end -%>
24
+ </td>
25
+ </tr>
26
+ <%% end %>
27
+ </tbody>
28
+ </table>
29
+
30
+ <%- if action? :new -%>
31
+ <p>
32
+ <%%= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path %>
33
+ </p>
34
+ <%- end -%>
@@ -0,0 +1,9 @@
1
+ <h2>New <%= singular_name.titleize %></h2>
2
+
3
+ <%%= render :form %>
4
+
5
+ <%- if action? :index -%>
6
+ <p>
7
+ <%%= link_to "Back to List", <%= plural_name %>_path %>
8
+ </p>
9
+ <%- end -%>
@@ -0,0 +1,18 @@
1
+ <h2><%= singular_name.titleize %></h2>
2
+
3
+ <dl>
4
+ <dt>CHANGEME</dt>
5
+ <dd><%%= @<%= singular_name %>.CHANGEME %></dd>
6
+ </dl>
7
+
8
+ <p>
9
+ <%- if action? :edit -%>
10
+ <%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
11
+ <%- end -%>
12
+ <%- if action? :destroy -%>
13
+ <%%= link_to "Destroy", @<%= singular_name %>, :confirm => I18n.t('Are you sure?'), :method => :delete %> |
14
+ <%- end -%>
15
+ <%- if action? :index -%>
16
+ <%%= link_to "View All", <%= plural_name %>_path %>
17
+ <%- end -%>
18
+ </p>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsweb-generators
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Williams
@@ -112,7 +112,11 @@ files:
112
112
  - lib/generators/nsweb/controller/templates/controller.rb
113
113
  - lib/generators/nsweb/controller/templates/helper.rb
114
114
  - lib/generators/nsweb/controller/templates/tests/rspec.rb
115
+ - lib/generators/nsweb/controller/templates/views/_form.html.erb
116
+ - lib/generators/nsweb/controller/templates/views/edit.html.erb
115
117
  - lib/generators/nsweb/controller/templates/views/index.html.erb
118
+ - lib/generators/nsweb/controller/templates/views/new.html.erb
119
+ - lib/generators/nsweb/controller/templates/views/show.html.erb
116
120
  - lib/generators/nsweb/model/model_generator.rb
117
121
  - lib/generators/nsweb/model/templates/migration.rb
118
122
  - lib/generators/nsweb/model/templates/model.rb