angularjs_scaffold 0.0.16 → 0.0.17
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/MIT-LICENSE +1 -1
- data/README.md +25 -0
- data/lib/angularjs_scaffold/version.rb +1 -1
- data/lib/generators/angularjs/install/install_generator.rb +13 -7
- data/lib/generators/angularjs/scaffold/scaffold_generator.rb +18 -6
- data/lib/generators/angularjs/scaffold/templates/index.html +3 -7
- metadata +3 -3
- data/README +0 -18
data/MIT-LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## AngularjsScaffold
|
2
|
+
|
3
|
+
A rails plugin for scaffolding views using Angular.js, Twitter bootstrap
|
4
|
+
and font awesome
|
5
|
+
|
6
|
+
This project uses MIT-LICENSE.
|
7
|
+
|
8
|
+
First install the gem or add it to your Gemfile:
|
9
|
+
|
10
|
+
$ gem install angularjs_scaffold
|
11
|
+
|
12
|
+
Second install it, this will add angularjs, bootstrap and fontawesome (there's an option to only install AngularJS)
|
13
|
+
|
14
|
+
$ rails g angularjs:install # adds angular.js and a dummy welcome JS controller
|
15
|
+
|
16
|
+
Run your usual scaffold command:
|
17
|
+
|
18
|
+
$ rails g scaffold Post title:string body:string
|
19
|
+
$ rake db:migrate
|
20
|
+
|
21
|
+
Now run the angularjs command and it will rewrite everything the AngularJS way:
|
22
|
+
|
23
|
+
$ rails g angularjs:scaffold Posts # adds everything needed using AngularJS
|
24
|
+
|
25
|
+
Enjoy!
|
@@ -8,13 +8,20 @@ module Angularjs
|
|
8
8
|
class_option 'no-bootstrap', :type => :boolean, :aliases => ["-nb"],
|
9
9
|
desc: "Don't include bootstrap"
|
10
10
|
|
11
|
-
|
12
11
|
def init_angularjs
|
12
|
+
def init_angularjs
|
13
13
|
if File.exist?('app/assets/javascripts/application.js')
|
14
14
|
insert_into_file "app/assets/javascripts/application.js",
|
15
15
|
"//= require_tree ./angularjs/\n", :after => "jquery_ujs\n"
|
16
16
|
else
|
17
17
|
copy_file "application.js", "app/assets/javascripts/application.js"
|
18
18
|
end
|
19
|
+
@application_css_file ='app/assets/stylesheets/application.css'
|
20
|
+
if (!(File.exist?('app/assets/stylesheets/application.css')) &&
|
21
|
+
File.exist?('app/assets/stylesheets/application.css.scss'))
|
22
|
+
@application_css_file ='app/assets/stylesheets/application.css.scss'
|
23
|
+
elsif !File.exist?('app/assets/stylesheets/application.css')
|
24
|
+
create_file @application_css_file
|
25
|
+
end
|
19
26
|
directory "underscore", "app/assets/javascripts/underscoree/"
|
20
27
|
directory "angularjs", "app/assets/javascripts/angularjs/"
|
21
28
|
if options["no-jquery"]
|
@@ -24,7 +31,6 @@ module Angularjs
|
|
24
31
|
/\/\/= require jquery\n/, ''
|
25
32
|
#gsub_file "app/assets/javascripts/application.js",
|
26
33
|
# /^$\n/, ''
|
27
|
-
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
@@ -35,15 +41,15 @@ module Angularjs
|
|
35
41
|
directory "bootstrap/css", "app/assets/stylesheets/bootstrap/"
|
36
42
|
directory "bootstrap/js", "app/assets/javascripts/bootstrap/"
|
37
43
|
directory "bootstrap/img", "app/assets/images/bootstrap/"
|
38
|
-
insert_into_file
|
44
|
+
insert_into_file @application_css_file,
|
39
45
|
" *= require bootstrap/bootstrap.min.css\n", :after => "require_self\n"
|
40
|
-
insert_into_file
|
46
|
+
insert_into_file @application_css_file,
|
41
47
|
" *= require bootstrap/bootstrap-responsive.min.css\n",
|
42
48
|
:after => "bootstrap.min.css\n"
|
43
|
-
insert_into_file
|
49
|
+
insert_into_file @application_css_file,
|
44
50
|
" *= require fontawesome/font-awesome.css\n",
|
45
51
|
:after => "bootstrap-responsive.min.css\n"
|
46
|
-
append_to_file
|
52
|
+
append_to_file @application_css_file,
|
47
53
|
"\nbody { padding-top: 60px; }\n"
|
48
54
|
unless options["no-jquery"]
|
49
55
|
insert_into_file "app/assets/javascripts/application.js",
|
@@ -74,7 +80,7 @@ module Angularjs
|
|
74
80
|
"//= require routes\n"
|
75
81
|
append_to_file "app/assets/javascripts/application.js",
|
76
82
|
"//= require welcome_controller\n"
|
77
|
-
append_to_file
|
83
|
+
append_to_file @application_css_file,
|
78
84
|
".center {text-align: center;}\n"
|
79
85
|
insert_into_file "app/controllers/application_controller.rb",
|
80
86
|
%{
|
@@ -7,18 +7,30 @@ module Angularjs
|
|
7
7
|
argument :controller_name, :type => :string
|
8
8
|
|
9
9
|
def init_vars
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
@model_name = controller_name.singularize #"Post"
|
11
|
+
@controller = controller_name #"Posts"
|
12
|
+
@resource_name = @model_name.demodulize.underscore #post
|
13
|
+
@plural_model_name = @resource_name.pluralize #posts
|
14
|
+
@model_name.constantize.columns.
|
15
|
+
each{|c|
|
16
|
+
(['name','title'].include?(c.name)) ? @resource_legend = c.name.capitalize : ''}
|
17
|
+
@resource_legend = 'ID' if @resource_legend.blank?
|
14
18
|
end
|
15
19
|
|
16
20
|
def columns
|
17
21
|
begin
|
18
22
|
excluded_column_names = %w[id _id _type created_at updated_at]
|
19
|
-
@model_name.constantize.columns.
|
23
|
+
@model_name.constantize.columns.
|
24
|
+
reject{|c| excluded_column_names.include?(c.name) }.
|
25
|
+
collect{|c| ::Rails::Generators::GeneratedAttribute.
|
26
|
+
new(c.name, c.type)}
|
20
27
|
rescue NoMethodError
|
21
|
-
@model_name.constantize.fields.
|
28
|
+
@model_name.constantize.fields.
|
29
|
+
collect{|c| c[1]}.
|
30
|
+
reject{|c| excluded_column_names.include?(c.name) }.
|
31
|
+
collect{|c|
|
32
|
+
::Rails::Generators::GeneratedAttribute.
|
33
|
+
new(c.name, c.type.to_s)}
|
22
34
|
end
|
23
35
|
end
|
24
36
|
|
@@ -2,16 +2,16 @@
|
|
2
2
|
<table class="table table-striped">
|
3
3
|
<thead>
|
4
4
|
<tr>
|
5
|
-
<th
|
6
|
-
<th>Actions</th>
|
5
|
+
<th><%= @resource_legend %></th>
|
7
6
|
<th>Created at</th>
|
7
|
+
<th>Actions</th>
|
8
8
|
</tr>
|
9
9
|
</thead>
|
10
10
|
<tbody>
|
11
11
|
<tr ng-repeat="<%= @resource_name%> in <%= @plural_model_name%>">
|
12
12
|
<td>
|
13
13
|
<a href="/<%= @plural_model_name%>/{{<%= @resource_name%>.id}}">
|
14
|
-
{{<%= @resource_name
|
14
|
+
{{<%= "#{@resource_name}.#{@resource_legend.downcase}"%>}}
|
15
15
|
</a>
|
16
16
|
</td>
|
17
17
|
<td>
|
@@ -26,10 +26,6 @@
|
|
26
26
|
<i class="icon-trash"></i> Delete
|
27
27
|
</button>
|
28
28
|
</td>
|
29
|
-
<td>
|
30
|
-
{{<%= @resource_name%>.created_at}}
|
31
|
-
|
32
|
-
</td>
|
33
29
|
</tr>
|
34
30
|
</tbody>
|
35
31
|
</table>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angularjs_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -100,7 +100,7 @@ files:
|
|
100
100
|
- lib/angularjs_scaffold.rb
|
101
101
|
- MIT-LICENSE
|
102
102
|
- Rakefile
|
103
|
-
- README
|
103
|
+
- README.md
|
104
104
|
- test/dummy/script/rails
|
105
105
|
- test/dummy/app/controllers/application_controller.rb
|
106
106
|
- test/dummy/app/helpers/application_helper.rb
|
data/README
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
AngularjsScaffold
|
2
|
-
|
3
|
-
This project uses MIT-LICENSE.
|
4
|
-
|
5
|
-
First install the gem or add it to your Gemfile:
|
6
|
-
$ gem install angularjs_scaffold
|
7
|
-
|
8
|
-
Second install it, this will add angularjs, bootstrap and fontawesome (there's an option to only install AngularJS)
|
9
|
-
$ rails g angularjs:install # adds angular.js and a dummy welcome JS controller
|
10
|
-
|
11
|
-
Run your usual scaffold command:
|
12
|
-
$ rails g scaffold Post title:string body:string
|
13
|
-
$ rake db:migrate
|
14
|
-
|
15
|
-
Now run the angularjs command and it will rewrite everything the AngularJS way:
|
16
|
-
$ rails g angularjs:scaffold Posts # adds everything needed using AngularJS
|
17
|
-
|
18
|
-
Enjoy!
|