activeadmin-nested-namespaces 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +162 -0
- data/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/Rakefile +6 -0
- data/activeadmin-nested-namespaces.gemspec +30 -0
- data/bin/bundle +105 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/nokogiri +29 -0
- data/bin/rackup +29 -0
- data/bin/rails +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/sass +29 -0
- data/bin/sass-convert +29 -0
- data/bin/scss +29 -0
- data/bin/setup +8 -0
- data/bin/sprockets +29 -0
- data/bin/thor +29 -0
- data/dummy_app/.gitignore +23 -0
- data/dummy_app/Gemfile +57 -0
- data/dummy_app/Gemfile.lock +260 -0
- data/dummy_app/README.md +24 -0
- data/dummy_app/Rakefile +8 -0
- data/dummy_app/app/admin/admin_users.rb +28 -0
- data/dummy_app/app/admin/dashboard.rb +13 -0
- data/dummy_app/app/admin/site1/dashboard.rb +13 -0
- data/dummy_app/app/admin/site1/posts.rb +3 -0
- data/dummy_app/app/admin/site2/dashboard.rb +12 -0
- data/dummy_app/app/admin/site3/demo/dashboard.rb +13 -0
- data/dummy_app/app/admin/site3/demo/posts.rb +15 -0
- data/dummy_app/app/assets/config/manifest.js +3 -0
- data/dummy_app/app/assets/images/.keep +0 -0
- data/dummy_app/app/assets/javascripts/active_admin.js.coffee +1 -0
- data/dummy_app/app/assets/javascripts/application.js +15 -0
- data/dummy_app/app/assets/javascripts/cable.js +13 -0
- data/dummy_app/app/assets/javascripts/channels/.keep +0 -0
- data/dummy_app/app/assets/stylesheets/active_admin.scss +17 -0
- data/dummy_app/app/assets/stylesheets/application.css +15 -0
- data/dummy_app/app/channels/application_cable/channel.rb +4 -0
- data/dummy_app/app/channels/application_cable/connection.rb +4 -0
- data/dummy_app/app/controllers/application_controller.rb +3 -0
- data/dummy_app/app/controllers/concerns/.keep +0 -0
- data/dummy_app/app/helpers/application_helper.rb +2 -0
- data/dummy_app/app/jobs/application_job.rb +2 -0
- data/dummy_app/app/mailers/application_mailer.rb +4 -0
- data/dummy_app/app/models/admin_user.rb +10 -0
- data/dummy_app/app/models/application_record.rb +3 -0
- data/dummy_app/app/models/concerns/.keep +0 -0
- data/dummy_app/app/models/post.rb +2 -0
- data/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/dummy_app/app/views/layouts/mailer.html.erb +13 -0
- data/dummy_app/app/views/layouts/mailer.text.erb +1 -0
- data/dummy_app/bin/bundle +3 -0
- data/dummy_app/bin/byebug +29 -0
- data/dummy_app/bin/listen +29 -0
- data/dummy_app/bin/nokogiri +29 -0
- data/dummy_app/bin/puma +29 -0
- data/dummy_app/bin/pumactl +29 -0
- data/dummy_app/bin/rackup +29 -0
- data/dummy_app/bin/rails +4 -0
- data/dummy_app/bin/rake +4 -0
- data/dummy_app/bin/sass +29 -0
- data/dummy_app/bin/sass-convert +29 -0
- data/dummy_app/bin/scss +29 -0
- data/dummy_app/bin/setup +38 -0
- data/dummy_app/bin/spring +29 -0
- data/dummy_app/bin/sprockets +29 -0
- data/dummy_app/bin/thor +29 -0
- data/dummy_app/bin/tilt +29 -0
- data/dummy_app/bin/update +29 -0
- data/dummy_app/bin/yarn +11 -0
- data/dummy_app/config.ru +5 -0
- data/dummy_app/config/application.rb +19 -0
- data/dummy_app/config/boot.rb +3 -0
- data/dummy_app/config/cable.yml +10 -0
- data/dummy_app/config/database.yml +25 -0
- data/dummy_app/config/environment.rb +5 -0
- data/dummy_app/config/environments/development.rb +54 -0
- data/dummy_app/config/environments/production.rb +91 -0
- data/dummy_app/config/environments/test.rb +42 -0
- data/dummy_app/config/initializers/active_admin.rb +313 -0
- data/dummy_app/config/initializers/active_admin_nested_namespace.rb +5 -0
- data/dummy_app/config/initializers/application_controller_renderer.rb +6 -0
- data/dummy_app/config/initializers/assets.rb +14 -0
- data/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/dummy_app/config/initializers/cookies_serializer.rb +5 -0
- data/dummy_app/config/initializers/devise.rb +290 -0
- data/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy_app/config/initializers/inflections.rb +16 -0
- data/dummy_app/config/initializers/mime_types.rb +4 -0
- data/dummy_app/config/initializers/wrap_parameters.rb +14 -0
- data/dummy_app/config/locales/devise.en.yml +64 -0
- data/dummy_app/config/locales/en.yml +33 -0
- data/dummy_app/config/puma.rb +56 -0
- data/dummy_app/config/routes.rb +20 -0
- data/dummy_app/config/secrets.yml +32 -0
- data/dummy_app/config/spring.rb +6 -0
- data/dummy_app/db/migrate/20180823051209_devise_create_admin_users.rb +44 -0
- data/dummy_app/db/migrate/20180823051213_create_active_admin_comments.rb +17 -0
- data/dummy_app/db/migrate/20180823051222_create_posts.rb +12 -0
- data/dummy_app/db/schema.rb +41 -0
- data/dummy_app/db/seeds.rb +8 -0
- data/dummy_app/lib/assets/.keep +0 -0
- data/dummy_app/lib/tasks/.keep +0 -0
- data/dummy_app/log/.keep +0 -0
- data/dummy_app/package.json +5 -0
- data/dummy_app/public/404.html +67 -0
- data/dummy_app/public/422.html +67 -0
- data/dummy_app/public/500.html +66 -0
- data/dummy_app/public/apple-touch-icon-precomposed.png +0 -0
- data/dummy_app/public/apple-touch-icon.png +0 -0
- data/dummy_app/public/favicon.ico +0 -0
- data/dummy_app/public/robots.txt +1 -0
- data/dummy_app/test/application_system_test_case.rb +5 -0
- data/dummy_app/test/controllers/.keep +0 -0
- data/dummy_app/test/fixtures/.keep +0 -0
- data/dummy_app/test/fixtures/admin_users.yml +11 -0
- data/dummy_app/test/fixtures/files/.keep +0 -0
- data/dummy_app/test/helpers/.keep +0 -0
- data/dummy_app/test/integration/.keep +0 -0
- data/dummy_app/test/mailers/.keep +0 -0
- data/dummy_app/test/models/.keep +0 -0
- data/dummy_app/test/models/admin_user_test.rb +7 -0
- data/dummy_app/test/system/.keep +0 -0
- data/dummy_app/test/test_helper.rb +9 -0
- data/dummy_app/tmp/.keep +0 -0
- data/dummy_app/vendor/.keep +0 -0
- data/lib/active_admin/nested_namespace.rb +270 -0
- data/lib/active_admin/nested_namespace/version.rb +5 -0
- metadata +236 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d62c7b0faddd0a79b3f85ef03abe7e392c2bd2b2
|
4
|
+
data.tar.gz: 73a3cabea12b16f59a9b4234339f726b035164a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 160f6d7298f8687b0f42663033018955c3e4dee1504a26326809b9587ef7cb527deed31b1cdd1d7ce96e87c3b64b47ae5ae271ada117392170e8ba530873622a
|
7
|
+
data.tar.gz: 5b2bdfb51d0103b0a6935ec2a163da9f138d00983b112042e7b4ecc5948245e795b22cec7bd8fa0ab4d4b13d2cfea8340e4a2ff7f7bc0087231d06ab4d6a633b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
activeadmin-nested-namespaces (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actionpack (5.2.1)
|
10
|
+
actionview (= 5.2.1)
|
11
|
+
activesupport (= 5.2.1)
|
12
|
+
rack (~> 2.0)
|
13
|
+
rack-test (>= 0.6.3)
|
14
|
+
rails-dom-testing (~> 2.0)
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
16
|
+
actionview (5.2.1)
|
17
|
+
activesupport (= 5.2.1)
|
18
|
+
builder (~> 3.1)
|
19
|
+
erubi (~> 1.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
22
|
+
activeadmin (1.3.1)
|
23
|
+
arbre (>= 1.1.1)
|
24
|
+
coffee-rails
|
25
|
+
formtastic (~> 3.1)
|
26
|
+
formtastic_i18n
|
27
|
+
inherited_resources (>= 1.9.0)
|
28
|
+
jquery-rails (>= 4.2.0)
|
29
|
+
kaminari (>= 0.15)
|
30
|
+
railties (>= 4.2, < 5.3)
|
31
|
+
ransack (>= 1.8.7)
|
32
|
+
sass (~> 3.1)
|
33
|
+
sprockets (< 4.1)
|
34
|
+
activemodel (5.2.1)
|
35
|
+
activesupport (= 5.2.1)
|
36
|
+
activerecord (5.2.1)
|
37
|
+
activemodel (= 5.2.1)
|
38
|
+
activesupport (= 5.2.1)
|
39
|
+
arel (>= 9.0)
|
40
|
+
activesupport (5.2.1)
|
41
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
42
|
+
i18n (>= 0.7, < 2)
|
43
|
+
minitest (~> 5.1)
|
44
|
+
tzinfo (~> 1.1)
|
45
|
+
arbre (1.1.1)
|
46
|
+
activesupport (>= 3.0.0)
|
47
|
+
arel (9.0.0)
|
48
|
+
builder (3.2.3)
|
49
|
+
coffee-rails (4.2.2)
|
50
|
+
coffee-script (>= 2.2.0)
|
51
|
+
railties (>= 4.0.0)
|
52
|
+
coffee-script (2.4.1)
|
53
|
+
coffee-script-source
|
54
|
+
execjs
|
55
|
+
coffee-script-source (1.12.2)
|
56
|
+
concurrent-ruby (1.0.5)
|
57
|
+
crass (1.0.4)
|
58
|
+
diff-lcs (1.3)
|
59
|
+
erubi (1.7.1)
|
60
|
+
execjs (2.7.0)
|
61
|
+
ffi (1.9.25)
|
62
|
+
formtastic (3.1.5)
|
63
|
+
actionpack (>= 3.2.13)
|
64
|
+
formtastic_i18n (0.6.0)
|
65
|
+
has_scope (0.7.2)
|
66
|
+
actionpack (>= 4.1)
|
67
|
+
activesupport (>= 4.1)
|
68
|
+
i18n (1.1.0)
|
69
|
+
concurrent-ruby (~> 1.0)
|
70
|
+
inherited_resources (1.9.0)
|
71
|
+
actionpack (>= 4.2, < 5.3)
|
72
|
+
has_scope (~> 0.6)
|
73
|
+
railties (>= 4.2, < 5.3)
|
74
|
+
responders
|
75
|
+
jquery-rails (4.3.3)
|
76
|
+
rails-dom-testing (>= 1, < 3)
|
77
|
+
railties (>= 4.2.0)
|
78
|
+
thor (>= 0.14, < 2.0)
|
79
|
+
kaminari (1.1.1)
|
80
|
+
activesupport (>= 4.1.0)
|
81
|
+
kaminari-actionview (= 1.1.1)
|
82
|
+
kaminari-activerecord (= 1.1.1)
|
83
|
+
kaminari-core (= 1.1.1)
|
84
|
+
kaminari-actionview (1.1.1)
|
85
|
+
actionview
|
86
|
+
kaminari-core (= 1.1.1)
|
87
|
+
kaminari-activerecord (1.1.1)
|
88
|
+
activerecord
|
89
|
+
kaminari-core (= 1.1.1)
|
90
|
+
kaminari-core (1.1.1)
|
91
|
+
loofah (2.2.2)
|
92
|
+
crass (~> 1.0.2)
|
93
|
+
nokogiri (>= 1.5.9)
|
94
|
+
method_source (0.9.0)
|
95
|
+
mini_portile2 (2.3.0)
|
96
|
+
minitest (5.11.3)
|
97
|
+
nokogiri (1.8.4)
|
98
|
+
mini_portile2 (~> 2.3.0)
|
99
|
+
rack (2.0.5)
|
100
|
+
rack-test (1.1.0)
|
101
|
+
rack (>= 1.0, < 3)
|
102
|
+
rails-dom-testing (2.0.3)
|
103
|
+
activesupport (>= 4.2.0)
|
104
|
+
nokogiri (>= 1.6)
|
105
|
+
rails-html-sanitizer (1.0.4)
|
106
|
+
loofah (~> 2.2, >= 2.2.2)
|
107
|
+
railties (5.2.1)
|
108
|
+
actionpack (= 5.2.1)
|
109
|
+
activesupport (= 5.2.1)
|
110
|
+
method_source
|
111
|
+
rake (>= 0.8.7)
|
112
|
+
thor (>= 0.19.0, < 2.0)
|
113
|
+
rake (10.5.0)
|
114
|
+
ransack (2.0.1)
|
115
|
+
actionpack (>= 5.0)
|
116
|
+
activerecord (>= 5.0)
|
117
|
+
activesupport (>= 5.0)
|
118
|
+
i18n
|
119
|
+
rb-fsevent (0.10.3)
|
120
|
+
rb-inotify (0.9.10)
|
121
|
+
ffi (>= 0.5.0, < 2)
|
122
|
+
responders (2.4.0)
|
123
|
+
actionpack (>= 4.2.0, < 5.3)
|
124
|
+
railties (>= 4.2.0, < 5.3)
|
125
|
+
rspec (3.8.0)
|
126
|
+
rspec-core (~> 3.8.0)
|
127
|
+
rspec-expectations (~> 3.8.0)
|
128
|
+
rspec-mocks (~> 3.8.0)
|
129
|
+
rspec-core (3.8.0)
|
130
|
+
rspec-support (~> 3.8.0)
|
131
|
+
rspec-expectations (3.8.1)
|
132
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
133
|
+
rspec-support (~> 3.8.0)
|
134
|
+
rspec-mocks (3.8.0)
|
135
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
136
|
+
rspec-support (~> 3.8.0)
|
137
|
+
rspec-support (3.8.0)
|
138
|
+
sass (3.5.7)
|
139
|
+
sass-listen (~> 4.0.0)
|
140
|
+
sass-listen (4.0.0)
|
141
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
142
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
143
|
+
sprockets (3.7.2)
|
144
|
+
concurrent-ruby (~> 1.0)
|
145
|
+
rack (> 1, < 3)
|
146
|
+
thor (0.20.0)
|
147
|
+
thread_safe (0.3.6)
|
148
|
+
tzinfo (1.2.5)
|
149
|
+
thread_safe (~> 0.1)
|
150
|
+
|
151
|
+
PLATFORMS
|
152
|
+
ruby
|
153
|
+
|
154
|
+
DEPENDENCIES
|
155
|
+
activeadmin (= 1.3.1)
|
156
|
+
activeadmin-nested-namespaces!
|
157
|
+
bundler (~> 1.16)
|
158
|
+
rake (~> 10.0)
|
159
|
+
rspec (~> 3.0)
|
160
|
+
|
161
|
+
BUNDLED WITH
|
162
|
+
1.16.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 - Martin Chan (osiutino)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# ActiveAdmin Nested Namespace
|
2
|
+
|
3
|
+
This plugin allows you to register resources/pages with nested namespaces in ActiveAdmin.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'activeadmin-nested-namespaces'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
|
18
|
+
Copy and paste these lines to `config/initializers/active_admin_nested_namespace.rb`
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'active_admin/nested_namespace'
|
22
|
+
|
23
|
+
if defined?(ActiveAdmin::NestedNamespace)
|
24
|
+
ActiveAdmin::NestedNamespace.setup
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
# Get Started
|
30
|
+
|
31
|
+
Register resources to 2 different namespaces:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# /app/admin/site1/foo/bar/posts.rb
|
35
|
+
ActiveAdmin.register Post, namespace: [:admin, :site1, :foo, :bar] do
|
36
|
+
...
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# /app/admin/site2/demo/posts.rb
|
42
|
+
ActiveAdmin.register Post, namespace: [:admin, :site2, :demo] do
|
43
|
+
...
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
It will generate routes like:
|
48
|
+
|
49
|
+
```
|
50
|
+
admin_site1_foo_bar_root GET /admin/site1/foo/bar(.:format) admin/site1/foo/bar/dashboard#index
|
51
|
+
admin_site2_demo_root GET /admin/site2/demo(.:format)
|
52
|
+
batch_action_admin_site1_foo_bar_posts POST /admin/site1/foo/bar/posts/batch_action(.:format) admin/site1/foo/bar/posts#batch_action
|
53
|
+
admin_site1_foo_bar_posts GET /admin/site1/foo/bar/posts(.:format) admin/site1/foo/bar/posts#index
|
54
|
+
POST /admin/site1/foo/bar/posts(.:format) admin/site1/foo/bar/posts#create
|
55
|
+
new_admin_site1_foo_bar_post GET /admin/site1/foo/bar/posts/new(.:format) admin/site1/foo/bar/posts#new
|
56
|
+
edit_admin_site1_foo_bar_post GET /admin/site1/foo/bar/posts/:id/edit(.:format) admin/site1/foo/bar/posts#edit
|
57
|
+
admin_site1_foo_bar_post GET /admin/site1/foo/bar/posts/:id(.:format) admin/site1/foo/bar/posts#show
|
58
|
+
PATCH /admin/site1/foo/bar/posts/:id(.:format) admin/site1/foo/bar/posts#update
|
59
|
+
PUT /admin/site1/foo/bar/posts/:id(.:format) admin/site1/foo/bar/posts#update
|
60
|
+
DELETE /admin/site1/foo/bar/posts/:id(.:format) admin/site1/foo/bar/posts#destroy
|
61
|
+
admin_site1_foo_bar_comments GET /admin/site1/foo/bar/comments(.:format) admin/site1/foo/bar/comments#index
|
62
|
+
POST /admin/site1/foo/bar/comments(.:format) admin/site1/foo/bar/comments#create
|
63
|
+
admin_site1_foo_bar_comment GET /admin/site1/foo/bar/comments/:id(.:format) admin/site1/foo/bar/comments#show
|
64
|
+
DELETE /admin/site1/foo/bar/comments/:id(.:format) admin/site1/foo/bar/comments#destroy
|
65
|
+
batch_action_admin_site2_demo_posts POST /admin/site2/demo/posts/batch_action(.:format) admin/site2/demo/posts#batch_action
|
66
|
+
admin_site2_demo_posts GET /admin/site2/demo/posts(.:format) admin/site2/demo/posts#index
|
67
|
+
edit_admin_site2_demo_post GET /admin/site2/demo/posts/:id/edit(.:format) admin/site2/demo/posts#edit
|
68
|
+
admin_site2_demo_post GET /admin/site2/demo/posts/:id(.:format) admin/site2/demo/posts#show
|
69
|
+
PATCH /admin/site2/demo/posts/:id(.:format) admin/site2/demo/posts#update
|
70
|
+
PUT /admin/site2/demo/posts/:id(.:format) admin/site2/demo/posts#update
|
71
|
+
admin_site2_demo_comments GET /admin/site2/demo/comments(.:format) admin/site2/demo/comments#index
|
72
|
+
POST /admin/site2/demo/comments(.:format) admin/site2/demo/comments#create
|
73
|
+
admin_site2_demo_comment GET /admin/site2/demo/comments/:id(.:format) admin/site2/demo/comments#show
|
74
|
+
DELETE /admin/site2/demo/comments/:id(.:format) admin/site2/demo/comments#destroy
|
75
|
+
|
76
|
+
```
|
77
|
+
|
78
|
+
# Configuration
|
79
|
+
|
80
|
+
In your initializers/active_admin.rb, you can define your own handler to the following methods.
|
81
|
+
|
82
|
+
* authentication_method
|
83
|
+
* current_user_method
|
84
|
+
* logout_link_path
|
85
|
+
|
86
|
+
For example:
|
87
|
+
|
88
|
+
``` ruby
|
89
|
+
# config.authentication_method = :authenticate_admin_user!
|
90
|
+
config.authentication_method = Proc.new do |name_path|
|
91
|
+
if [config.default_namespace, :root].include?(name_path.first)
|
92
|
+
:authenticate_admin_user!
|
93
|
+
else
|
94
|
+
"authenticate_#{name_path.map(&:to_s).join('_').underscore}_admin_user!".to_sym
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# config.current_user_method = :current_admin_user
|
99
|
+
config.current_user_method = Proc.new do |name_path|
|
100
|
+
if [config.default_namespace, :root].include?(name_path.first)
|
101
|
+
:current_admin_user
|
102
|
+
else
|
103
|
+
"current_#{name_path.map(&:to_s).join('_').underscore}_admin_user".to_sym
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# config.logout_link_path = :destroy_admin_user_session_path
|
108
|
+
config.logout_link_path = Proc.new do |name_path|
|
109
|
+
if [config.default_namespace, :root].include?(name_path.first)
|
110
|
+
:destroy_admin_user_session_path
|
111
|
+
else
|
112
|
+
"destroy_#{name_path.map(&:to_s).join('_').underscore}_admin_user_session_path".to_sym
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
```
|
117
|
+
|
118
|
+
And in your routes.rb:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
namespace :site1 do
|
122
|
+
namespace :foo do
|
123
|
+
namespace :bar do
|
124
|
+
devise_for :admin_users, ActiveAdmin::Devise.config
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
namespace :site2 do
|
129
|
+
namespace :demo do
|
130
|
+
devise_for :admin_users, ActiveAdmin::Devise.config
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
## Contributors
|
136
|
+
[Martin Chan](https://twitter.com/osiutino) - creator
|
137
|
+
|
138
|
+
## License
|
139
|
+
|
140
|
+
[MIT License](https://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "active_admin/nested_namespace/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activeadmin-nested-namespaces"
|
8
|
+
spec.version = ActiveAdmin::NestedNamespace::VERSION
|
9
|
+
spec.authors = ["osiutino"]
|
10
|
+
spec.email = ["osiutino@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ ActiveAdmin plugin to enable nested namespaces support }
|
13
|
+
spec.description = %q{ This plugin allows you to register resources/pages with nested namespaces in ActiveAdmin. }
|
14
|
+
spec.homepage = "https://github.com/siutin/activeadmin-nested-namespaces"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "activeadmin", "= 1.3.1"
|
30
|
+
end
|
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|