active_leonardo 0.0.4 → 0.0.5
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/CHANGELOG +4 -0
- data/README.rdoc +3 -1
- data/active_template.rb +4 -1
- data/lib/generators/leolay/leolay_generator.rb +1 -1
- data/lib/generators/leolay/templates/config/locales/en.yml +2 -0
- data/lib/generators/leolay/templates/config/locales/it.yml +2 -0
- metadata +91 -61
- data/lib/generators/leolay/templates/config/initializers/activeadmin_cancan.rb +0 -114
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Leolay Generators
|
2
2
|
|
3
|
+
[](https://codeclimate.com/github/marcomd/Active_Leonardo)
|
4
|
+
|
3
5
|
A layout and customized scaffold generator for Rails 3 to combine with active admin gem
|
4
6
|
It generates the layout, the style, the internationalization and it helps you to startup active_admin gems
|
5
7
|
|
@@ -139,7 +141,7 @@ PS: Of course, these options are in addition to those provided by the original s
|
|
139
141
|
|
140
142
|
== Tutorial
|
141
143
|
|
142
|
-
On my blog you can find some other info.
|
144
|
+
On my [Blog]: http://marcomastrodonato.blogspot.it/ (Click to visit my blog) you can find some other info.
|
143
145
|
|
144
146
|
|
145
147
|
|
data/active_template.rb
CHANGED
@@ -64,7 +64,10 @@ if authentication
|
|
64
64
|
end
|
65
65
|
|
66
66
|
authorization = yes?("Authorization ?")
|
67
|
-
|
67
|
+
if authorization
|
68
|
+
gem 'cancan'
|
69
|
+
gem 'activeadmin-cancan'
|
70
|
+
end
|
68
71
|
end
|
69
72
|
|
70
73
|
dashboard_root = yes?("Would you use dashboard as root ? (recommended)")
|
@@ -351,7 +351,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
351
351
|
def setup_activeadmin
|
352
352
|
return unless options.activeadmin? and activeadmin?
|
353
353
|
template "config/initializers/activeadmin_leonardo.rb", "config/initializers/activeadmin_leonardo.rb"
|
354
|
-
copy_file "config/initializers/activeadmin_cancan.rb", "config/initializers/activeadmin_cancan.rb" if options.authorization?
|
354
|
+
#copy_file "config/initializers/activeadmin_cancan.rb", "config/initializers/activeadmin_cancan.rb" if options.authorization?
|
355
355
|
template "app/admin/users.rb", "app/admin/#{options[:auth_class].downcase.pluralize}.rb"
|
356
356
|
|
357
357
|
file = "app/assets/stylesheets/active_admin.css.scss"
|
@@ -244,6 +244,8 @@ it:
|
|
244
244
|
change_password: "Cambia la password"
|
245
245
|
current_password: "Password attuale"
|
246
246
|
new_password: "Nuova password"
|
247
|
+
unauthorized:
|
248
|
+
default: "Non hai l'autorizzazione per svolgere questa operazione o per accedere a questa area"
|
247
249
|
states:
|
248
250
|
generic:
|
249
251
|
new: "Nuovo"
|
metadata
CHANGED
@@ -1,73 +1,96 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_leonardo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Marco Mastrodonato
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-09-26 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rails
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 3.1.0
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 1
|
32
|
+
- 0
|
29
33
|
version: 3.1.0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: activeadmin
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.4.0
|
38
34
|
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activeadmin
|
39
38
|
prerelease: false
|
40
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 15
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 4
|
48
|
+
- 0
|
45
49
|
version: 0.4.0
|
46
|
-
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
47
53
|
name: cancan
|
48
|
-
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
56
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 5
|
64
|
+
- 0
|
53
65
|
version: 1.5.0
|
54
66
|
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: activeadmin-cancan
|
55
70
|
prerelease: false
|
56
|
-
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 19
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 1
|
80
|
+
- 4
|
81
|
+
version: 0.1.4
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id004
|
84
|
+
description: This generator help you to create new Rails applications to combine with active admin gem. It generates application structure to easily get the internationalization and authorization.
|
85
|
+
email:
|
66
86
|
- m.mastrodonato@gmail.com
|
67
87
|
executables: []
|
88
|
+
|
68
89
|
extensions: []
|
90
|
+
|
69
91
|
extra_rdoc_files: []
|
70
|
-
|
92
|
+
|
93
|
+
files:
|
71
94
|
- lib/generators/active_leonardo.rb
|
72
95
|
- lib/generators/erb/leosca/leosca_generator.rb
|
73
96
|
- lib/generators/leolay/install_generator.rb
|
@@ -75,7 +98,6 @@ files:
|
|
75
98
|
- lib/generators/leolay/templates/app/admin/users.rb
|
76
99
|
- lib/generators/leolay/templates/app/assets/javascripts/custom.js
|
77
100
|
- lib/generators/leolay/templates/app/helpers/layout_helper.rb
|
78
|
-
- lib/generators/leolay/templates/config/initializers/activeadmin_cancan.rb
|
79
101
|
- lib/generators/leolay/templates/config/initializers/activeadmin_leonardo.rb
|
80
102
|
- lib/generators/leolay/templates/config/locales/devise.it.yml
|
81
103
|
- lib/generators/leolay/templates/config/locales/en.yml
|
@@ -108,28 +130,36 @@ files:
|
|
108
130
|
- active_template.rb
|
109
131
|
homepage: https://github.com/marcomd/Active_Leonardo
|
110
132
|
licenses: []
|
133
|
+
|
111
134
|
post_install_message:
|
112
135
|
rdoc_options: []
|
113
|
-
|
136
|
+
|
137
|
+
require_paths:
|
114
138
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
140
|
none: false
|
117
|
-
requirements:
|
118
|
-
- -
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
|
121
|
-
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
149
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
|
128
|
-
-
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements:
|
158
|
+
- Start a new app with the active_template.rb inside root folder
|
129
159
|
rubyforge_project:
|
130
160
|
rubygems_version: 1.8.24
|
131
161
|
signing_key:
|
132
162
|
specification_version: 3
|
133
|
-
summary: This gem provides a new customized scaffold generator to combine with active
|
134
|
-
admin
|
163
|
+
summary: This gem provides a new customized scaffold generator to combine with active admin
|
135
164
|
test_files: []
|
165
|
+
|
@@ -1,114 +0,0 @@
|
|
1
|
-
|
2
|
-
module ActiveAdmin
|
3
|
-
module Views
|
4
|
-
#Integrate cancan in default_actions
|
5
|
-
#\lib\active_admin\views\index_as_table.rb
|
6
|
-
class IndexAsTable
|
7
|
-
class IndexTableFor
|
8
|
-
# Adds links to View, Edit and Delete
|
9
|
-
def default_actions(options = {})
|
10
|
-
options = {
|
11
|
-
:name => "",
|
12
|
-
:auth => nil
|
13
|
-
}.merge(options)
|
14
|
-
column options[:name] do |resource|
|
15
|
-
links = ''.html_safe
|
16
|
-
if controller.action_methods.include?('show') && (options[:auth] ? can?(:read, resource) : true)
|
17
|
-
links += link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
|
18
|
-
end
|
19
|
-
if controller.action_methods.include?('edit') && (options[:auth] ? can?(:update, resource) : true)
|
20
|
-
links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
|
21
|
-
end
|
22
|
-
if controller.action_methods.include?('destroy') && (options[:auth] ? can?(:update, resource) : true)
|
23
|
-
links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
|
24
|
-
end
|
25
|
-
links
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module ViewHelpers
|
33
|
-
# lib/active_admin/view_helpers/auto_link_helper.rb
|
34
|
-
def auto_link(resource, link_content = nil)
|
35
|
-
content = link_content || display_name(resource)
|
36
|
-
if can?(:read, resource) && registration = active_admin_resource_for(resource.class)
|
37
|
-
begin
|
38
|
-
content = link_to(content, send(registration.route_instance_path, resource))
|
39
|
-
rescue
|
40
|
-
end
|
41
|
-
end
|
42
|
-
content
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class Resource
|
47
|
-
module ActionItems
|
48
|
-
private
|
49
|
-
|
50
|
-
# Adds the default action items to each resource
|
51
|
-
def add_default_action_items
|
52
|
-
# New Link on all actions except :new and :show
|
53
|
-
add_action_item :except => [:new, :show] do
|
54
|
-
if controller.action_methods.include?('new') && can?(:create, active_admin_config.resource_class)
|
55
|
-
link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_name), new_resource_path)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# Edit link on show
|
60
|
-
add_action_item :only => :show do
|
61
|
-
if controller.action_methods.include?('edit') && can?(:edit, resource)
|
62
|
-
link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_name), edit_resource_path(resource))
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Destroy link on show
|
67
|
-
add_action_item :only => :show do
|
68
|
-
if controller.action_methods.include?("destroy") && can?(:destroy, resource)
|
69
|
-
link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_name),
|
70
|
-
resource_path(resource),
|
71
|
-
:method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# lib/active_admin/resource/menu.rb
|
78
|
-
module Menu
|
79
|
-
# The :if block is evaluated by TabbedNavigation#display_item?
|
80
|
-
def default_menu_options
|
81
|
-
klass = resource_class # avoid variable capture
|
82
|
-
super.merge(:if => proc{ can? :read, klass })
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class ResourceController
|
88
|
-
# lib/active_admin/resource_controller/collection.rb
|
89
|
-
|
90
|
-
# The following doesn't work (see https://github.com/ryanb/cancan/pull/683):
|
91
|
-
#
|
92
|
-
# load_and_authorize_resource
|
93
|
-
# skip_load_resource :only => :index
|
94
|
-
#
|
95
|
-
# If you don't skip loading on #index you will get the exception:
|
96
|
-
#
|
97
|
-
# "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection."
|
98
|
-
#
|
99
|
-
# Add to your activeadmin file:
|
100
|
-
#
|
101
|
-
# controller.load_resource :except => :index
|
102
|
-
# controller.authorize_resource
|
103
|
-
|
104
|
-
# https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
|
105
|
-
# https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L80
|
106
|
-
module Collection
|
107
|
-
module BaseCollection
|
108
|
-
def scoped_collection
|
109
|
-
end_of_association_chain.accessible_by(current_ability)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|