merb-admin 0.8.1 → 0.8.3
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/.gitignore +29 -27
- data/Gemfile +24 -22
- data/Gemfile.lock +86 -0
- data/LICENSE +20 -20
- data/README.rdoc +54 -58
- data/Rakefile +11 -44
- data/app/controllers/application.rb +6 -6
- data/app/controllers/main.rb +191 -191
- data/app/helpers/application_helper.rb +64 -64
- data/app/helpers/main_helper.rb +167 -167
- data/app/models/.gitkeep +0 -0
- data/app/views/layout/_message.html.erb +10 -10
- data/app/views/layout/dashboard.html.erb +34 -34
- data/app/views/layout/form.html.erb +48 -48
- data/app/views/layout/list.html.erb +42 -42
- data/app/views/main/_belongs_to.html.erb +29 -29
- data/app/views/main/_big_decimal.html.erb +12 -12
- data/app/views/main/_boolean.html.erb +7 -7
- data/app/views/main/_date.html.erb +12 -12
- data/app/views/main/_datetime.html.erb +12 -12
- data/app/views/main/_float.html.erb +12 -12
- data/app/views/main/_has_many.html.erb +16 -16
- data/app/views/main/_has_one.html.erb +30 -30
- data/app/views/main/_integer.html.erb +12 -12
- data/app/views/main/_properties.html.erb +18 -18
- data/app/views/main/_string.html.erb +15 -15
- data/app/views/main/_text.html.erb +11 -11
- data/app/views/main/_time.html.erb +12 -12
- data/app/views/main/_timestamp.html.erb +12 -12
- data/app/views/main/delete.html.erb +28 -28
- data/app/views/main/edit.html.erb +19 -19
- data/app/views/main/index.html.erb +22 -22
- data/app/views/main/list.html.erb +93 -93
- data/app/views/main/new.html.erb +16 -16
- data/config/init.rb +30 -0
- data/config/router.rb +4 -0
- data/lib/abstract_model.rb +84 -86
- data/lib/active_record_support.rb +147 -147
- data/lib/datamapper_support.rb +139 -140
- data/lib/generic_support.rb +13 -13
- data/lib/merb-admin.rb +99 -99
- data/lib/merb-admin/merbtasks.rb +103 -103
- data/lib/merb-admin/slicetasks.rb +174 -174
- data/lib/merb-admin/spectasks.rb +55 -55
- data/lib/merb-admin/version.rb +3 -0
- data/lib/sequel_support.rb +275 -275
- data/merb-admin.gemspec +42 -232
- data/public/javascripts/CollapsedFieldsets.js +85 -85
- data/public/javascripts/DateTimeShortcuts.js +255 -255
- data/public/javascripts/RelatedObjectLookups.js +96 -96
- data/public/javascripts/SelectBox.js +111 -111
- data/public/javascripts/SelectFilter2.js +113 -113
- data/public/javascripts/actions.js +39 -39
- data/public/javascripts/calendar.js +143 -143
- data/public/javascripts/core.js +176 -176
- data/public/javascripts/dateparse.js +233 -233
- data/public/javascripts/getElementsBySelector.js +167 -167
- data/public/javascripts/i18n.js +33 -33
- data/public/javascripts/ordering.js +137 -137
- data/public/javascripts/timeparse.js +94 -94
- data/public/javascripts/urlify.js +140 -140
- data/public/stylesheets/base.css +746 -746
- data/public/stylesheets/changelists.css +269 -269
- data/public/stylesheets/dashboard.css +24 -24
- data/public/stylesheets/forms.css +327 -327
- data/public/stylesheets/global.css +142 -142
- data/public/stylesheets/ie.css +50 -50
- data/public/stylesheets/layout.css +29 -29
- data/public/stylesheets/login.css +54 -54
- data/public/stylesheets/master.css +1 -1
- data/public/stylesheets/patch-iewin.css +7 -7
- data/public/stylesheets/rtl.css +206 -206
- data/public/stylesheets/widgets.css +506 -506
- data/screenshots/create.png +0 -0
- data/screenshots/delete.png +0 -0
- data/screenshots/edit.png +0 -0
- data/screenshots/index.png +0 -0
- data/screenshots/list.png +0 -0
- data/screenshots/new.png +0 -0
- data/spec/controllers/main_spec.rb +25 -25
- data/spec/migrations/activerecord/001_create_divisions_migration.rb +13 -13
- data/spec/migrations/activerecord/002_create_drafts_migration.rb +19 -19
- data/spec/migrations/activerecord/003_create_leagues_migration.rb +12 -12
- data/spec/migrations/activerecord/004_create_players_migration.rb +19 -20
- data/spec/migrations/activerecord/005_create_teams_migration.rb +22 -22
- data/spec/migrations/sequel/001_create_divisions_migration.rb +15 -15
- data/spec/migrations/sequel/002_create_drafts_migration.rb +21 -21
- data/spec/migrations/sequel/003_create_leagues_migration.rb +14 -14
- data/spec/migrations/sequel/004_create_players_migration.rb +21 -22
- data/spec/migrations/sequel/005_create_teams_migration.rb +24 -24
- data/spec/models/activerecord/division.rb +7 -7
- data/spec/models/activerecord/draft.rb +11 -11
- data/spec/models/activerecord/league.rb +6 -6
- data/spec/models/activerecord/player.rb +8 -8
- data/spec/models/activerecord/team.rb +13 -13
- data/spec/models/datamapper/division.rb +12 -12
- data/spec/models/datamapper/draft.rb +18 -18
- data/spec/models/datamapper/league.rb +11 -11
- data/spec/models/datamapper/player.rb +20 -21
- data/spec/models/datamapper/team.rb +22 -22
- data/spec/models/sequel/division.rb +15 -15
- data/spec/models/sequel/draft.rb +19 -19
- data/spec/models/sequel/league.rb +14 -14
- data/spec/models/sequel/player.rb +18 -18
- data/spec/models/sequel/team.rb +21 -21
- data/spec/requests/main_spec.rb +763 -763
- data/spec/spec_helper.rb +113 -112
- metadata +247 -41
- data/VERSION +0 -1
data/lib/datamapper_support.rb
CHANGED
|
@@ -1,140 +1,139 @@
|
|
|
1
|
-
require 'dm-core'
|
|
2
|
-
require 'dm-
|
|
3
|
-
require 'dm-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
:
|
|
73
|
-
:
|
|
74
|
-
:
|
|
75
|
-
:
|
|
76
|
-
:
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
:
|
|
87
|
-
:
|
|
88
|
-
:
|
|
89
|
-
:
|
|
90
|
-
:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@
|
|
100
|
-
options.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
DataMapper::Types::
|
|
118
|
-
DataMapper::Types::
|
|
119
|
-
DataMapper::Types::
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
end
|
|
1
|
+
require 'dm-core'
|
|
2
|
+
require 'dm-aggregates'
|
|
3
|
+
require 'dm-types'
|
|
4
|
+
require 'dm-validations'
|
|
5
|
+
|
|
6
|
+
module MerbAdmin
|
|
7
|
+
class AbstractModel
|
|
8
|
+
module DatamapperSupport
|
|
9
|
+
def get(id)
|
|
10
|
+
model.get(id).extend(InstanceMethods)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def count(options = {})
|
|
14
|
+
model.count(options.reject{|key, value| [:sort, :sort_reverse].include?(key)})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def first(options = {})
|
|
18
|
+
model.first(merge_order(options)).extend(InstanceMethods)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def all(options = {})
|
|
22
|
+
model.all(merge_order(options))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def paginated(options = {})
|
|
26
|
+
page = options.delete(:page) || 1
|
|
27
|
+
per_page = options.delete(:per_page) || MerbAdmin[:per_page]
|
|
28
|
+
|
|
29
|
+
page_count = (count(options).to_f / per_page).ceil
|
|
30
|
+
|
|
31
|
+
options.merge!({
|
|
32
|
+
:limit => per_page,
|
|
33
|
+
:offset => (page - 1) * per_page
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
[page_count, all(options)]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def create(params = {})
|
|
40
|
+
model.create(params).extend(InstanceMethods)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def new(params = {})
|
|
44
|
+
model.new(params).extend(InstanceMethods)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy_all!
|
|
48
|
+
model.all.destroy!
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def has_many_associations
|
|
52
|
+
associations.select do |association|
|
|
53
|
+
association[:type] == :has_many
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def has_one_associations
|
|
58
|
+
associations.select do |association|
|
|
59
|
+
association[:type] == :has_one
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def belongs_to_associations
|
|
64
|
+
associations.select do |association|
|
|
65
|
+
association[:type] == :belongs_to
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def associations
|
|
70
|
+
model.relationships.to_a.map do |name, association|
|
|
71
|
+
{
|
|
72
|
+
:name => name,
|
|
73
|
+
:pretty_name => name.to_s.gsub("_", " ").capitalize,
|
|
74
|
+
:type => association_type_lookup(association),
|
|
75
|
+
:parent_model => association.parent_model,
|
|
76
|
+
:parent_key => association.parent_key.map{|r| r.name},
|
|
77
|
+
:child_model => association.child_model,
|
|
78
|
+
:child_key => association.child_key.map{|r| r.name},
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def properties
|
|
84
|
+
model.properties.map do |property|
|
|
85
|
+
{
|
|
86
|
+
:name => property.name,
|
|
87
|
+
:pretty_name => property.name.to_s.gsub(/_id$/, "").gsub("_", " ").capitalize,
|
|
88
|
+
:type => type_lookup(property),
|
|
89
|
+
:length => property.respond_to?(:length) ? property.length : nil,
|
|
90
|
+
:nullable? => property.allow_nil?,
|
|
91
|
+
:serial? => property.serial?,
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
|
|
98
|
+
def merge_order(options)
|
|
99
|
+
@sort ||= options.delete(:sort) || :id
|
|
100
|
+
@sort_order ||= options.delete(:sort_reverse) ? :desc : :asc
|
|
101
|
+
options.merge(:order => [@sort.to_sym.send(@sort_order)])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def association_type_lookup(association)
|
|
105
|
+
if self.model == association.parent_model
|
|
106
|
+
association.options[:max] > 1 ? :has_many : :has_one
|
|
107
|
+
elsif self.model == association.child_model
|
|
108
|
+
:belongs_to
|
|
109
|
+
else
|
|
110
|
+
raise "Unknown association type"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def type_lookup(property)
|
|
115
|
+
type = {
|
|
116
|
+
BigDecimal => :big_decimal,
|
|
117
|
+
DataMapper::Types::Boolean => :boolean,
|
|
118
|
+
DataMapper::Types::Serial => :integer,
|
|
119
|
+
DataMapper::Types::Text => :text,
|
|
120
|
+
Date => :date,
|
|
121
|
+
DateTime => :datetime,
|
|
122
|
+
Fixnum => :integer,
|
|
123
|
+
Float => :float,
|
|
124
|
+
Integer => :integer,
|
|
125
|
+
String => :string,
|
|
126
|
+
Time => :time,
|
|
127
|
+
}
|
|
128
|
+
type[property.type] || type[property.primitive]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
module InstanceMethods
|
|
132
|
+
def update_attributes(attributes)
|
|
133
|
+
update(attributes)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
data/lib/generic_support.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
module MerbAdmin
|
|
2
|
-
class AbstractModel
|
|
3
|
-
module GenericSupport
|
|
4
|
-
def to_param
|
|
5
|
-
model.to_s.snake_case
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def pretty_name
|
|
9
|
-
model.to_s.snake_case.gsub('_', ' ').capitalize
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
1
|
+
module MerbAdmin
|
|
2
|
+
class AbstractModel
|
|
3
|
+
module GenericSupport
|
|
4
|
+
def to_param
|
|
5
|
+
model.to_s.snake_case
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def pretty_name
|
|
9
|
+
model.to_s.snake_case.gsub('_', ' ').capitalize
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/merb-admin.rb
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
if defined?(Merb::Plugins)
|
|
2
|
-
|
|
3
|
-
$:.unshift File.dirname(__FILE__)
|
|
4
|
-
|
|
5
|
-
Merb::Plugins.add_rakefiles "merb-admin/merbtasks", "merb-admin/slicetasks", "merb-admin/spectasks"
|
|
6
|
-
|
|
7
|
-
# Register the Slice for the current host application
|
|
8
|
-
Merb::Slices::register(__FILE__)
|
|
9
|
-
|
|
10
|
-
# Slice configuration - set this in a before_app_loads callback.
|
|
11
|
-
# By default a Slice uses its own layout, so you can swicht to
|
|
12
|
-
# the main application layout or no layout at all if needed.
|
|
13
|
-
#
|
|
14
|
-
# Configuration options:
|
|
15
|
-
# :layout - the layout to use; defaults to :merb-admin
|
|
16
|
-
# :mirror - which path component types to use on copy operations; defaults to all
|
|
17
|
-
Merb::Slices::config[:merb_admin][:layout] ||= :merb_admin
|
|
18
|
-
Merb::Slices::config[:merb_admin][:per_page] ||= 100
|
|
19
|
-
Merb::Slices::config[:merb_admin][:excluded_models] ||= []
|
|
20
|
-
|
|
21
|
-
# All Slice code is expected to be namespaced inside a module
|
|
22
|
-
module MerbAdmin
|
|
23
|
-
|
|
24
|
-
# Slice metadata
|
|
25
|
-
self.description = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
|
|
26
|
-
self.version = "0.8.
|
|
27
|
-
self.author = "Erik Michaels-Ober"
|
|
28
|
-
|
|
29
|
-
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
|
30
|
-
# right after a slice's classes have been loaded internally.
|
|
31
|
-
def self.loaded
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Initialization hook - runs before AfterAppLoads BootLoader
|
|
35
|
-
def self.init
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Activation hook - runs after AfterAppLoads BootLoader
|
|
39
|
-
def self.activate
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Deactivation hook - triggered by Merb::Slices.deactivate(MerbAdmin)
|
|
43
|
-
def self.deactivate
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def self.setup_router(scope)
|
|
47
|
-
scope.match("/", :method => :get).
|
|
48
|
-
to(:controller => "main", :action => "index").
|
|
49
|
-
name(:dashboard)
|
|
50
|
-
|
|
51
|
-
scope.match("/:model_name", :method => :get).
|
|
52
|
-
to(:controller => "main", :action => "list").
|
|
53
|
-
name(:list)
|
|
54
|
-
|
|
55
|
-
scope.match("/:model_name/new", :method => :get).
|
|
56
|
-
to(:controller => "main", :action => "new").
|
|
57
|
-
name(:new)
|
|
58
|
-
|
|
59
|
-
scope.match("/:model_name/:id/edit", :method => :get).
|
|
60
|
-
to(:controller => "main", :action => "edit").
|
|
61
|
-
name(:edit)
|
|
62
|
-
|
|
63
|
-
scope.match("/:model_name", :method => :post).
|
|
64
|
-
to(:controller => "main", :action => "create").
|
|
65
|
-
name(:create)
|
|
66
|
-
|
|
67
|
-
scope.match("/:model_name/:id", :method => :put).
|
|
68
|
-
to(:controller => "main", :action => "update").
|
|
69
|
-
name(:update)
|
|
70
|
-
|
|
71
|
-
scope.match("/:model_name/:id/delete", :method => :get).
|
|
72
|
-
to(:controller => "main", :action => "delete").
|
|
73
|
-
name(:delete)
|
|
74
|
-
|
|
75
|
-
scope.match("/:model_name/:id(.:format)", :method => :delete).
|
|
76
|
-
to(:controller => "main", :action => "destroy").
|
|
77
|
-
name(:destroy)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Setup the slice layout for MerbAdmin
|
|
83
|
-
#
|
|
84
|
-
# Use MerbAdmin.push_path and MerbAdmin.push_app_path
|
|
85
|
-
# to set paths to merb-admin-level and app-level paths. Example:
|
|
86
|
-
#
|
|
87
|
-
# MerbAdmin.push_path(:application, MerbAdmin.root)
|
|
88
|
-
# MerbAdmin.push_app_path(:application, Merb.root / 'slices' / 'merb-admin')
|
|
89
|
-
# ...
|
|
90
|
-
#
|
|
91
|
-
# Any component path that hasn't been set will default to MerbAdmin.root
|
|
92
|
-
#
|
|
93
|
-
# Or just call setup_default_structure! to setup a basic Merb MVC structure.
|
|
94
|
-
MerbAdmin.setup_default_structure!
|
|
95
|
-
|
|
96
|
-
# Add dependencies for other MerbAdmin classes below. Example:
|
|
97
|
-
# dependency "merb-admin/other"
|
|
98
|
-
|
|
99
|
-
end
|
|
1
|
+
if defined?(Merb::Plugins)
|
|
2
|
+
|
|
3
|
+
$:.unshift File.dirname(__FILE__)
|
|
4
|
+
|
|
5
|
+
Merb::Plugins.add_rakefiles "merb-admin/merbtasks", "merb-admin/slicetasks", "merb-admin/spectasks"
|
|
6
|
+
|
|
7
|
+
# Register the Slice for the current host application
|
|
8
|
+
Merb::Slices::register(__FILE__)
|
|
9
|
+
|
|
10
|
+
# Slice configuration - set this in a before_app_loads callback.
|
|
11
|
+
# By default a Slice uses its own layout, so you can swicht to
|
|
12
|
+
# the main application layout or no layout at all if needed.
|
|
13
|
+
#
|
|
14
|
+
# Configuration options:
|
|
15
|
+
# :layout - the layout to use; defaults to :merb-admin
|
|
16
|
+
# :mirror - which path component types to use on copy operations; defaults to all
|
|
17
|
+
Merb::Slices::config[:merb_admin][:layout] ||= :merb_admin
|
|
18
|
+
Merb::Slices::config[:merb_admin][:per_page] ||= 100
|
|
19
|
+
Merb::Slices::config[:merb_admin][:excluded_models] ||= []
|
|
20
|
+
|
|
21
|
+
# All Slice code is expected to be namespaced inside a module
|
|
22
|
+
module MerbAdmin
|
|
23
|
+
|
|
24
|
+
# Slice metadata
|
|
25
|
+
self.description = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
|
|
26
|
+
self.version = "0.8.3"
|
|
27
|
+
self.author = "Erik Michaels-Ober"
|
|
28
|
+
|
|
29
|
+
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
|
30
|
+
# right after a slice's classes have been loaded internally.
|
|
31
|
+
def self.loaded
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Initialization hook - runs before AfterAppLoads BootLoader
|
|
35
|
+
def self.init
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Activation hook - runs after AfterAppLoads BootLoader
|
|
39
|
+
def self.activate
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Deactivation hook - triggered by Merb::Slices.deactivate(MerbAdmin)
|
|
43
|
+
def self.deactivate
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.setup_router(scope)
|
|
47
|
+
scope.match("/", :method => :get).
|
|
48
|
+
to(:controller => "main", :action => "index").
|
|
49
|
+
name(:dashboard)
|
|
50
|
+
|
|
51
|
+
scope.match("/:model_name", :method => :get).
|
|
52
|
+
to(:controller => "main", :action => "list").
|
|
53
|
+
name(:list)
|
|
54
|
+
|
|
55
|
+
scope.match("/:model_name/new", :method => :get).
|
|
56
|
+
to(:controller => "main", :action => "new").
|
|
57
|
+
name(:new)
|
|
58
|
+
|
|
59
|
+
scope.match("/:model_name/:id/edit", :method => :get).
|
|
60
|
+
to(:controller => "main", :action => "edit").
|
|
61
|
+
name(:edit)
|
|
62
|
+
|
|
63
|
+
scope.match("/:model_name", :method => :post).
|
|
64
|
+
to(:controller => "main", :action => "create").
|
|
65
|
+
name(:create)
|
|
66
|
+
|
|
67
|
+
scope.match("/:model_name/:id", :method => :put).
|
|
68
|
+
to(:controller => "main", :action => "update").
|
|
69
|
+
name(:update)
|
|
70
|
+
|
|
71
|
+
scope.match("/:model_name/:id/delete", :method => :get).
|
|
72
|
+
to(:controller => "main", :action => "delete").
|
|
73
|
+
name(:delete)
|
|
74
|
+
|
|
75
|
+
scope.match("/:model_name/:id(.:format)", :method => :delete).
|
|
76
|
+
to(:controller => "main", :action => "destroy").
|
|
77
|
+
name(:destroy)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Setup the slice layout for MerbAdmin
|
|
83
|
+
#
|
|
84
|
+
# Use MerbAdmin.push_path and MerbAdmin.push_app_path
|
|
85
|
+
# to set paths to merb-admin-level and app-level paths. Example:
|
|
86
|
+
#
|
|
87
|
+
# MerbAdmin.push_path(:application, MerbAdmin.root)
|
|
88
|
+
# MerbAdmin.push_app_path(:application, Merb.root / 'slices' / 'merb-admin')
|
|
89
|
+
# ...
|
|
90
|
+
#
|
|
91
|
+
# Any component path that hasn't been set will default to MerbAdmin.root
|
|
92
|
+
#
|
|
93
|
+
# Or just call setup_default_structure! to setup a basic Merb MVC structure.
|
|
94
|
+
MerbAdmin.setup_default_structure!
|
|
95
|
+
|
|
96
|
+
# Add dependencies for other MerbAdmin classes below. Example:
|
|
97
|
+
# dependency "merb-admin/other"
|
|
98
|
+
|
|
99
|
+
end
|