godmin 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +21 -0
- data/CHANGELOG.md +15 -0
- data/README.md +72 -18
- data/app/assets/javascripts/godmin/index.js +1 -0
- data/app/assets/javascripts/godmin/navigation.js +16 -0
- data/app/views/godmin/shared/_navigation.html.erb +0 -29
- data/app/views/godmin/shared/_navigation_aside.html.erb +7 -0
- data/app/views/layouts/godmin/application.html.erb +7 -2
- data/config/locales/en.yml +2 -2
- data/lib/generators/godmin/authentication/authentication_generator.rb +1 -1
- data/lib/generators/godmin/install/install_generator.rb +5 -2
- data/lib/generators/godmin/resource/resource_generator.rb +7 -3
- data/lib/godmin.rb +0 -4
- data/lib/godmin/application_controller.rb +2 -0
- data/lib/godmin/helpers/navigation.rb +52 -0
- data/lib/godmin/version.rb +1 -1
- metadata +5 -3
- data/lib/godmin/rails.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 142e127c459d99fcaffc7277c23302b39ed55fdd
|
4
|
+
data.tar.gz: 0d33f7c04855780ceb0b20fc48fbe5e226cc738a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce10bc5fc5b5cebe832a9fb95da78c8a37c7121f3e1b1efd6b1494a76e72b8a458e62c3032925a7cc31e2d57c7e31a7400955c91aaddc49aafaacb39d31f7bb0
|
7
|
+
data.tar.gz: e6a2b6e898e3a7e5280cef2f4ffa6edcde3b9af2411e84308abff1680bca9a7af5ba6cd01e724111c5c7b32927574a0101382a704e01047c4061fa2dfc29e789
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
rubocop:
|
4
|
+
enabled: true
|
5
|
+
eslint:
|
6
|
+
enabled: true
|
7
|
+
csslint:
|
8
|
+
enabled: true
|
9
|
+
bundler-audit:
|
10
|
+
enabled: true
|
11
|
+
ratings:
|
12
|
+
paths:
|
13
|
+
- "**.rb"
|
14
|
+
- "**.js"
|
15
|
+
- "**.jsx"
|
16
|
+
- "**.css"
|
17
|
+
exclude_paths:
|
18
|
+
- config/**/*
|
19
|
+
- test/**/*
|
20
|
+
- vendor/**/*
|
21
|
+
- tmp/**/*
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.12.0 - 2015-06-30
|
4
|
+
Features
|
5
|
+
- Adds new navigation helpers for building a custom navbar (https://github.com/varvet/godmin/issues/54)
|
6
|
+
|
7
|
+
Other
|
8
|
+
- Removes the godmin router method
|
9
|
+
|
10
|
+
In order to upgrade:
|
11
|
+
- Remove the `godmin do` block from the `config/routes.rb` file
|
12
|
+
- Specify a root route if there is none already
|
13
|
+
- Create a `shared/_navigation.html.erb` partial if there is none already
|
14
|
+
|
15
|
+
Bug fixes
|
16
|
+
- Fixes issue with authentication generator not modifying the application controller
|
17
|
+
|
3
18
|
### 0.11.2 - 2015-06-22
|
4
19
|
Bug fixes
|
5
20
|
- Fixes broken collection select helper
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
Godmin is an admin framework for Rails 4+.
|
8
8
|
|
9
|
+
![Screenshot](https://raw.githubusercontent.com/varvet/godmin/master/screenshot.png)
|
10
|
+
|
9
11
|
- [Installation](#installation)
|
10
12
|
- [Standalone installation](#standalone-installation)
|
11
13
|
- [Engine installation](#engine-installation)
|
@@ -18,8 +20,10 @@ Godmin is an admin framework for Rails 4+.
|
|
18
20
|
- [Resource fetching, building and saving](#resource-fetching-building-and-saving)
|
19
21
|
- [Redirecting](#redirecting)
|
20
22
|
- [Pagination](#pagination)
|
23
|
+
- [Exporting](#exporting)
|
21
24
|
- [Views](#views)
|
22
25
|
- [Forms](#forms)
|
26
|
+
- [Navigation](#navigation)
|
23
27
|
- [Authentication](#authentication)
|
24
28
|
- [Built in authentication](#built-in-authentication)
|
25
29
|
- [Shared authentication](#shared-authentication)
|
@@ -97,16 +101,6 @@ end
|
|
97
101
|
|
98
102
|
If Godmin was installed inside an engine, as in the previous section, the namespace is the underscored name of the engine, e.g. `"admin"`.
|
99
103
|
|
100
|
-
The `config/routes.rb` file is modified as such:
|
101
|
-
```ruby
|
102
|
-
Rails.application.routes.draw do
|
103
|
-
godmin do
|
104
|
-
end
|
105
|
-
end
|
106
|
-
```
|
107
|
-
|
108
|
-
Resource routes placed within the `godmin` block are automatically added to the default navigation.
|
109
|
-
|
110
104
|
The application controller is modified as such:
|
111
105
|
```ruby
|
112
106
|
class ApplicationController < ActionController::Base
|
@@ -118,6 +112,8 @@ Require statements are placed in both `app/assets/javascripts/application.js` an
|
|
118
112
|
|
119
113
|
If Godmin was installed inside an engine, a `require "godmin"` statement is placed in `{namespace}/lib/{namespace}.rb`.
|
120
114
|
|
115
|
+
An `app/views/shared/_navigation.html.erb` partial is created.
|
116
|
+
|
121
117
|
And finally, the `app/views/layouts` folder is removed by default, so as not to interfere with the Godmin layouts. It can be added back in case you wish to override the built in layouts.
|
122
118
|
|
123
119
|
## Getting started
|
@@ -138,9 +134,13 @@ This does a number of things.
|
|
138
134
|
It inserts a route in the `config/routes.rb` file:
|
139
135
|
|
140
136
|
```ruby
|
141
|
-
|
142
|
-
|
143
|
-
|
137
|
+
resources :articles
|
138
|
+
```
|
139
|
+
|
140
|
+
It inserts a `navbar_item` in the `app/views/shared/_navigation.html.erb` partial:
|
141
|
+
|
142
|
+
```erb
|
143
|
+
<%= navbar_item Article %>
|
144
144
|
```
|
145
145
|
|
146
146
|
It creates a controller:
|
@@ -175,7 +175,7 @@ By now we have a basic admin interface for managing articles.
|
|
175
175
|
|
176
176
|
As we saw in the example above, resources are divided into controllers and service objects. Actions, redirects, params permitting etc go in the controller while resource fetching, building, sorting, filtering etc go in the service object. This makes the service objects small and easy to test.
|
177
177
|
|
178
|
-
We have already seen
|
178
|
+
We have already seen three methods at play: `attrs_for_index`, `attrs_for_show` and `attrs_for_form`. We will now look at some additional resource concepts.
|
179
179
|
|
180
180
|
### Scopes
|
181
181
|
|
@@ -466,20 +466,30 @@ class ArticlesService
|
|
466
466
|
end
|
467
467
|
```
|
468
468
|
|
469
|
+
### Exporting
|
470
|
+
|
471
|
+
The `attrs_for_export` method in the service object makes it possible to mark attributes or methods on the model as exportable. When implemented, an export button will appear on the index page with options for both CSV and JSON export.
|
472
|
+
|
473
|
+
```ruby
|
474
|
+
class ArticlesService
|
475
|
+
include Godmin::Resources::Service
|
476
|
+
|
477
|
+
attrs_for_export :id, :title, :created_at, :updated_at
|
478
|
+
end
|
479
|
+
```
|
480
|
+
|
469
481
|
## Views
|
470
482
|
|
471
483
|
It's easy to override view templates and partials in Godmin, both globally and per resource. All you have to do is place a file with an identical name in your `app/views` directory. For instance, to override the `godmin/resource/index.html.erb` template for all resources, place a file under `app/views/resource/index.html.erb`. If you only wish to override it for articles, place it instead under `app/views/articles/index.html.erb`.
|
472
484
|
|
473
485
|
If you wish to customize the content of a table column, you can place a partial under `app/views/{resource}/columns/{column_name}.html.erb`, e.g. `app/views/articles/columns/_title.html.erb`. The resource is available to the partial through the `resource` variable.
|
474
486
|
|
475
|
-
Oftentimes, the default form provided by Godmin doesn't cut it. The `godmin/resource/_form.html.erb` partial is therefore one of the most common to override per resource. See below for more on form building.
|
476
|
-
|
477
|
-
Likewise, the `godmin/shared/_navigation.html.erb` partial can be overridden to build a custom navigation bar.
|
478
|
-
|
479
487
|
The full list of templates and partials that can be overridden [can be found here](https://github.com/varvet/godmin/tree/master/app/views/godmin).
|
480
488
|
|
481
489
|
### Forms
|
482
490
|
|
491
|
+
Oftentimes, the default form provided by Godmin doesn't cut it. The `godmin/resource/_form.html.erb` partial is therefore one of the most common to override per resource.
|
492
|
+
|
483
493
|
Godmin comes with its own FormBuilder that automatically generates bootstrapped markup. It is based on the [Rails Bootstrap Forms](https://github.com/bootstrap-ruby/rails-bootstrap-forms) FormBuilder, and all its methods are directly available. In addition it has a few convenience methods that can be leveraged.
|
484
494
|
|
485
495
|
The `input` method will automatically detect the type of field from the database and generate an appropriate form field:
|
@@ -490,6 +500,48 @@ form_for @resource do |f|
|
|
490
500
|
end
|
491
501
|
```
|
492
502
|
|
503
|
+
### Navigation
|
504
|
+
|
505
|
+
Godmin comes with built in view helpers for generating the navbar.
|
506
|
+
|
507
|
+
The `navbar_item` helper generates a link in the navbar. It can be used in a number of different ways.
|
508
|
+
|
509
|
+
```ruby
|
510
|
+
# Links to the index page of the article resource
|
511
|
+
navbar_item Article
|
512
|
+
|
513
|
+
# Links to a custom path with a custom link text
|
514
|
+
navbar_item Article, articles_path(scope: :published) do
|
515
|
+
"Published articles"
|
516
|
+
end
|
517
|
+
|
518
|
+
# Links to a custom path with a custom link text without specifying resource
|
519
|
+
navbar_item "Some text", some_path
|
520
|
+
```
|
521
|
+
|
522
|
+
The `show` option can be passed a proc that evaluates to true or false. This is used to control if the link should be shown or not. By default it checks against the resource policy object if authorization is enabled.
|
523
|
+
|
524
|
+
```ruby
|
525
|
+
navbar_item Article, show: -> { show? }
|
526
|
+
```
|
527
|
+
|
528
|
+
The `icon` option can be passed a glyphicon:
|
529
|
+
|
530
|
+
```ruby
|
531
|
+
navbar_item Article, icon: "book"
|
532
|
+
```
|
533
|
+
|
534
|
+
The `navbar_dropdown` and `navbar_divider` helpers can be used to build dropdown menus.
|
535
|
+
|
536
|
+
```ruby
|
537
|
+
navbar_dropdown "Multiple things" do
|
538
|
+
navbar_item Article
|
539
|
+
navbar_item Comment
|
540
|
+
navbar_divider
|
541
|
+
navbar_item User
|
542
|
+
end
|
543
|
+
```
|
544
|
+
|
493
545
|
## Authentication
|
494
546
|
|
495
547
|
Multiple authentication scenarios are supported. Godmin comes with a lightweight built in authentication solution that can be used to sign in to the admin section via the admin interface. In addition, when running an admin engine, it is possible to set up a shared authentication solution so that administrators can sign in via the main app.
|
@@ -779,6 +831,8 @@ If you wish to translate the datetimepicker, add the following to your `app/asse
|
|
779
831
|
//= require godmin
|
780
832
|
```
|
781
833
|
|
834
|
+
Please note that the datepickers default to en-GB, not en-US, because Rails cannot automatically parse en-US dates.
|
835
|
+
|
782
836
|
### Select boxes
|
783
837
|
|
784
838
|
Make a [selectize.js](http://brianreavis.github.io/selectize.js/) select box out of a text field or select box:
|
@@ -9,9 +9,25 @@ Godmin.Navigation = (function() {
|
|
9
9
|
function initializeEvents() {}
|
10
10
|
|
11
11
|
function initializeState() {
|
12
|
+
setActiveLink();
|
12
13
|
removeEmptyDropdowns();
|
13
14
|
}
|
14
15
|
|
16
|
+
function setActiveLink() {
|
17
|
+
var $links = $('.nav.navbar-nav a[href="' + window.location.pathname + window.location.search + '"]');
|
18
|
+
|
19
|
+
if ($links.length) {
|
20
|
+
addActiveClass($links);
|
21
|
+
} else {
|
22
|
+
addActiveClass($('.nav.navbar-nav a[href="' + window.location.pathname + '"]'));
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
function addActiveClass($links) {
|
27
|
+
$links.closest('li').addClass('active');
|
28
|
+
$links.closest('li.dropdown').addClass('active');
|
29
|
+
}
|
30
|
+
|
15
31
|
function removeEmptyDropdowns() {
|
16
32
|
$('.navbar-nav .dropdown, .breadcrumb .dropdown').each(function() {
|
17
33
|
if ($(this).find('li').length === 0) {
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<ul class="nav navbar-nav">
|
2
|
-
<% Godmin.resources.each do |resource| %>
|
3
|
-
<% if policy(resource).index? %>
|
4
|
-
<% if controller.controller_name == resource.to_s %>
|
5
|
-
<li class="active">
|
6
|
-
<% else %>
|
7
|
-
<li>
|
8
|
-
<% end %>
|
9
|
-
<%= link_to resource.to_s.classify.constantize.model_name.human(count: 2), resource %>
|
10
|
-
</li>
|
11
|
-
<% end %>
|
12
|
-
<% end %>
|
13
|
-
</ul>
|
14
|
-
<ul class="nav navbar-nav navbar-right">
|
15
|
-
<% if authentication_enabled? &&
|
16
|
-
admin_user.singleton_class.include?(Godmin::Authentication::User) &&
|
17
|
-
admin_user_signed_in? %>
|
18
|
-
<li class="dropdown">
|
19
|
-
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
20
|
-
<%= admin_user.login %> <span class="caret"></span>
|
21
|
-
</a>
|
22
|
-
<ul class="dropdown-menu" role="menu">
|
23
|
-
<li>
|
24
|
-
<%= link_to translate_scoped("sessions.sign_out"), session_path, method: :delete %>
|
25
|
-
</li>
|
26
|
-
</ul>
|
27
|
-
</li>
|
28
|
-
<% end %>
|
29
|
-
</ul>
|
@@ -4,8 +4,13 @@
|
|
4
4
|
<div class="navbar-header">
|
5
5
|
<%= link_to t("godmin.title"), root_path, class: "navbar-brand" %>
|
6
6
|
</div>
|
7
|
-
<div class="collapse navbar-collapse
|
8
|
-
|
7
|
+
<div class="collapse navbar-collapse">
|
8
|
+
<ul class="nav navbar-nav">
|
9
|
+
<%= render partial: "shared/navigation" %>
|
10
|
+
</ul>
|
11
|
+
<ul class="nav navbar-nav navbar-right">
|
12
|
+
<%= render partial: "shared/navigation_aside" %>
|
13
|
+
</ul>
|
9
14
|
</div>
|
10
15
|
</div>
|
11
16
|
</nav>
|
data/config/locales/en.yml
CHANGED
@@ -28,7 +28,7 @@ class Godmin::AuthenticationGenerator < Godmin::Generators::NamedBase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def modify_application_controller
|
31
|
-
inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "Godmin::
|
31
|
+
inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "Godmin::ApplicationController\n" do
|
32
32
|
<<-END.strip_heredoc.indent(namespace ? 4 : 2)
|
33
33
|
include Godmin::Authentication
|
34
34
|
|
@@ -14,12 +14,15 @@ class Godmin::InstallGenerator < Godmin::Generators::Base
|
|
14
14
|
def create_routes
|
15
15
|
inject_into_file "config/routes.rb", before: /^end/ do
|
16
16
|
<<-END.strip_heredoc.indent(2)
|
17
|
-
|
18
|
-
end
|
17
|
+
root to: "application#welcome"
|
19
18
|
END
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
def create_navigation
|
23
|
+
create_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb")
|
24
|
+
end
|
25
|
+
|
23
26
|
def modify_application_controller
|
24
27
|
inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "ActionController::Base\n" do
|
25
28
|
<<-END.strip_heredoc.indent(namespace ? 4 : 2)
|
@@ -4,9 +4,13 @@ class Godmin::ResourceGenerator < Godmin::Generators::NamedBase
|
|
4
4
|
argument :attributes, type: :array, default: [], banner: "attribute attribute"
|
5
5
|
|
6
6
|
def add_route
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
route "resources :#{file_name.pluralize}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_navigation
|
11
|
+
append_to_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb") do
|
12
|
+
<<-END.strip_heredoc
|
13
|
+
<%= navbar_item #{class_name} %>
|
10
14
|
END
|
11
15
|
end
|
12
16
|
end
|
data/lib/godmin.rb
CHANGED
@@ -8,7 +8,6 @@ require "godmin/authentication"
|
|
8
8
|
require "godmin/authorization"
|
9
9
|
require "godmin/engine"
|
10
10
|
require "godmin/paginator"
|
11
|
-
require "godmin/rails"
|
12
11
|
require "godmin/resolver"
|
13
12
|
require "godmin/resources/resource_controller"
|
14
13
|
require "godmin/resources/resource_service"
|
@@ -18,9 +17,6 @@ module Godmin
|
|
18
17
|
mattr_accessor :namespace
|
19
18
|
self.namespace = nil
|
20
19
|
|
21
|
-
mattr_accessor :resources
|
22
|
-
self.resources = []
|
23
|
-
|
24
20
|
def self.configure
|
25
21
|
yield self
|
26
22
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "godmin/helpers/application"
|
2
2
|
require "godmin/helpers/forms"
|
3
|
+
require "godmin/helpers/navigation"
|
3
4
|
require "godmin/helpers/translations"
|
4
5
|
|
5
6
|
module Godmin
|
@@ -11,6 +12,7 @@ module Godmin
|
|
11
12
|
|
12
13
|
helper Godmin::Helpers::Application
|
13
14
|
helper Godmin::Helpers::Forms
|
15
|
+
helper Godmin::Helpers::Navigation
|
14
16
|
helper Godmin::Helpers::Translations
|
15
17
|
|
16
18
|
helper_method :authentication_enabled?
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Godmin
|
2
|
+
module Helpers
|
3
|
+
module Navigation
|
4
|
+
def navbar_item(resource, url = resource, show: nil, icon: nil, **options)
|
5
|
+
show ||= lambda do
|
6
|
+
resource.is_a?(String) ? true : policy(resource).index?
|
7
|
+
end
|
8
|
+
|
9
|
+
return unless show.call
|
10
|
+
|
11
|
+
link_text =
|
12
|
+
if block_given?
|
13
|
+
capture do
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
else
|
17
|
+
resource.respond_to?(:model_name) ? resource.model_name.human(count: :many) : resource
|
18
|
+
end
|
19
|
+
|
20
|
+
content_tag :li do
|
21
|
+
link_to url, options do
|
22
|
+
if icon.present?
|
23
|
+
concat content_tag :span, "", class: "glyphicon glyphicon-#{icon}"
|
24
|
+
concat " "
|
25
|
+
end
|
26
|
+
concat link_text
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def navbar_dropdown(title)
|
32
|
+
dropdown_toggle = link_to "#", class: "dropdown-toggle", data: { toggle: "dropdown" } do
|
33
|
+
concat "#{title} "
|
34
|
+
concat content_tag :span, "", class: "caret"
|
35
|
+
end
|
36
|
+
|
37
|
+
dropdown_menu = content_tag :ul, class: "dropdown-menu" do
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
|
41
|
+
content_tag :li, class: "dropdown" do
|
42
|
+
concat dropdown_toggle
|
43
|
+
concat dropdown_menu
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def navbar_divider
|
48
|
+
content_tag :li, "", class: "divider"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/godmin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Ljungblad
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-06-
|
13
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bcrypt
|
@@ -207,6 +207,7 @@ executables: []
|
|
207
207
|
extensions: []
|
208
208
|
extra_rdoc_files: []
|
209
209
|
files:
|
210
|
+
- ".codeclimate.yml"
|
210
211
|
- ".gitignore"
|
211
212
|
- ".rubocop.yml"
|
212
213
|
- ".travis.yml"
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- app/views/godmin/resource/show.json.jbuilder
|
245
246
|
- app/views/godmin/sessions/new.html.erb
|
246
247
|
- app/views/godmin/shared/_navigation.html.erb
|
248
|
+
- app/views/godmin/shared/_navigation_aside.html.erb
|
247
249
|
- app/views/layouts/godmin/_content.html.erb
|
248
250
|
- app/views/layouts/godmin/_layout.html.erb
|
249
251
|
- app/views/layouts/godmin/application.html.erb
|
@@ -275,10 +277,10 @@ files:
|
|
275
277
|
- lib/godmin/helpers/batch_actions.rb
|
276
278
|
- lib/godmin/helpers/filters.rb
|
277
279
|
- lib/godmin/helpers/forms.rb
|
280
|
+
- lib/godmin/helpers/navigation.rb
|
278
281
|
- lib/godmin/helpers/tables.rb
|
279
282
|
- lib/godmin/helpers/translations.rb
|
280
283
|
- lib/godmin/paginator.rb
|
281
|
-
- lib/godmin/rails.rb
|
282
284
|
- lib/godmin/resolver.rb
|
283
285
|
- lib/godmin/resources/resource_controller.rb
|
284
286
|
- lib/godmin/resources/resource_service.rb
|
data/lib/godmin/rails.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module ActionDispatch::Routing
|
2
|
-
class Mapper
|
3
|
-
def godmin
|
4
|
-
override_resources do
|
5
|
-
yield
|
6
|
-
end
|
7
|
-
|
8
|
-
unless has_named_route?(:root)
|
9
|
-
root to: "application#welcome"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def override_resources
|
16
|
-
def resources(*resources)
|
17
|
-
unless Godmin.resources.include?(resources.first)
|
18
|
-
Godmin.resources << resources.first
|
19
|
-
end
|
20
|
-
|
21
|
-
super
|
22
|
-
end
|
23
|
-
|
24
|
-
yield
|
25
|
-
|
26
|
-
def resources(*resources, &block)
|
27
|
-
super(*resources, &block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|