nu-generators 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # nu generators
2
2
 
3
- personalized generator for scaffolds.
3
+ Personalized generator for scaffolds.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ``` ruby
10
+ group :development do
11
+ gem 'nu-generators', '~> 0.0.2'
12
+ end
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
4
18
 
5
19
  ## usage:
6
20
 
@@ -12,7 +12,7 @@ module Nu
12
12
  end
13
13
 
14
14
  def create_views_files
15
- views = %w(all edit show new _form)
15
+ views = %w(index show all edit new _form)
16
16
 
17
17
  views.each do |view|
18
18
  template "views/#{view}.html.erb", "app/views/#{plural_name}/#{view}.html.erb"
@@ -1,7 +1,7 @@
1
1
  class <%= class_name.pluralize %>Controller < ApplicationController
2
- #before_filter :authenticate_user!, except: [:show]
2
+ #before_filter :authenticate_user!, except: [:index, :show]
3
3
 
4
- def all
4
+ def index
5
5
  @<%= plural_table_name %> = <%= class_name.singularize %>.all
6
6
 
7
7
  respond_to do |format|
@@ -9,15 +9,24 @@ class <%= class_name.pluralize %>Controller < ApplicationController
9
9
  format.json { render json: @<%= plural_table_name %> }
10
10
  end
11
11
  end
12
-
12
+
13
13
  def show
14
- @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
14
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
15
15
 
16
16
  respond_to do |format|
17
17
  format.html # show.html.erb
18
18
  format.json { render json: @<%= singular_table_name %> }
19
19
  end
20
20
  end
21
+
22
+ def all
23
+ @<%= plural_table_name %> = <%= class_name.singularize %>.all
24
+
25
+ respond_to do |format|
26
+ format.html # all.html.erb
27
+ format.json { render json: @<%= plural_table_name %> }
28
+ end
29
+ end
21
30
 
22
31
  def new
23
32
  @<%= singular_table_name %> = <%= class_name.singularize %>.new
@@ -29,7 +38,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
29
38
  end
30
39
 
31
40
  def edit
32
- @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
41
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
33
42
  end
34
43
 
35
44
  def create
@@ -37,7 +46,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
37
46
 
38
47
  respond_to do |format|
39
48
  if @<%= singular_table_name %>.save
40
- format.html { redirect_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) }
49
+ format.html { redirect_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
41
50
  format.json { render json: @<%= singular_table_name %>, status: :created, location: @<%= singular_table_name %> }
42
51
  else
43
52
  format.html { render "new" }
@@ -47,11 +56,11 @@ class <%= class_name.pluralize %>Controller < ApplicationController
47
56
  end
48
57
 
49
58
  def update
50
- @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
59
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
51
60
 
52
61
  respond_to do |format|
53
62
  if @<%= singular_table_name %>.update_attributes(params[:<%= singular_table_name %>])
54
- format.html { redirect_to all_<%= plural_table_name %>_path }
63
+ format.html { redirect_to all_<%= plural_table_name %>_path, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
55
64
  format.json { head :ok }
56
65
  else
57
66
  format.html { render "edit" }
@@ -61,7 +70,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
61
70
  end
62
71
 
63
72
  def destroy
64
- @<%= singular_table_name %> = <%= class_name.singularize %>.find_by_slug(params[:id])
73
+ @<%= singular_table_name %> = <%= class_name.singularize %>.find(params[:id])
65
74
  @<%= singular_table_name %>.destroy
66
75
 
67
76
  respond_to do |format|
@@ -1,27 +1,31 @@
1
- <h1>Listing <%= plural_table_name %></h1>
1
+ <div class="publisher">
2
+ <h1><%%= t("publisher.listing") %> <%%= t("menu.<%= plural_table_name %>") %></h1>
3
+ <%%= link_to "+ #{t('publisher.new')}", new_<%= singular_table_name %>_path, <%= key_value :class, "'btn btn-primary'" %> %>
2
4
 
3
- <table>
4
- <tr>
5
+ <table>
6
+ <thead>
7
+ <tr>
5
8
  <% attributes.each do |attribute| -%>
6
- <th><%= attribute.human_name %></th>
9
+ <th><%= attribute.human_name %></th>
7
10
  <% end -%>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
11
+ <th></th>
12
+ </tr>
13
+ </thead>
12
14
 
13
- <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
- <tr>
15
+ <tbody>
16
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
17
+ <tr class="#cycle('odd', 'even')">
15
18
  <% attributes.each do |attribute| -%>
16
- <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
19
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
20
  <% end -%>
18
- <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
19
- <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
20
- <td><%%= link_to 'Destroy', <%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ confirm: 'Are you sure?' }" %> %></td>
21
- </tr>
22
- <%% end %>
23
- </table>
21
+ <td>
22
+ <%%= link_to t('publisher.edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), <%= key_value :class, "'btn btn-mini btn-danger'" %> %>
23
+ <%%= link_to t('publisher.destroy'), <%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ confirm: t('publisher.confirm') }" %>, <%= key_value :class, "'btn btn-mini btn-danger'" %> %></td>
24
+ </td>
25
+ </tr>
26
+ <%% end %>
27
+ </tbody>
28
+ </table>
24
29
 
25
- <br />
26
-
27
- <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
30
+ <%%= link_to "+ #{t('publisher.new')}", new_<%= singular_table_name %>_path, <%= key_value :class, "'btn btn-primary'" %> %>
31
+ </div>
@@ -1,5 +1,6 @@
1
- <div class="publisher">
2
- <h1>editing <%= singular_table_name %></h1>
1
+ <div class="publisher">
2
+ <h1><%%= t("publisher.editing") %> <%%= t("menu.<%= singular_table_name %>") %>: <%%#= @<%= singular_table_name %>.name %></h1>
3
+ <%%= link_to "« #{t('publisher.list_all')}", all_<%= plural_table_name %>_path, <%= key_value :class, "'btn'" %> %>
3
4
 
4
- <%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %> %>
5
+ <%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
5
6
  </div>
@@ -0,0 +1,21 @@
1
+ <h1>Listing <%= plural_table_name %></h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <% attributes.each do |attribute| -%>
6
+ <th><%= attribute.human_name %></th>
7
+ <% end -%>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
+ <tr>
15
+ <% attributes.each do |attribute| -%>
16
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <% end -%>
18
+ <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
19
+ </tr>
20
+ <%% end %>
21
+ </table>
@@ -1,5 +1,6 @@
1
1
  <div class="publisher">
2
- <h1>new <%= singular_table_name %></h1>
2
+ <h1><%%= t("publisher.new") %> <%%= t("menu.<%= singular_table_name %>") %></h1>
3
+ <%%= link_to "« #{t('publisher.list_all')}", all_<%= plural_table_name %>_path, <%= key_value :class, "'btn'" %> %>
3
4
 
4
5
  <%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
5
6
  </div>
@@ -1,5 +1,5 @@
1
1
  module Nu
2
2
  module Generators
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nu-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-27 00:00:00.000000000 Z
14
+ date: 2012-12-23 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: nu design custom generators
17
17
  email:
@@ -37,6 +37,7 @@ files:
37
37
  - lib/generators/nu/templates/scaffold/views/_form.html.erb
38
38
  - lib/generators/nu/templates/scaffold/views/all.html.erb
39
39
  - lib/generators/nu/templates/scaffold/views/edit.html.erb
40
+ - lib/generators/nu/templates/scaffold/views/index.html.erb
40
41
  - lib/generators/nu/templates/scaffold/views/new.html.erb
41
42
  - lib/generators/nu/templates/scaffold/views/show.html.erb
42
43
  - lib/nu-generators.rb