customize_admin 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +28 -0
- data/app/assets/stylesheets/customize_admin/application.css +2 -1
- data/app/views/customize_admin/base/_form.html.erb +1 -1
- data/lib/customize_admin.rb +11 -0
- data/lib/customize_admin/version.rb +1 -1
- data/lib/generators/customize_admin/add_resource/USAGE +8 -0
- data/lib/generators/customize_admin/add_resource/add_resource_generator.rb +26 -0
- data/lib/generators/customize_admin/add_resource/add_resource_generator.rb~ +46 -0
- data/lib/generators/customize_admin/add_resource/templates/controller_template.rb +3 -0
- data/lib/generators/customize_admin/install/install_generator.rb +13 -3
- data/lib/generators/customize_admin/install/templates/customize_admin.rb +5 -0
- data/lib/generators/customize_admin/scaffold/scaffold_generator.rb +5 -16
- metadata +31 -26
data/README.rdoc
CHANGED
@@ -15,3 +15,31 @@ And then execute:
|
|
15
15
|
After this run install generator:
|
16
16
|
|
17
17
|
rails g customize_admin:install
|
18
|
+
|
19
|
+
== Usage
|
20
|
+
|
21
|
+
=== Scaffold
|
22
|
+
CustomizeAdmin allows you to create new resources and add them to your admin. For example:
|
23
|
+
|
24
|
+
rails g customize_admin:scaffold product name:string description:text
|
25
|
+
|
26
|
+
=== Add resource
|
27
|
+
CustomizeAdmin allows you to add new admin resource to your CustomizeAdmin using existing models
|
28
|
+
rails g customize_admin:add_resource NEW_ADMIN_RESOURCE EXISTING_RESOURCE
|
29
|
+
|
30
|
+
For example:
|
31
|
+
rails g customize_admin:add_resource account user
|
32
|
+
|
33
|
+
|
34
|
+
= Coming soon description of how to:
|
35
|
+
== Customize views
|
36
|
+
|
37
|
+
== Customize controllers
|
38
|
+
|
39
|
+
=== Search query
|
40
|
+
Default search query is set like this:
|
41
|
+
|
42
|
+
SEARCH_QUERY = "name LIKE ?"
|
43
|
+
|
44
|
+
So, you can overwrite this in your current CustomizeAdmin controller and set different value
|
45
|
+
|
@@ -35,6 +35,7 @@ form .input {
|
|
35
35
|
}
|
36
36
|
.right{
|
37
37
|
margin-left:auto;
|
38
|
+
width: 100px;
|
38
39
|
margin-right:auto;
|
39
40
|
}
|
40
41
|
#search{
|
@@ -65,7 +66,7 @@ margin-right:auto;
|
|
65
66
|
background: white;
|
66
67
|
cursor: default;
|
67
68
|
|
68
|
-
|
69
|
+
|
69
70
|
/* self-clearing method: */ }
|
70
71
|
.digg_pagination a, .digg_pagination span, .digg_pagination em {
|
71
72
|
line-height:34px;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= semantic_form_for(
|
1
|
+
<%= semantic_form_for( resource, :url => collection_path, :namespace => "#{CustomizeAdmin.name_space}") do |f| %>
|
2
2
|
<%= render :partial => "all_form_inputs", :locals => { :f => f } %>
|
3
3
|
<%= render :partial => "more_form_inputs", :locals => { :f => f } %>
|
4
4
|
<div class="right"><%= f.submit "Save", :class => "btn large primary" %> </div>
|
data/lib/customize_admin.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
class CustomizeAdmin::AddResourceGenerator < Rails::Generators::NamedBase
|
2
|
+
include Rails::Generators::ResourceHelpers
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
argument :resource_class
|
5
|
+
|
6
|
+
def generate_controller
|
7
|
+
@namespace_class = CustomizeAdmin.name_space.camelize
|
8
|
+
@namespace = CustomizeAdmin.name_space
|
9
|
+
@controller_name = plural_name.camelize
|
10
|
+
@resource = resource_class.camelize
|
11
|
+
@collection_name = resource_class.pluralize
|
12
|
+
@instance_name = resource_class
|
13
|
+
|
14
|
+
template "controller_template.rb", "app/controllers/#{@namespace}/#{plural_name}_controller.rb"
|
15
|
+
|
16
|
+
insert_into_file "config/routes.rb", :after => "namespace :#{@namespace} do\n #customize_admin:\n" do
|
17
|
+
" resources :#{plural_name}\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
insert_into_file "app/views/customize_admin/application/_admin_menu.html.erb", :after => "<li></li>\n" do
|
21
|
+
"<li><%= link_to '#{@controller_name}', #{@namespace +"_"+ plural_name}_path %></li>\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class CustomizeAdmin::ScaffoldGenerator < Rails::Generators::NamedBase
|
2
|
+
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
#argument :model_name, :type => :string
|
5
|
+
argument :fields, :type => :array, :banner => "field:type"
|
6
|
+
#argument :namespace, :type => :string, :default => "admin" #, :required => false
|
7
|
+
|
8
|
+
def generate_controller
|
9
|
+
puts file_name
|
10
|
+
#puts class_name
|
11
|
+
puts plural_name
|
12
|
+
puts options
|
13
|
+
puts namespace
|
14
|
+
|
15
|
+
@controller_name = plural_name[0].capitalize + plural_name.slice(1..-1)
|
16
|
+
#namespace = ask("Tell the admin namespace")
|
17
|
+
namespace = "admin"
|
18
|
+
@namespace = namespace[0].capitalize + namespace.slice(1..-1)
|
19
|
+
if namespace.present?
|
20
|
+
template "controller_template.rb", "app/controllers/#{namespace}/#{plural_name}_controller.rb"
|
21
|
+
insert_into_file "config/routes.rb", :after => "namespace :#{namespace} do\n #customize_admin:\n" do
|
22
|
+
" resources :#{plural_name}\n"
|
23
|
+
end
|
24
|
+
else
|
25
|
+
template "controller_template.rb", "app/controllers/#{plural_name}_controller.rb"
|
26
|
+
route("resources :#{plural_name}")
|
27
|
+
end
|
28
|
+
|
29
|
+
insert_into_file "app/views/customize_admin/application/_admin_menu.html.erb", :after => "customize_admin\n" do
|
30
|
+
"<%= link_to '#{@controller_name}', #{namespace +"_"+ plural_name}_path %>\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_to_menu
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_model
|
39
|
+
s = ""
|
40
|
+
fields.each do |f|
|
41
|
+
s += f + " "
|
42
|
+
end
|
43
|
+
generate "model #{file_name} #{s}"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class CustomizeAdmin::InstallGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
3
4
|
def add_gems
|
4
5
|
insert_into_file "Gemfile", :after => "source 'http://rubygems.org'\n" do
|
5
|
-
"# CustomizeAdmin gems:\n gem 'inherited_resources'\n gem 'has_scope'\n gem 'formtastic'\n gem 'will_paginate'\n gem 'devise'\n gem 'twitter-bootstrap-rails', '1.4.3' \n \n"
|
6
|
+
"# CustomizeAdmin gems:\n gem 'inherited_resources', '1.3.0'\n gem 'has_scope', '0.5.1'\n gem 'formtastic', '2.0.2'\n gem 'will_paginate', '3.0.2'\n gem 'devise', '2.0.0'\n gem 'twitter-bootstrap-rails', '1.4.3' \n \n"
|
6
7
|
end
|
7
|
-
|
8
8
|
end
|
9
9
|
|
10
10
|
def add_routes
|
@@ -16,7 +16,11 @@ class CustomizeAdmin::InstallGenerator < Rails::Generators::Base
|
|
16
16
|
|
17
17
|
def create_menu_file
|
18
18
|
create_file "app/views/customize_admin/application/_admin_menu.html.erb" do
|
19
|
-
"<%= link_to 'Dashboard', #{@name_space}_path, :class => 'brand' %>
|
19
|
+
"<%= link_to 'Dashboard', #{@name_space}_path, :class => 'brand' %>
|
20
|
+
<ul class='nav'>
|
21
|
+
<li></li>
|
22
|
+
</ul>
|
23
|
+
"
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -29,6 +33,8 @@ class CustomizeAdmin::InstallGenerator < Rails::Generators::Base
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def create_admin_user_table
|
36
|
+
#@devise_name = ask("Tell me devise admin user model (default is AdminUser)")
|
37
|
+
#@devise_name.blank? ? @devise_name = "AdminUser" : ""
|
32
38
|
generate "devise AdminUser"
|
33
39
|
end
|
34
40
|
|
@@ -68,4 +74,8 @@ end ",
|
|
68
74
|
|
69
75
|
end
|
70
76
|
|
77
|
+
def add_config
|
78
|
+
template "customize_admin.rb", "config/initializers/customize_admin.rb"
|
79
|
+
end
|
80
|
+
|
71
81
|
end
|
@@ -1,21 +1,13 @@
|
|
1
1
|
class CustomizeAdmin::ScaffoldGenerator < Rails::Generators::NamedBase
|
2
2
|
|
3
3
|
source_root File.expand_path('../templates', __FILE__)
|
4
|
-
#argument :model_name, :type => :string
|
5
4
|
argument :fields, :type => :array, :banner => "field:type"
|
6
|
-
#argument :namespace, :type => :string, :default => "admin" #, :required => false
|
7
5
|
|
8
6
|
def generate_controller
|
9
|
-
puts file_name
|
10
|
-
#puts class_name
|
11
|
-
puts plural_name
|
12
|
-
puts options
|
13
|
-
puts namespace
|
14
7
|
|
15
|
-
@controller_name = plural_name
|
16
|
-
|
17
|
-
namespace =
|
18
|
-
@namespace = namespace[0].capitalize + namespace.slice(1..-1)
|
8
|
+
@controller_name = plural_name.pluralize.camelize
|
9
|
+
namespace = CustomizeAdmin.name_space
|
10
|
+
@namespace = namespace.camelize
|
19
11
|
if namespace.present?
|
20
12
|
template "controller_template.rb", "app/controllers/#{namespace}/#{plural_name}_controller.rb"
|
21
13
|
insert_into_file "config/routes.rb", :after => "namespace :#{namespace} do\n #customize_admin:\n" do
|
@@ -26,15 +18,12 @@ class CustomizeAdmin::ScaffoldGenerator < Rails::Generators::NamedBase
|
|
26
18
|
route("resources :#{plural_name}")
|
27
19
|
end
|
28
20
|
|
29
|
-
insert_into_file "app/views/customize_admin/application/_admin_menu.html.erb", :after => "
|
30
|
-
"
|
21
|
+
insert_into_file "app/views/customize_admin/application/_admin_menu.html.erb", :after => "</li>\n" do
|
22
|
+
"<li><%= link_to '#{@controller_name}', #{namespace +"_"+ plural_name}_path %></li>\n"
|
31
23
|
end
|
32
24
|
|
33
25
|
end
|
34
26
|
|
35
|
-
def add_to_menu
|
36
|
-
end
|
37
|
-
|
38
27
|
def generate_model
|
39
28
|
s = ""
|
40
29
|
fields.each do |f|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customize_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &17606460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,65 +21,65 @@ dependencies:
|
|
21
21
|
version: 3.1.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17606460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: inherited_resources
|
27
|
-
requirement: &
|
27
|
+
requirement: &17622340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - =
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 1.3.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17622340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: has_scope
|
38
|
-
requirement: &
|
38
|
+
requirement: &17621880 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - =
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.5.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17621880
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: formtastic
|
49
|
-
requirement: &
|
49
|
+
requirement: &17621420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - =
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.0.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *17621420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: will_paginate
|
60
|
-
requirement: &
|
60
|
+
requirement: &17620960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - =
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 3.0.2
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *17620960
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: devise
|
71
|
-
requirement: &
|
71
|
+
requirement: &17620500 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - =
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 2.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *17620500
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: twitter-bootstrap-rails
|
82
|
-
requirement: &
|
82
|
+
requirement: &17620040 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - =
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 1.4.3
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *17620040
|
91
91
|
description: CustomizeAdmin it is simple way to customize your admin view.
|
92
92
|
email:
|
93
93
|
- cieslar.jakub@gmail.com
|
@@ -124,12 +124,17 @@ files:
|
|
124
124
|
- lib/customize_admin/version.rb
|
125
125
|
- lib/customize_admin/engine.rb
|
126
126
|
- lib/templates/erb/scaffold/_form.html.erb
|
127
|
+
- lib/generators/customize_admin/add_resource/templates/controller_template.rb
|
128
|
+
- lib/generators/customize_admin/add_resource/USAGE
|
129
|
+
- lib/generators/customize_admin/add_resource/add_resource_generator.rb~
|
130
|
+
- lib/generators/customize_admin/add_resource/add_resource_generator.rb
|
127
131
|
- lib/generators/customize_admin/scaffold/scaffold_generator.rb
|
128
132
|
- lib/generators/customize_admin/scaffold/templates/controller_template.rb
|
129
133
|
- lib/generators/customize_admin/scaffold/USAGE
|
130
134
|
- lib/generators/customize_admin/install/templates/devise_admin.html.erb
|
131
135
|
- lib/generators/customize_admin/install/templates/dashboard_controller.rb
|
132
136
|
- lib/generators/customize_admin/install/templates/index.html.erb
|
137
|
+
- lib/generators/customize_admin/install/templates/customize_admin.rb
|
133
138
|
- lib/generators/customize_admin/install/USAGE
|
134
139
|
- lib/generators/customize_admin/install/install_generator.rb
|
135
140
|
- lib/tasks/customize_admin_tasks.rake
|