refinerycms-multisite 0.0.2 → 0.0.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/app/models/site.rb
CHANGED
@@ -12,23 +12,4 @@ class Site < ActiveRecord::Base
|
|
12
12
|
Site.joins(:hostnames).where(:hostnames=>{:hostname=>hostname}).first ||
|
13
13
|
Site.joins(:hostnames).where(:hostnames=>{:hostname=>'*'}).first
|
14
14
|
end
|
15
|
-
|
16
|
-
# Monkey-Patch the Page-Controller for loading the right root-Page
|
17
|
-
PagesController.class_eval do
|
18
|
-
def home
|
19
|
-
if (@site)
|
20
|
-
error_404 unless (@page = Page.find(@site.page_id)).present?
|
21
|
-
else
|
22
|
-
error_404 unless (@page = Page.where(:link_url => '/').first).present?
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
# Monkey-Patch the Application-Controller for loading the current site
|
27
|
-
ApplicationController.class_eval do
|
28
|
-
prepend_before_filter :load_site
|
29
|
-
protected
|
30
|
-
def load_site
|
31
|
-
@site = Site.find_by_hostname(request.host)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
15
|
+
end
|
@@ -19,4 +19,25 @@ module Refinery
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ActionController::Base
|
25
|
+
# Loading the Current Site
|
26
|
+
before_filter :load_site
|
27
|
+
protected
|
28
|
+
def load_site
|
29
|
+
@site = Site.find_by_hostname(request.host)
|
30
|
+
# Monkey-Patch the Page-Controller for loading the right root-Page
|
31
|
+
return if ::PagesController.new.respond_to? :home_with_site
|
32
|
+
::PagesController.class_eval do
|
33
|
+
def home_with_site
|
34
|
+
if (@site)
|
35
|
+
error_404 unless (@page = Page.find(@site.page_id)).present?
|
36
|
+
else
|
37
|
+
home_without_site
|
38
|
+
end
|
39
|
+
end
|
40
|
+
alias_method_chain :home, :site
|
41
|
+
end
|
42
|
+
end
|
22
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-multisite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Andreas K\xC3\xB6nig"
|
@@ -75,7 +75,6 @@ files:
|
|
75
75
|
- Gemfile
|
76
76
|
- Rakefile
|
77
77
|
- app/controllers/admin/sites_controller.rb
|
78
|
-
- app/controllers/application_controller.rb
|
79
78
|
- app/helpers/admin/sites_helper.rb
|
80
79
|
- app/helpers/application_helper.rb
|
81
80
|
- app/models/hostname.rb
|