administrate 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of administrate might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/views/administrate/application/_sidebar.html.erb +2 -2
- data/lib/administrate/base_dashboard.rb +11 -11
- data/lib/administrate/engine.rb +1 -0
- data/lib/administrate/{fields → field}/associative.rb +0 -0
- data/lib/administrate/{fields → field}/base.rb +0 -0
- data/lib/administrate/{fields → field}/belongs_to.rb +0 -0
- data/lib/administrate/{fields → field}/boolean.rb +0 -0
- data/lib/administrate/{fields → field}/date_time.rb +0 -0
- data/lib/administrate/{fields → field}/deferred.rb +0 -0
- data/lib/administrate/{fields → field}/email.rb +0 -0
- data/lib/administrate/{fields → field}/has_many.rb +0 -0
- data/lib/administrate/{fields → field}/has_one.rb +0 -0
- data/lib/administrate/{fields → field}/image.rb +0 -0
- data/lib/administrate/{fields → field}/number.rb +0 -0
- data/lib/administrate/{fields → field}/polymorphic.rb +0 -0
- data/lib/administrate/{fields → field}/string.rb +0 -0
- data/lib/administrate/{fields → field}/text.rb +0 -0
- data/lib/administrate/namespace.rb +29 -0
- data/lib/administrate/version.rb +1 -1
- data/lib/generators/administrate/field/templates/field_object.rb.erb +1 -1
- data/lib/generators/administrate/install/install_generator.rb +9 -27
- data/lib/generators/administrate/{manifest/manifest_generator.rb → routes/routes_generator.rb} +19 -6
- data/lib/generators/administrate/routes/templates/routes.rb.erb +5 -0
- metadata +19 -19
- data/lib/generators/administrate/install/templates/routes.rb +0 -7
- data/lib/generators/administrate/manifest/templates/dashboard_manifest.rb.erb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6b7e88304b6a4b6255696bd3e09757f8dc9fa1
|
4
|
+
data.tar.gz: 46632cb11d7f960f33f89177d41e6be93407c200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd234605bdad1d95b25a2bd494df96ec9450d15c31500349edc4045daaea79da1acf394627a0930e3b487ffd5d9b9a43e30c27da6df07b674973e026adce839
|
7
|
+
data.tar.gz: aca5e1ea7517a2eca432c8edd9394cbf9be95e630c8de24f86eb2c9d63405bca2a8c7f28a4f29033a99dfaad0b385d70c7c16ad2a0416432f63a1b4d6afdb2c0
|
@@ -4,11 +4,11 @@
|
|
4
4
|
This partial is used to display the sidebar in Administrate.
|
5
5
|
By default, the sidebar contains navigation links
|
6
6
|
for all resources in the admin dashboard,
|
7
|
-
as defined by the
|
7
|
+
as defined by the routes in the `admin/` namespace
|
8
8
|
%>
|
9
9
|
|
10
10
|
<ul class="sidebar__list">
|
11
|
-
<%
|
11
|
+
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
12
12
|
<li>
|
13
13
|
<%= link_to(
|
14
14
|
display_resource_name(resource),
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require "administrate/
|
2
|
-
require "administrate/
|
3
|
-
require "administrate/
|
4
|
-
require "administrate/
|
5
|
-
require "administrate/
|
6
|
-
require "administrate/
|
7
|
-
require "administrate/
|
8
|
-
require "administrate/
|
9
|
-
require "administrate/
|
10
|
-
require "administrate/
|
11
|
-
require "administrate/
|
1
|
+
require "administrate/field/belongs_to"
|
2
|
+
require "administrate/field/boolean"
|
3
|
+
require "administrate/field/date_time"
|
4
|
+
require "administrate/field/email"
|
5
|
+
require "administrate/field/has_many"
|
6
|
+
require "administrate/field/has_one"
|
7
|
+
require "administrate/field/image"
|
8
|
+
require "administrate/field/number"
|
9
|
+
require "administrate/field/polymorphic"
|
10
|
+
require "administrate/field/string"
|
11
|
+
require "administrate/field/text"
|
12
12
|
|
13
13
|
module Administrate
|
14
14
|
class BaseDashboard
|
data/lib/administrate/engine.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Administrate
|
2
|
+
class Namespace
|
3
|
+
def initialize(namespace)
|
4
|
+
@namespace = namespace
|
5
|
+
end
|
6
|
+
|
7
|
+
def resources
|
8
|
+
namespace_controller_paths.uniq.map do |controller|
|
9
|
+
controller.gsub(/^#{namespace}\//, "").to_sym
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :namespace
|
16
|
+
|
17
|
+
def namespace_controller_paths
|
18
|
+
all_controller_paths.select do |controller|
|
19
|
+
controller.starts_with?(namespace.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def all_controller_paths
|
24
|
+
Rails.application.routes.routes.map do |route|
|
25
|
+
route.defaults[:controller].to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/administrate/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rails/generators/base"
|
2
2
|
require "administrate/generator_helpers"
|
3
|
+
require "administrate/namespace"
|
3
4
|
|
4
5
|
module Administrate
|
5
6
|
module Generators
|
@@ -7,6 +8,13 @@ module Administrate
|
|
7
8
|
include Administrate::GeneratorHelpers
|
8
9
|
source_root File.expand_path("../templates", __FILE__)
|
9
10
|
|
11
|
+
def run_routes_generator
|
12
|
+
if dashboard_resources.none?
|
13
|
+
call_generator("administrate:routes")
|
14
|
+
load Rails.root.join("config/routes.rb")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
def create_dashboard_controller
|
11
19
|
copy_file(
|
12
20
|
"application_controller.rb",
|
@@ -14,12 +22,6 @@ module Administrate
|
|
14
22
|
)
|
15
23
|
end
|
16
24
|
|
17
|
-
def insert_dashboard_routes
|
18
|
-
unless File.read(rails_routes_file_path).include?(dashboard_routes)
|
19
|
-
route(dashboard_routes)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
25
|
def run_dashboard_generators
|
24
26
|
singular_dashboard_resources.each do |resource|
|
25
27
|
call_generator("administrate:dashboard", resource)
|
@@ -33,27 +35,7 @@ module Administrate
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def dashboard_resources
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def manifest
|
40
|
-
unless defined?(DashboardManifest)
|
41
|
-
call_generator("administrate:manifest")
|
42
|
-
end
|
43
|
-
|
44
|
-
DashboardManifest
|
45
|
-
end
|
46
|
-
|
47
|
-
def dashboard_routes
|
48
|
-
File.read(routes_file_path)
|
49
|
-
end
|
50
|
-
|
51
|
-
def rails_routes_file_path
|
52
|
-
Rails.root.join("config/routes.rb")
|
53
|
-
end
|
54
|
-
|
55
|
-
def routes_file_path
|
56
|
-
File.expand_path(find_in_source_paths("routes.rb"))
|
38
|
+
Administrate::Namespace.new(:admin).resources
|
57
39
|
end
|
58
40
|
end
|
59
41
|
end
|
data/lib/generators/administrate/{manifest/manifest_generator.rb → routes/routes_generator.rb}
RENAMED
@@ -1,16 +1,16 @@
|
|
1
1
|
Rails.application.eager_load!
|
2
2
|
require "rails/generators/base"
|
3
|
+
require "administrate/namespace"
|
3
4
|
|
4
5
|
module Administrate
|
5
6
|
module Generators
|
6
|
-
class
|
7
|
+
class RoutesGenerator < Rails::Generators::Base
|
7
8
|
source_root File.expand_path("../templates", __FILE__)
|
8
9
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
)
|
10
|
+
def insert_dashboard_routes
|
11
|
+
unless File.read(rails_routes_file_path).include?(dashboard_routes)
|
12
|
+
route(dashboard_routes)
|
13
|
+
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def warn_about_invalid_models
|
@@ -22,6 +22,7 @@ module Administrate
|
|
22
22
|
models_without_tables.each do |invalid_model|
|
23
23
|
puts "WARNING: Unable to generate a dashboard for #{invalid_model}."
|
24
24
|
puts " It is not connected to a database table."
|
25
|
+
puts " Make sure your database migrations are up to date."
|
25
26
|
end
|
26
27
|
|
27
28
|
unnamed_constants.each do |invalid_model|
|
@@ -60,6 +61,18 @@ module Administrate
|
|
60
61
|
def unnamed_constants
|
61
62
|
ActiveRecord::Base.descendants.reject { |d| d.name == d.to_s }
|
62
63
|
end
|
64
|
+
|
65
|
+
def dashboard_routes
|
66
|
+
ERB.new(File.read(routes_file_path)).result(binding)
|
67
|
+
end
|
68
|
+
|
69
|
+
def rails_routes_file_path
|
70
|
+
Rails.root.join("config/routes.rb")
|
71
|
+
end
|
72
|
+
|
73
|
+
def routes_file_path
|
74
|
+
File.expand_path(find_in_source_paths("routes.rb.erb"))
|
75
|
+
end
|
63
76
|
end
|
64
77
|
end
|
65
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grayson Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autoprefixer-rails
|
@@ -268,21 +268,22 @@ files:
|
|
268
268
|
- lib/administrate.rb
|
269
269
|
- lib/administrate/base_dashboard.rb
|
270
270
|
- lib/administrate/engine.rb
|
271
|
-
- lib/administrate/
|
272
|
-
- lib/administrate/
|
273
|
-
- lib/administrate/
|
274
|
-
- lib/administrate/
|
275
|
-
- lib/administrate/
|
276
|
-
- lib/administrate/
|
277
|
-
- lib/administrate/
|
278
|
-
- lib/administrate/
|
279
|
-
- lib/administrate/
|
280
|
-
- lib/administrate/
|
281
|
-
- lib/administrate/
|
282
|
-
- lib/administrate/
|
283
|
-
- lib/administrate/
|
284
|
-
- lib/administrate/
|
271
|
+
- lib/administrate/field/associative.rb
|
272
|
+
- lib/administrate/field/base.rb
|
273
|
+
- lib/administrate/field/belongs_to.rb
|
274
|
+
- lib/administrate/field/boolean.rb
|
275
|
+
- lib/administrate/field/date_time.rb
|
276
|
+
- lib/administrate/field/deferred.rb
|
277
|
+
- lib/administrate/field/email.rb
|
278
|
+
- lib/administrate/field/has_many.rb
|
279
|
+
- lib/administrate/field/has_one.rb
|
280
|
+
- lib/administrate/field/image.rb
|
281
|
+
- lib/administrate/field/number.rb
|
282
|
+
- lib/administrate/field/polymorphic.rb
|
283
|
+
- lib/administrate/field/string.rb
|
284
|
+
- lib/administrate/field/text.rb
|
285
285
|
- lib/administrate/generator_helpers.rb
|
286
|
+
- lib/administrate/namespace.rb
|
286
287
|
- lib/administrate/order.rb
|
287
288
|
- lib/administrate/page.rb
|
288
289
|
- lib/administrate/page/base.rb
|
@@ -308,9 +309,8 @@ files:
|
|
308
309
|
- lib/generators/administrate/field/templates/field_object.rb.erb
|
309
310
|
- lib/generators/administrate/install/install_generator.rb
|
310
311
|
- lib/generators/administrate/install/templates/application_controller.rb
|
311
|
-
- lib/generators/administrate/
|
312
|
-
- lib/generators/administrate/
|
313
|
-
- lib/generators/administrate/manifest/templates/dashboard_manifest.rb.erb
|
312
|
+
- lib/generators/administrate/routes/routes_generator.rb
|
313
|
+
- lib/generators/administrate/routes/templates/routes.rb.erb
|
314
314
|
- lib/generators/administrate/views/edit_generator.rb
|
315
315
|
- lib/generators/administrate/views/field_generator.rb
|
316
316
|
- lib/generators/administrate/views/form_generator.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# DashboardManifest tells Administrate which dashboards to display
|
2
|
-
class DashboardManifest
|
3
|
-
# `DASHBOARDS`
|
4
|
-
# a list of dashboards to display in the side navigation menu
|
5
|
-
#
|
6
|
-
# These are all of the rails models that we found in your database
|
7
|
-
# at the time you installed Administrate.
|
8
|
-
#
|
9
|
-
# To show or hide dashboards, add or remove the model name from this list.
|
10
|
-
# Dashboards returned from this method must be Rails models for Administrate
|
11
|
-
# to work correctly.
|
12
|
-
DASHBOARDS = [
|
13
|
-
<% dashboard_resources.each do |model| -%>
|
14
|
-
:<%= model %>,
|
15
|
-
<% end -%>
|
16
|
-
]
|
17
|
-
|
18
|
-
# `ROOT_DASHBOARD`
|
19
|
-
# the name of the dashboard that will be displayed
|
20
|
-
# at "http://your_site.com/admin"
|
21
|
-
#
|
22
|
-
# This dashboard will likely be the first page that admins see
|
23
|
-
# when they log into the dashboard.
|
24
|
-
ROOT_DASHBOARD = DASHBOARDS.first
|
25
|
-
end
|