trusty-multi-site-extension 1.0.4 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yjc2ZDFmZDQzODlkOGM4YjI0NWI5YjAxZGFlMjgyZmNiMDRkZGY2Yw==
4
+ YTU4NmI1YTRkOTg2NTMzODdjMzc1ZWNlODk0ODE2ZjViNGFhYmVjOQ==
5
5
  data.tar.gz: !binary |-
6
- ZmMwZTA2YzVhOGFiMWY3MTZiY2I4MWFmYzAzOThlNmMzZTBjNmZiMQ==
6
+ NjNhMmM3NmFjNDI0ODRiMTc4YjU2NTM1Mzg2MTU2N2M1MDk4MjcyNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGU2ZGI4MTRkMzI1NDQ1YjYwMDQ3ZWJkN2MzYzQ5MjMwYTBiNDE5NjllNjA4
10
- ZmRjNmY5MTU3NWQ0ZjdhOGY4MTk1NDE1NzM1OWY1NmMzNGQ2NTIzN2E2OWY2
11
- ODM1NDVlNDA2YTM5YWQ4MDI2ZTc2OWNmZWI0MTAxM2Y0YzRmNDE=
9
+ ZjEzN2QyYjQ3NTkzZDAxNTRmNTg1ZTk0ODMzNmQyNDlmMjcwOTQ2NTU1ZmQx
10
+ Y2ZhNTFmYzBiNmM1YzI4NDE5MGYzYzI0NGQ5YjBmZmRlMTBiNzMzYTlmMzhj
11
+ NmY0OTM0ZWNkNDIwYTMyMDY2MDY0YTE2OWYxMWRjZGM0YmJjYmI=
12
12
  data.tar.gz: !binary |-
13
- YTljZjczN2E5MTdjMjFmMTVjODIxNjEyYWYxMjY3MDhkYTA1MTc5MDI4MzRi
14
- ZDQ5ZTZhYjlkY2NlNjE1NTcxNmIxNWUzMGE5NzY1MjU5ODc3NjRkYWYwZWNj
15
- ZDg2ZWQ3YTBkYzcxODFhZDExNzU2Y2RkMjljYTFkZGRmZjFhZTU=
13
+ NzAxN2IwYjg0ODdlMTVmNTUxN2JhOTU3NDUzNjg1ZTA5OTQ1YjdmN2QwYWMw
14
+ NzVmNDA5ZDQ1NGMxMjBhNWVlMDdjOTY0ODczYTgwNGMwMjYwZWFmNDU1ZDgy
15
+ Y2MwOTY5MDQ0MjY0M2ZlMDIyNTJlY2EzNjQ5MjIxYzg0YTI0OTc=
data/README.markdown CHANGED
@@ -1,5 +1,7 @@
1
1
  # Multi Site #
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/trusty-multi-site-extension.svg)](http://badge.fury.io/rb/trusty-multi-site-extension)
4
+
3
5
  Created by Sean Cribbs, November 2007. Inspired by the original virtual_domain behavior.
4
6
 
5
7
  Multi Site allows you to host multiple websites on a single TrustyCMS installation.
@@ -31,7 +31,7 @@
31
31
  - if f.object.new_record?
32
32
  A new homepage will be created automatically if none is specified.
33
33
  - else
34
- If you change the site homepage ID, be sure it is is to a page with no parents.
34
+ If you change the site homepage ID, be sure it is to a page with no parents.
35
35
 
36
36
  - render_region :form_bottom do |form_bottom|
37
37
  - form_bottom.edit_timestamp do
@@ -0,0 +1,24 @@
1
+ class AddSiteIdToPages < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :pages, :site_id, :integer, required: true
4
+ add_index :pages, :site_id
5
+
6
+ Site.all.each do |site|
7
+ homepage = site.homepage
8
+ homepage.site_id = site.id
9
+ homepage.save
10
+ unless homepage.id == Page.root.id
11
+ homepage.descendants.each do |page|
12
+ page.site_id = site.id
13
+ page.save
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ def self.down
21
+ remove_index :pages, site_id
22
+ remove_column :pages, :site_id
23
+ end
24
+ end
@@ -5,10 +5,16 @@ module MultiSite::PageExtensions
5
5
  base.class_eval {
6
6
  alias_method_chain :url, :sites
7
7
  mattr_accessor :current_site
8
- has_one :site, :foreign_key => "homepage_id", :dependent => :nullify
8
+ belongs_to :site
9
+ before_create :associate_with_site
9
10
  }
10
11
  base.extend ClassMethods
11
12
  class << base
13
+
14
+ def associate_with_site
15
+ self.site_id = Page.current_site.site_id if self.site_id.nil?
16
+ end
17
+
12
18
  def find_by_path(path, live=true)
13
19
  root = homepage
14
20
  raise Page::MissingRootPageError unless root
@@ -24,6 +30,11 @@ module MultiSite::PageExtensions
24
30
  end
25
31
 
26
32
  module ClassMethods
33
+
34
+ def find_by_slug_for_site(slug)
35
+ self.where(slug: slug, site_id: Page.current_site.id)
36
+ end
37
+
27
38
  def homepage
28
39
  if current_site.is_a?(Site)
29
40
  homepage = self.current_site.homepage
@@ -4,7 +4,7 @@ require "trusty-multi-site-extension"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "trusty-multi-site-extension"
7
- s.version = "1.0.4"
7
+ s.version = "1.1.4"
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Eric Sipple"]
10
10
  s.date = %q{2014-10-07}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-multi-site-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Sipple
@@ -90,6 +90,7 @@ files:
90
90
  - db/migrate/006_remove_user_login_index.rb
91
91
  - db/migrate/20090810145840_site_abbreviation.rb
92
92
  - db/migrate/201411031415046078_recreate_non_unique_index_on_snippets_name.rb
93
+ - db/migrate/2015032011031415046078_add_site_id_to_pages.rb
93
94
  - lib/multi_site/admin_ui.rb
94
95
  - lib/multi_site/application_controller_extensions.rb
95
96
  - lib/multi_site/application_controller_filter_extensions.rb