thesilverspoon 0.0.28 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/templates/layouts/scaffold.html.erb +32 -34
- data/lib/templates/views/erb/integrated_view.html.erb +6 -6
- data/lib/thesilverspoon.rb +2 -4
- data/lib/thesilverspoon/version.rb +1 -1
- data/thesilverspoon.gemspec +2 -1
- metadata +18 -42
- data/.gitignore~ +0 -4
- data/Gemfile~ +0 -6
- data/README.md~ +0 -149
- data/doc/README.rdoc~ +0 -12
- data/lib/integratedscaffold.rb~ +0 -299
- data/lib/templates/actions/create.rb~ +0 -12
- data/lib/templates/actions/destroy.rb~ +0 -10
- data/lib/templates/actions/edit.rb~ +0 -6
- data/lib/templates/actions/new.rb~ +0 -4
- data/lib/templates/actions/update.rb~ +0 -14
- data/lib/templates/assets/stylesheets/silverspoon.css.scss~ +0 -29
- data/lib/templates/controller.rb~ +0 -4
- data/lib/templates/layouts/application.html.erb~ +0 -80
- data/lib/templates/layouts/dummy_data.html.erb~ +0 -85
- data/lib/templates/layouts/general_layout.html.erb~ +0 -14
- data/lib/templates/model.rb~ +0 -54
- data/lib/templates/views/erb/edit.html.erb~ +0 -6
- data/lib/templates/views/erb/index.html.erb~ +0 -32
- data/lib/templates/views/erb/integrated_view.html.erb~ +0 -182
- data/lib/templates/views/erb/new.html.erb~ +0 -6
- data/lib/templates/views/erb/show.html.erb~ +0 -20
- data/lib/thesilverspoon.rb~ +0 -365
- data/lib/thesilverspoon/version.rb~ +0 -3
- data/thesilverspoon.gemspec~ +0 -39
@@ -1,85 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>BrandName</title>
|
5
|
-
<%%= stylesheet_link_tag "application" %>
|
6
|
-
<%%= javascript_include_tag "application" %>
|
7
|
-
<%%= csrf_meta_tags %>
|
8
|
-
<script type="text/javascript">
|
9
|
-
$(function() {
|
10
|
-
$(".edit_link").click(function(){
|
11
|
-
$.get("<%%=params[:controller]%>"+"/"+$(this).attr("id")+"/edit?get=1",function(data){
|
12
|
-
|
13
|
-
$("#edit_form .modal-body").html(data);
|
14
|
-
$("#edit_form").modal('toggle');
|
15
|
-
|
16
|
-
}) ;
|
17
|
-
});
|
18
|
-
});
|
19
|
-
</script>
|
20
|
-
<%%= yield(:head) %>
|
21
|
-
<style>
|
22
|
-
table td {
|
23
|
-
border: none;
|
24
|
-
}
|
25
|
-
|
26
|
-
table tr {
|
27
|
-
border: none;
|
28
|
-
}
|
29
|
-
</style>
|
30
|
-
</head>
|
31
|
-
<body>
|
32
|
-
<div id="wrapper">
|
33
|
-
<div class="topbar" style="z-index: 999999999">
|
34
|
-
<div class="fill">
|
35
|
-
<div class="container">
|
36
|
-
<a class="brand" href="/">BrandName</a>
|
37
|
-
<ul class="nav">
|
38
|
-
<!--<li><a href="#about" style="color:white;">About</a></li>-->
|
39
|
-
<!--<li><a href="#contact" style="color:white;">Contact</a></li>-->
|
40
|
-
</ul>
|
41
|
-
|
42
|
-
<%% if !user_signed_in? %>
|
43
|
-
<%%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => "pull-right"}) do |f| %>
|
44
|
-
<%%= f.email_field :email, :class=>"input-small", :placeholder=>"Email" %>
|
45
|
-
<%%= f.password_field :password, :class=>"input-small", :placeholder=>"Password" %>
|
46
|
-
<%%= f.submit "Sign In", :class=>"primary btn" %>
|
47
|
-
<%% end %>
|
48
|
-
<%% else %>
|
49
|
-
<div class="pull-right" style="margin-top: 10px;color:white;">
|
50
|
-
<%%= current_user.email %>
|
51
|
-
<span class="nav_link">
|
52
|
-
| <%%= link_to "Sign out", destroy_user_session_path, :method => :delete, :style=>"color:white;" %>
|
53
|
-
</span>
|
54
|
-
</div>
|
55
|
-
<%% end %>
|
56
|
-
</div>
|
57
|
-
</div>
|
58
|
-
</div>
|
59
|
-
<div class="container">
|
60
|
-
|
61
|
-
<div class="page-header" style="height:100px"></div>
|
62
|
-
<div style="position:absolute;margin-top: -110px;" class="span16">
|
63
|
-
<%%= yield(:page_header) %>
|
64
|
-
</div>
|
65
|
-
|
66
|
-
<div class="content">
|
67
|
-
<%%= js extend_gritter :position => :bottom_right %>
|
68
|
-
<%%= js add_gritter(flash[:notice], :image => :success, :title => "Notice", :sticky => false, :time => 2000) %>
|
69
|
-
<%%= js add_gritter(flash[:alert], :image => :warning, :title => "Alert!", :sticky => false, :time => 2000) %>
|
70
|
-
<%%= yield %>
|
71
|
-
</div>
|
72
|
-
|
73
|
-
<%% if request.fullpath=="/" %>
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
<%% end %>
|
78
|
-
</div>
|
79
|
-
</div>
|
80
|
-
|
81
|
-
<%%= javascript_include_tag "/assets/exclusions/jquery.pageslide" %>
|
82
|
-
|
83
|
-
|
84
|
-
</body>
|
85
|
-
</html>
|
data/lib/templates/model.rb~
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
class <%= class_name %> < ActiveRecord::Base
|
2
|
-
|
3
|
-
<%= " set_table_name :#{table_name}\n" if table_name -%>
|
4
|
-
|
5
|
-
# ---------------
|
6
|
-
# Accessible Attributes
|
7
|
-
# ---------------
|
8
|
-
# Only accessible attributes can be created or modified. In case, you add more attributes through a later migration,
|
9
|
-
# remember to add the attribute to the attr_accessible list. Otherwise, many an hour is lost in figuring out why data is not
|
10
|
-
# getting captured through forms...
|
11
|
-
|
12
|
-
attr_accessible <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>
|
13
|
-
|
14
|
-
# ---------------
|
15
|
-
# Associations
|
16
|
-
# ---------------
|
17
|
-
# Uncomment, copy and add you associations here...
|
18
|
-
# belongs_to :parent
|
19
|
-
# has_many :children, :dependent=>:destroy
|
20
|
-
# has_and_belongs_to_many :friends
|
21
|
-
# has_one :life
|
22
|
-
|
23
|
-
|
24
|
-
# ---------------
|
25
|
-
# Validations
|
26
|
-
# ---------------
|
27
|
-
# These are the standard validations that you might need to use with the models. Please uncomment as required...
|
28
|
-
|
29
|
-
<% model_attributes.each do |attribute|%>
|
30
|
-
# validates_presence_of :<%="#{attribute.name}" %>
|
31
|
-
<% if attribute.type==:integer -%>
|
32
|
-
# validates_numericality_of :<%="#{attribute.name}"%>
|
33
|
-
<% elsif attribute.type==:string -%>
|
34
|
-
# validates_length_of :<%= "#{attribute.name}" %> ,:maximum=>255
|
35
|
-
<% end -%>
|
36
|
-
<% end -%>
|
37
|
-
|
38
|
-
# ---------------
|
39
|
-
# Schema Information
|
40
|
-
# ---------------
|
41
|
-
# Just so that you do not have to open up the migration file to check this everytime...
|
42
|
-
|
43
|
-
<% model_attributes.each do |attribute| %>
|
44
|
-
# <%= attribute.name %>:<%=attribute.type %>
|
45
|
-
<% end %>
|
46
|
-
|
47
|
-
# ---------------
|
48
|
-
# Scope
|
49
|
-
# ---------------
|
50
|
-
# Consider using a model scope if you find yourself having to use 'order' too frequently in your finds
|
51
|
-
|
52
|
-
# default_scope order('created_at DESC')
|
53
|
-
|
54
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
<%%= content_for :page_header do %>
|
3
|
-
<%% "<%= plural_name.titleize %>" %>
|
4
|
-
<%% end %>
|
5
|
-
|
6
|
-
<table>
|
7
|
-
<tr>
|
8
|
-
<%- for attribute in model_attributes -%>
|
9
|
-
<th><%= attribute.human_name.titleize %></th>
|
10
|
-
<%- end -%>
|
11
|
-
</tr>
|
12
|
-
<%% for <%= instance_name %> in @<%= instances_name %> %>
|
13
|
-
<tr>
|
14
|
-
<%- for attribute in model_attributes -%>
|
15
|
-
<td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
|
16
|
-
<%- end -%>
|
17
|
-
<%- if action? :show -%>
|
18
|
-
<td><%%= link_to "Show", <%= item_path %> %></td>
|
19
|
-
<%- end -%>
|
20
|
-
<%- if action? :edit -%>
|
21
|
-
<td><%%= link_to "Edit", <%= item_path :action => :edit %> %></td>
|
22
|
-
<%- end -%>
|
23
|
-
<%- if action? :destroy -%>
|
24
|
-
<td><%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
25
|
-
<%- end -%>
|
26
|
-
</tr>
|
27
|
-
<%% end %>
|
28
|
-
</table>
|
29
|
-
|
30
|
-
<%- if action? :new -%>
|
31
|
-
<p><%%= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %> %></p>
|
32
|
-
<%- end -%>
|
@@ -1,182 +0,0 @@
|
|
1
|
-
<%%= content_for :head do %>
|
2
|
-
<%%= stylesheet_link_tag "/assets/exclusions/jquery_data_table" %>
|
3
|
-
|
4
|
-
<%# TODO: Move Script and CSS to unobtrusive files %>
|
5
|
-
<script type="text/javascript">
|
6
|
-
$(function() {
|
7
|
-
$('#example').dataTable({
|
8
|
-
"bJQueryUI": true,
|
9
|
-
"sPaginationType": "full_numbers"
|
10
|
-
});
|
11
|
-
|
12
|
-
$('form').submit(function() {
|
13
|
-
|
14
|
-
$('form').append("<input type='hidden' name='integrated_view' value='yes'> ");
|
15
|
-
return true;
|
16
|
-
|
17
|
-
});
|
18
|
-
|
19
|
-
})
|
20
|
-
</script>
|
21
|
-
<%% end %>
|
22
|
-
|
23
|
-
<%%= content_for :page_header do %>
|
24
|
-
<div class="pull-left" style="border: none;"><%%= image_tag('logo.png') %></div>
|
25
|
-
<%% end %>
|
26
|
-
|
27
|
-
<div class="row">
|
28
|
-
|
29
|
-
<div class="span4" style="text-align: center">
|
30
|
-
<div class="pageslide_header">
|
31
|
-
<h1>"<%= plural_name.titleize %>"</h1>
|
32
|
-
</div>
|
33
|
-
<br/>
|
34
|
-
<br/>
|
35
|
-
<table>
|
36
|
-
<tr>
|
37
|
-
<td>
|
38
|
-
<a href="#" data-controls-modal="new_form" data-backdrop="static">
|
39
|
-
<%%= image_tag('new.png', :size=>"32x32") %>
|
40
|
-
</a>
|
41
|
-
</td>
|
42
|
-
<td>
|
43
|
-
<a href="#" data-controls-modal="new_form" data-backdrop="static">
|
44
|
-
<h2>Create New</h2>
|
45
|
-
</a>
|
46
|
-
|
47
|
-
<div id="new_form" class="modal hide fade">
|
48
|
-
<div class="modal-header">
|
49
|
-
<a href="#" class="close"> × </a>
|
50
|
-
|
51
|
-
<h3>Create new record</h3>
|
52
|
-
</div>
|
53
|
-
<div class ="modal-body">
|
54
|
-
<%%= render 'form' %>
|
55
|
-
</div>
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
<div id="edit_form" class="modal hide fade">
|
60
|
-
<div class="modal-header">
|
61
|
-
<a href="#" class="close"> × </a>
|
62
|
-
|
63
|
-
<h3>Edit a record</h3>
|
64
|
-
</div>
|
65
|
-
<div class="modal-body">
|
66
|
-
|
67
|
-
</div>
|
68
|
-
</div>
|
69
|
-
|
70
|
-
|
71
|
-
<br>
|
72
|
-
<br>
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
</td>
|
77
|
-
</tr>
|
78
|
-
<tr>
|
79
|
-
<td>
|
80
|
-
<a href="#" data-controls-modal="upload_form" data-backdrop="static">
|
81
|
-
<%%= image_tag('upload.png', :size=>"32x32") %>
|
82
|
-
</a>
|
83
|
-
</td>
|
84
|
-
<td>
|
85
|
-
<a href="#" data-controls-modal="upload_form" data-backdrop="static">
|
86
|
-
<h2>Upload</h2>
|
87
|
-
</a>
|
88
|
-
|
89
|
-
<div id="upload_form" class="modal hide fade">
|
90
|
-
<div class="modal-header">
|
91
|
-
<a href="#" class="close"> × </a>
|
92
|
-
|
93
|
-
<h3>Upload Excel File</h3>
|
94
|
-
</div>
|
95
|
-
<%%= form_tag('/<%= instance_name %>/parse_save_from_excel', :multipart => true) do |f| %>
|
96
|
-
<div class="modal-body">
|
97
|
-
Select an Excel File :
|
98
|
-
<%%= file_field_tag :excel_file %>
|
99
|
-
</div>
|
100
|
-
|
101
|
-
<div class="modal-footer">
|
102
|
-
<%%= submit_tag 'Submit', :class=>"large btn primary pull-left" %>
|
103
|
-
</div>
|
104
|
-
<%% end -%>
|
105
|
-
|
106
|
-
</div>
|
107
|
-
|
108
|
-
|
109
|
-
</td>
|
110
|
-
</tr>
|
111
|
-
<tr>
|
112
|
-
<td>
|
113
|
-
<a href="<%%=<%= item_path :action => :new %> %>" class="add_new span3">
|
114
|
-
<%%= image_tag('download.png', :size=>"32x32") %>
|
115
|
-
</a>
|
116
|
-
</td>
|
117
|
-
<td>
|
118
|
-
<a href=" <%%=<%= item_path :action => :new %> %>" class="add_new span3">
|
119
|
-
<h2>Download</h2>
|
120
|
-
</a>
|
121
|
-
</td>
|
122
|
-
</tr>
|
123
|
-
|
124
|
-
</table>
|
125
|
-
|
126
|
-
</div>
|
127
|
-
|
128
|
-
<div class="span12">
|
129
|
-
<table class="jqueried_table display" cellpadding="0" cellspacing="0" border="0" id="example">
|
130
|
-
<thead>
|
131
|
-
<tr>
|
132
|
-
<%- for attribute in @model_attributes -%>
|
133
|
-
<th><%= attribute.human_name.titleize %></th>
|
134
|
-
<%- end -%>
|
135
|
-
<th>Manage</th>
|
136
|
-
</tr>
|
137
|
-
</thead>
|
138
|
-
<tbody>
|
139
|
-
<%% @<%= instances_name %>.each do |<%= instance_name %>| %>
|
140
|
-
<tr>
|
141
|
-
<%- for attribute in @model_attributes -%>
|
142
|
-
<td style="border-right: 1px solid #d3d3d3">
|
143
|
-
<a href="#" data-controls-modal="show_details" data-backdrop="static"><%%= <%= instance_name %>
|
144
|
-
.<%= attribute.name %> %></a>
|
145
|
-
</td>
|
146
|
-
<%- end %>
|
147
|
-
|
148
|
-
<td class="options">
|
149
|
-
<a href="#" id="<%%= <%= instance_name %>.id %> "class="edit_link" >Edit</a>|
|
150
|
-
<%%= link_to "Destroy", <%= item_path %>_path(:id=><%= instance_name %>.id,:integrated_view=>"yes"),:confirm => 'Are you sure?', :method => :delete %>
|
151
|
-
</td>
|
152
|
-
</tr>
|
153
|
-
|
154
|
-
|
155
|
-
<div id="show_details" class="modal hide fade">
|
156
|
-
<div class="modal-header">
|
157
|
-
<a href="#" class="close"> × </a>
|
158
|
-
|
159
|
-
<h3><%%= "<%= singular_name.titleize %>" %></h3>
|
160
|
-
</div>
|
161
|
-
<div class="modal-body">
|
162
|
-
<%- for attribute in model_attributes -%>
|
163
|
-
<p>
|
164
|
-
<strong><%= attribute.human_name.titleize %>:</strong>
|
165
|
-
<%%= <%= instance_name %>.<%= attribute.name %> %>
|
166
|
-
</p>
|
167
|
-
|
168
|
-
<%- end -%>
|
169
|
-
</div>
|
170
|
-
|
171
|
-
<div class="modal-footer">
|
172
|
-
<a href="#" class="close"> Back </a>
|
173
|
-
</div>
|
174
|
-
</div>
|
175
|
-
<%%- end -%>
|
176
|
-
</tbody>
|
177
|
-
</table>
|
178
|
-
|
179
|
-
</div>
|
180
|
-
|
181
|
-
</div>
|
182
|
-
<br/>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<span style="color:white"><%% "<%= singular_name.titleize %>" %></span>
|
2
|
-
|
3
|
-
<%- for attribute in model_attributes -%>
|
4
|
-
<p>
|
5
|
-
<strong><%= attribute.human_name.titleize %>:</strong>
|
6
|
-
<%%= @<%= instance_name %>.<%= attribute.name %> %>
|
7
|
-
</p>
|
8
|
-
<%- end -%>
|
9
|
-
|
10
|
-
<p>
|
11
|
-
<%- if action? :edit -%>
|
12
|
-
<%%= link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %> %> |
|
13
|
-
<%- end -%>
|
14
|
-
<%- if action? :destroy -%>
|
15
|
-
<%%= link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete %> |
|
16
|
-
<%- end -%>
|
17
|
-
<%- if action? :index -%>
|
18
|
-
<%%= link_to "View All", <%= items_path %> %>
|
19
|
-
<%- end -%>
|
20
|
-
</p>
|
data/lib/thesilverspoon.rb~
DELETED
@@ -1,365 +0,0 @@
|
|
1
|
-
require "thesilverspoon/version"
|
2
|
-
# Require the RAILS generators to be able to extend Rails:Generators::NamedBase
|
3
|
-
require 'rails/generators'
|
4
|
-
#sample module
|
5
|
-
module Everything
|
6
|
-
# If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
|
7
|
-
class Scaffold < Rails::Generators::NamedBase
|
8
|
-
|
9
|
-
# Method in the 'thor' library which gives you access to the accessor methods
|
10
|
-
no_tasks { attr_accessor :model_attributes, :controller_actions }
|
11
|
-
|
12
|
-
# This captures the arguments that the generator can take after "rails g integratedscaffold name"
|
13
|
-
argument :g_parameters, :type => :array, :default => [], :banner => "field:type field:type"
|
14
|
-
|
15
|
-
# this sets the path where the code looks for templates within the gem
|
16
|
-
def self.source_root
|
17
|
-
File.expand_path("../templates", __FILE__)
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(*args, &block)
|
21
|
-
|
22
|
-
# This is a standard initializer
|
23
|
-
|
24
|
-
super # Call parent class
|
25
|
-
@model_attributes = [] # Initialize empty array for 'thor' attributes
|
26
|
-
|
27
|
-
# This method splits the name:type arguments in the parameters list
|
28
|
-
g_parameters.each do |arg|
|
29
|
-
@model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
|
30
|
-
end
|
31
|
-
|
32
|
-
# Creates a list of all the standard actions in the controller
|
33
|
-
@controller_actions=all_actions
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def create_model
|
39
|
-
|
40
|
-
# creates the model using the 'model.rb' template and puts it into the rails app
|
41
|
-
template 'model.rb', "app/models/#{model_path}.rb"
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_controller
|
46
|
-
|
47
|
-
# creates the controller using the 'controller.rb' template and puts it into the rails app
|
48
|
-
template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_migration
|
52
|
-
|
53
|
-
# creates the migration file using the 'migration.rb' template and puts it into the rails app with a time stamp
|
54
|
-
template 'migration.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_#{model_path.pluralize.gsub('/', '_')}.rb"
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def create_helper
|
59
|
-
|
60
|
-
# creates the helper using the 'helper.rb' template and puts it into the rails app
|
61
|
-
template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
|
62
|
-
end
|
63
|
-
|
64
|
-
def create_routes
|
65
|
-
|
66
|
-
# adds the routes for the gem into the routes file
|
67
|
-
namespaces = plural_name.split('/')
|
68
|
-
resource = namespaces.pop
|
69
|
-
route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
|
70
|
-
"namespace(:#{namespace}){ #{acc} }"
|
71
|
-
}
|
72
|
-
|
73
|
-
s=%{match "#{resource}_integrated_view"=>"#{resource}#integrated_view"\n}
|
74
|
-
|
75
|
-
inject_into_file "config/routes.rb", s, :after=>"resources :#{resource}\n"
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
def create_views
|
81
|
-
|
82
|
-
# creates the standard views using the '[action].html.erb' templates and puts it into the rails app
|
83
|
-
controller_actions.each do |action|
|
84
|
-
if action!="create" and action!="update" and action!="destroy" and action!="parse_save_from_excel"
|
85
|
-
template "views/erb/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
if form_partial?
|
89
|
-
template "views/erb/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def class_name
|
96
|
-
name.camelize
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def model_path
|
101
|
-
name.underscore
|
102
|
-
end
|
103
|
-
|
104
|
-
def controller_methods(dir_name)
|
105
|
-
controller_actions.map do |action|
|
106
|
-
read_template("#{dir_name}/#{action}.rb")
|
107
|
-
end.join("\n").strip
|
108
|
-
end
|
109
|
-
|
110
|
-
def read_template(relative_path)
|
111
|
-
ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
|
112
|
-
end
|
113
|
-
|
114
|
-
def instance_name
|
115
|
-
if @namespace_model
|
116
|
-
singular_name.gsub('/', '_')
|
117
|
-
else
|
118
|
-
singular_name.split('/').last
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def instances_name
|
123
|
-
instance_name.pluralize
|
124
|
-
end
|
125
|
-
|
126
|
-
def all_actions
|
127
|
-
%w[index show new create edit update destroy]
|
128
|
-
end
|
129
|
-
|
130
|
-
def item_resource
|
131
|
-
name.underscore.gsub('/', '_')
|
132
|
-
end
|
133
|
-
|
134
|
-
def items_path
|
135
|
-
if action? :index
|
136
|
-
"#{item_resource.pluralize}_path"
|
137
|
-
else
|
138
|
-
"root_path"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def item_path(options = {})
|
143
|
-
name = options[:instance_variable] ? "@#{instance_name}" : instance_name
|
144
|
-
suffix = options[:full_url] ? "url" : "path"
|
145
|
-
if options[:action].to_s == "new"
|
146
|
-
"new_#{item_resource}_#{suffix}"
|
147
|
-
elsif options[:action].to_s == "edit"
|
148
|
-
"edit_#{item_resource}_#{suffix}(#{name})"
|
149
|
-
else
|
150
|
-
if name.include?('::') && !@namespace_model
|
151
|
-
namespace = singular_name.split('/')[0..-2]
|
152
|
-
"[:#{namespace.join(', :')}, #{name}]"
|
153
|
-
else
|
154
|
-
name
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def item_url
|
160
|
-
if action? :show
|
161
|
-
item_path(:full_url => true, :instance_variable => true)
|
162
|
-
else
|
163
|
-
items_url
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def items_url
|
168
|
-
if action? :index
|
169
|
-
item_resource.pluralize + '_url'
|
170
|
-
else
|
171
|
-
"root_url"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
|
176
|
-
def plural_name
|
177
|
-
name.underscore.pluralize
|
178
|
-
end
|
179
|
-
|
180
|
-
def form_partial?
|
181
|
-
actions? :new, :edit
|
182
|
-
end
|
183
|
-
|
184
|
-
def all_actions
|
185
|
-
%w[index show new create edit update destroy parse_save_from_excel integrated_view]
|
186
|
-
end
|
187
|
-
|
188
|
-
def action?(name)
|
189
|
-
controller_actions.include? name.to_s
|
190
|
-
end
|
191
|
-
|
192
|
-
def actions?(*names)
|
193
|
-
names.all? { |name| action? name }
|
194
|
-
end
|
195
|
-
|
196
|
-
def add_gem(name, options = {})
|
197
|
-
gemfile_content = File.read(destination_path("Gemfile"))
|
198
|
-
File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
|
199
|
-
gem name, options unless gemfile_content.include? name
|
200
|
-
end
|
201
|
-
|
202
|
-
def destination_path(path)
|
203
|
-
File.join(destination_root, path)
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
# If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
|
208
|
-
|
209
|
-
|
210
|
-
end
|
211
|
-
#endd of class
|
212
|
-
|
213
|
-
end
|
214
|
-
module Thesilverspoon
|
215
|
-
class Install < Rails::Generators::Base
|
216
|
-
|
217
|
-
def self.source_root
|
218
|
-
File.expand_path("../templates", __FILE__)
|
219
|
-
end
|
220
|
-
|
221
|
-
|
222
|
-
def initialize(*args, &block)
|
223
|
-
super
|
224
|
-
#now we invokde generators off twitter boootstrap and gritter
|
225
|
-
Rails::Generators.invoke('bootstrap:install')
|
226
|
-
Rails::Generators.invoke('gritter:locale')
|
227
|
-
Rails::Generators.invoke('devise:install')
|
228
|
-
Rails::Generators.invoke('devise', ["user"])
|
229
|
-
Rails::Generators.invoke('devise:views')
|
230
|
-
Rails::Generators.invoke('cancan:ability')
|
231
|
-
Rails::Generators.invoke('migration', ["add_role_to_user", ["admin:boolean"]])
|
232
|
-
Rails::Generators.invoke('controller',["welcome",["index"]])
|
233
|
-
Rails::Generators.invoke('rails_admin:install')
|
234
|
-
end
|
235
|
-
|
236
|
-
def create_new_user
|
237
|
-
s="\nUser.create!(:email=>'admin@tss.com',:password=>'secret',:password_confirmation=>'secret',:admin=>true)"
|
238
|
-
append_to_file "db/seeds.rb", s
|
239
|
-
inject_into_file "app/models/user.rb",",:admin",:after=>" attr_accessible :email, :password, :password_confirmation, :remember_me"
|
240
|
-
|
241
|
-
end
|
242
|
-
|
243
|
-
def create_root_route
|
244
|
-
|
245
|
-
s="root"
|
246
|
-
s=s+":to=>"
|
247
|
-
s=s+"'welcome#index'\n"
|
248
|
-
|
249
|
-
# append_to_file "config/routes.rb",s
|
250
|
-
inject_into_file "config/routes.rb",s,:after=>"# root :to => 'welcome#index'\n"
|
251
|
-
|
252
|
-
end
|
253
|
-
|
254
|
-
def create_appplication_helper
|
255
|
-
remove_file "app/helpers/application_helper.rb"
|
256
|
-
template 'application_helper.rb', "app/helpers/application_helper.rb"
|
257
|
-
end
|
258
|
-
|
259
|
-
def create_uploader
|
260
|
-
#creates the uploader ruby file using carrierwave
|
261
|
-
template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
|
262
|
-
end
|
263
|
-
|
264
|
-
def create_images
|
265
|
-
|
266
|
-
# copies the standard images into the assets/images folder
|
267
|
-
@images=Array.new
|
268
|
-
@images= Dir.entries("#{Install.source_root}/assets/images")
|
269
|
-
@images.each do |image|
|
270
|
-
|
271
|
-
if image!=".." and image !="."
|
272
|
-
copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
def create_javascripts
|
280
|
-
|
281
|
-
# copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
|
282
|
-
# : Remove the hardcoding for the javascripts inclusion
|
283
|
-
|
284
|
-
copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
def create_stylesheet
|
289
|
-
template "#{Install.source_root}/assets/stylesheets/silverspoon.css.scss", "app/assets/stylesheets/silverspoon.css.scss"
|
290
|
-
template "#{Install.source_root}/assets/stylesheets/base_classes.css.scss", "app/assets/stylesheets/base_classes.css.scss"
|
291
|
-
template "#{Install.source_root}/assets/stylesheets/silverspoon.css.scss", "app/assets/stylesheets/information_page.css.scss"
|
292
|
-
template "#{Install.source_root}/assets/stylesheets/jquery-ui-1.8.17.custom.css", "app/assets/stylesheets/jquery-ui-1.8.17.custom.css"
|
293
|
-
|
294
|
-
|
295
|
-
end
|
296
|
-
|
297
|
-
def create_stylesheets_exclusions
|
298
|
-
|
299
|
-
# copies the sequenced css into the assets/stylesheets/exclusions folder
|
300
|
-
directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
|
301
|
-
end
|
302
|
-
|
303
|
-
def create_javascript_exclusions
|
304
|
-
|
305
|
-
# copies the sequenced javascript into the assets/javascripts/exclusions folder
|
306
|
-
directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
|
307
|
-
end
|
308
|
-
|
309
|
-
def create_stylesheet_images
|
310
|
-
|
311
|
-
# copies the dependent css images into the assets/stylesheets/images folder
|
312
|
-
directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"
|
313
|
-
|
314
|
-
end
|
315
|
-
|
316
|
-
|
317
|
-
def create_layouts
|
318
|
-
=begin
|
319
|
-
#remove hardcoding and make a loop for including all files in this folder
|
320
|
-
=end
|
321
|
-
remove_file "app/views/layouts/application.html.erb"
|
322
|
-
template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
|
323
|
-
template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
|
324
|
-
#template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
|
325
|
-
# template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
|
326
|
-
# template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"
|
327
|
-
|
328
|
-
end
|
329
|
-
|
330
|
-
def insert_devise_code
|
331
|
-
inject_into_file "config/application.rb", 'require "devise"', :after=>"require File.expand_path('../boot', __FILE__)\n"
|
332
|
-
# inject_into_file "config/application.rb", "require 'bootstrap-sass'\n", :after=>"require File.expand_path('../boot', __FILE__)\n"
|
333
|
-
inject_into_file "config/application.rb", "require 'bootstrapped'\n", :after=>"require 'rails/all'\n"
|
334
|
-
inject_into_file "config/application.rb", "require 'gritter'\n", :after=>"require 'rails/all'\n"
|
335
|
-
|
336
|
-
|
337
|
-
inject_into_file "app/assets/stylesheets/application.css", '*=require_directory', :before=>"*/"
|
338
|
-
|
339
|
-
append_to_file "app/assets/javascripts/application.js", '//= require bootstrap'
|
340
|
-
inject_into_file "app/controllers/application_controller.rb", "before_filter :authenticate_user!\n", :after=>" protect_from_forgery\n"
|
341
|
-
|
342
|
-
|
343
|
-
end
|
344
|
-
|
345
|
-
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
|
350
|
-
module Revert
|
351
|
-
# If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
|
352
|
-
class Layout < Rails::Generators::Base
|
353
|
-
|
354
|
-
def self.source_root
|
355
|
-
File.expand_path("../templates", __FILE__)
|
356
|
-
end
|
357
|
-
def initialize(*args, &block)
|
358
|
-
super
|
359
|
-
remove_file "app/views/layouts/application.html.erb"
|
360
|
-
template "#{Layout.source_root}/layouts/general_layout.html.erb",'app/views/layouts/application.html.erb'
|
361
|
-
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|