forked from radiant/radiant-multi-site-extension
-
Notifications
You must be signed in to change notification settings - Fork 6
/
multi_site_extension.rb
60 lines (49 loc) · 2.03 KB
/
multi_site_extension.rb
1
2
3
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
require_dependency 'application_controller'
class MultiSiteExtension < Radiant::Extension
version "0.8.1"
description %{ Enables virtual sites to be created with associated domain names.
Also scopes the sitemap view to any given page (or the root of an
individual site) and allows model classes to be scoped by site. }
url "http://radiantcms.org/"
define_routes do |map|
map.namespace :admin, :member => { :remove => :get } do |admin|
admin.resources :sites, :member => {
:move_higher => :post,
:move_lower => :post,
:move_to_top => :put,
:move_to_bottom => :put
}
end
end
def activate
# ActionController::Routing modules are required rather than sent as includes
# because the routing persists between dev. requests and is not compatible
# with multiple alias_method_chain calls.
require 'multi_site/route_extensions'
require 'multi_site/route_set_extensions'
# likewise for ScopedValidation, which is a pre-emptive hack that shouldn't run more than once.
require 'multi_site/scoped_validation'
# Model extensions
ActiveRecord::Base.send :include, MultiSite::ScopedModel
Page.send :include, MultiSite::PageExtensions
# Controller extensions
ApplicationController.send :include, MultiSite::ApplicationControllerExtensions
SiteController.send :include, MultiSite::SiteControllerExtensions
Admin::ResourceController.send :include, MultiSite::ResourceControllerExtensions
Admin::PagesController.send :include, MultiSite::PagesControllerExtensions
unless defined? admin.site
Radiant::AdminUI.send :include, MultiSite::AdminUI
admin.site = Radiant::AdminUI.load_default_site_regions
end
if respond_to?(:tab)
tab("Content") do
add_item "Sites", "/admin/sites", :visibility => [:admin]
end
else
admin.tabs.add "Sites", "/admin/sites", :visibility => [:admin]
end
end
def deactivate
end
end
class ActiveRecord::SiteNotFound < Exception; end