trusty-multi-site-extension 1.2.1 → 2.0.0.pre.beta
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.
- checksums.yaml +8 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +12 -0
- data/Rakefile +121 -119
- data/app/models/site.rb +2 -2
- data/app/views/admin/layouts/_choose_site.html.haml +1 -1
- data/app/views/admin/snippets/_choose_site.html.haml +1 -1
- data/app/views/admin/users/_choose_site.html.haml +1 -1
- data/config/trustygems.yml +2 -0
- data/lib/multi_site/scoped_model.rb +2 -15
- data/lib/multi_site/site_chooser_helper.rb +1 -1
- data/trusty-multi-site-extension.gemspec +4 -5
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWIxODlhMmY0ODI2ODU0NTRiYTMzN2RmOGI2ZDU5ZDcxODQxNDJjYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzUyN2E3ZWNjYzNjZGU2YmIyMjM3OGJhN2Y1Yzg0NTljODhlNmE5Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGFkNmQ2NjQwZjRjNjQzM2YzMjdhMWM3Y2I2Y2U1ZWZkYmU2YTUwY2FjYWU0
|
10
|
+
NTBjODMyMWZhMDgxMWEwNjcwMjQxNzg3NzAxY2I5NzZkMGY4MDU3NDFjN2Mz
|
11
|
+
MmMyODI2OTJlNjg5ODQxNmVmZDFiOTRjODlhNmZlNGU5NDMxZTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTk3MzI1Y2YxMjJmNWEyYTU5MzAyYzQ5MjA3NGMyNDM4NmRhMjdiNWNiOTdi
|
14
|
+
MGVjOTEyZjE5Yjc0ZjVmNTRlMzQ2NDlkOGM2NDFiN2ZiY2Q4M2JhNDMwZTM4
|
15
|
+
ODgyOTZhYjA1N2YwMDk3NDJhZTI2ZGI0YmFkNDAwZDMxMmFjYmQ=
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Rakefile
CHANGED
@@ -1,120 +1,122 @@
|
|
1
|
-
|
1
|
+
require 'trustygems'
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
require 'rake
|
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
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
#
|
120
|
-
|
3
|
+
# # I think this is the one that should be moved to the extension Rakefile template
|
4
|
+
#
|
5
|
+
# # In rails 1.2, plugins aren't available in the path until they're loaded.
|
6
|
+
# # Check to see if the rspec plugin is installed first and require
|
7
|
+
# # it if it is. If not, use the gem version.
|
8
|
+
#
|
9
|
+
# # Determine where the RSpec plugin is by loading the boot
|
10
|
+
# unless defined? TRUSTY_CMS_ROOT
|
11
|
+
# ENV["RAILS_ENV"] = "test"
|
12
|
+
# case
|
13
|
+
# when ENV["TRUSTY_ENV_FILE"]
|
14
|
+
# require File.dirname(ENV["TRUSTY_ENV_FILE"]) + "/boot"
|
15
|
+
# when File.dirname(__FILE__) =~ %r{vendor/trusty_cms/vendor/extensions}
|
16
|
+
# require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
17
|
+
# else
|
18
|
+
# require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# require 'rake'
|
23
|
+
# require 'rake/rdoctask'
|
24
|
+
# require 'rake/testtask'
|
25
|
+
#
|
26
|
+
# rspec_base = File.expand_path(TRUSTY_CMS_ROOT + '/vendor/plugins/rspec/lib')
|
27
|
+
# $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
28
|
+
# require 'spec/rake/spectask'
|
29
|
+
# # require 'spec/translator'
|
30
|
+
#
|
31
|
+
# # Cleanup the TRUSTY_CMS_ROOT constant so specs will load the environment
|
32
|
+
# Object.send(:remove_const, :TRUSTY_CMS_ROOT)
|
33
|
+
#
|
34
|
+
# extension_root = File.expand_path(File.dirname(__FILE__))
|
35
|
+
#
|
36
|
+
# task :default => :spec
|
37
|
+
# task :stats => "spec:statsetup"
|
38
|
+
#
|
39
|
+
# desc "Run all specs in spec directory"
|
40
|
+
# Spec::Rake::SpecTask.new(:spec) do |t|
|
41
|
+
# t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
42
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# namespace :spec do
|
46
|
+
# desc "Run all specs in spec directory with RCov"
|
47
|
+
# Spec::Rake::SpecTask.new(:rcov) do |t|
|
48
|
+
# t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
49
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
50
|
+
# t.rcov = true
|
51
|
+
# t.rcov_opts = ['--exclude', 'spec', '--rails']
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# desc "Print Specdoc for all specs"
|
55
|
+
# Spec::Rake::SpecTask.new(:doc) do |t|
|
56
|
+
# t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
57
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# [:models, :controllers, :views, :helpers].each do |sub|
|
61
|
+
# desc "Run the specs under spec/#{sub}"
|
62
|
+
# Spec::Rake::SpecTask.new(sub) do |t|
|
63
|
+
# t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
64
|
+
# t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# # Hopefully no one has written their extensions in pre-0.9 style
|
69
|
+
# # desc "Translate specs from pre-0.9 to 0.9 style"
|
70
|
+
# # task :translate do
|
71
|
+
# # translator = ::Spec::Translator.new
|
72
|
+
# # dir = RAILS_ROOT + '/spec'
|
73
|
+
# # translator.translate(dir, dir)
|
74
|
+
# # end
|
75
|
+
#
|
76
|
+
# # Setup specs for stats
|
77
|
+
# task :statsetup do
|
78
|
+
# require 'code_statistics'
|
79
|
+
# ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
80
|
+
# ::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
81
|
+
# ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
82
|
+
# ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
83
|
+
# ::CodeStatistics::TEST_TYPES << "Model specs"
|
84
|
+
# ::CodeStatistics::TEST_TYPES << "View specs"
|
85
|
+
# ::CodeStatistics::TEST_TYPES << "Controller specs"
|
86
|
+
# ::CodeStatistics::TEST_TYPES << "Helper specs"
|
87
|
+
# ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# namespace :db do
|
91
|
+
# namespace :fixtures do
|
92
|
+
# desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
93
|
+
# task :load => :environment do
|
94
|
+
# require 'active_record/fixtures'
|
95
|
+
# ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
96
|
+
# (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
97
|
+
# Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# desc 'Generate documentation for the <%= file_name %> extension.'
|
105
|
+
# Rake::RDocTask.new(:rdoc) do |rdoc|
|
106
|
+
# rdoc.rdoc_dir = 'rdoc'
|
107
|
+
# rdoc.title = '<%= class_name %>'
|
108
|
+
# rdoc.options << '--line-numbers' << '--inline-source'
|
109
|
+
# rdoc.rdoc_files.include('README')
|
110
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
111
|
+
# end
|
112
|
+
#
|
113
|
+
# # For extensions that are in transition
|
114
|
+
# desc 'Test the <%= file_name %> extension.'
|
115
|
+
# Rake::TestTask.new(:test) do |t|
|
116
|
+
# t.libs << 'lib'
|
117
|
+
# t.pattern = 'test/**/*_test.rb'
|
118
|
+
# t.verbose = true
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# # Load any custom rakefiles for extension
|
122
|
+
# Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/app/models/site.rb
CHANGED
@@ -7,7 +7,7 @@ class Site < ActiveRecord::Base
|
|
7
7
|
belongs_to :updated_by, :class_name => 'User'
|
8
8
|
belongs_to :production_homepage , :class_name => 'ProductionPage'
|
9
9
|
|
10
|
-
default_scope
|
10
|
+
default_scope {order('position ASC')}
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_accessor :several
|
@@ -16,7 +16,7 @@ class Site < ActiveRecord::Base
|
|
16
16
|
|
17
17
|
def find_for_host(hostname = '')
|
18
18
|
return default if hostname.blank?
|
19
|
-
sites =
|
19
|
+
sites = where("domain IS NOT NULL")
|
20
20
|
site = sites.find { |site| hostname == site.base_domain || hostname =~ Regexp.compile(site.domain) }
|
21
21
|
site || default
|
22
22
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
%p{:style => 'float: left; margin-right: 32px'}
|
3
3
|
%label{:for=>"layout_site_id", :Class => "admin_only"}
|
4
4
|
Site
|
5
|
-
- sites = Site.
|
5
|
+
- sites = Site.all.map { |s| [s.name, s.id] }
|
6
6
|
- selection = {:include_blank => Layout.is_shareable?}
|
7
7
|
- selection[:selected] = current_site.id if @layout.new_record? && ! Layout.is_shareable?
|
8
8
|
= select :layout, :site_id, sites, selection
|
@@ -2,5 +2,5 @@
|
|
2
2
|
%p{:style => 'float: left; margin-right: 32px'}
|
3
3
|
%label{:for=>"snippet_site_id", :Class => "admin_only"}
|
4
4
|
Site
|
5
|
-
- sites = Site.
|
5
|
+
- sites = Site.all.map { |s| [s.name, s.id] }
|
6
6
|
= select :snippet, :site_id, sites, :include_blank => Snippet.is_shareable?, :selected => @snippet.site_id || current_site.id
|
@@ -3,6 +3,6 @@
|
|
3
3
|
%th.label
|
4
4
|
%label{:for=>"user_admin"} Can edit site
|
5
5
|
%td.field{:style => 'text-align: left;'}
|
6
|
-
= select :user, :site_id, [['<any>', '']] + Site.
|
6
|
+
= select :user, :site_id, [['<any>', '']] + Site.all.map { |s| [s.name, s.id] }
|
7
7
|
%td.help
|
8
8
|
A user with no site is able to act (to whatever extent their status allows) on any site.
|
@@ -25,6 +25,7 @@ module MultiSite
|
|
25
25
|
}.merge(options)
|
26
26
|
|
27
27
|
class_eval <<-EO
|
28
|
+
default_scope {where(site_scope_condition)}
|
28
29
|
extend MultiSite::ScopedModel::ScopedClassMethods
|
29
30
|
include MultiSite::ScopedModel::ScopedInstanceMethods
|
30
31
|
EO
|
@@ -37,8 +38,6 @@ module MultiSite
|
|
37
38
|
|
38
39
|
class << self
|
39
40
|
attr_accessor :shareable
|
40
|
-
alias_method_chain :all, :site
|
41
|
-
alias_method_chain :where, :site
|
42
41
|
alias_method_chain :paginate, :site
|
43
42
|
%w{count average minimum maximum sum}.each do |getter|
|
44
43
|
alias_method_chain getter.intern, :site
|
@@ -50,23 +49,11 @@ module MultiSite
|
|
50
49
|
end
|
51
50
|
|
52
51
|
module ScopedClassMethods
|
53
|
-
def all_with_site(options = {})
|
54
|
-
return all_without_site(options) unless sites?
|
55
|
-
with_scope(:find => {:conditions => site_scope_condition}) do
|
56
|
-
all_without_site(options)
|
57
|
-
end
|
58
|
-
end
|
59
52
|
|
60
|
-
def where_with_site(options = {})
|
61
|
-
return where_without_site(options) unless sites?
|
62
|
-
with_scope(:find => {:conditions => site_scope_condition}) do
|
63
|
-
where_without_site(options)
|
64
|
-
end
|
65
|
-
end
|
66
53
|
|
67
54
|
def paginate_with_site(options={})
|
68
55
|
return paginate_without_site(options) unless sites?
|
69
|
-
|
56
|
+
where(site_scope_condition) do
|
70
57
|
paginate_without_site(options)
|
71
58
|
end
|
72
59
|
end
|
@@ -2,7 +2,7 @@ module MultiSite::SiteChooserHelper
|
|
2
2
|
|
3
3
|
def sites_chooser_thing
|
4
4
|
return "" unless admin? && defined?(Site) && defined?(controller) && controller.sited_model? && controller.template_name == 'index' && Site.several?
|
5
|
-
options = Site.
|
5
|
+
options = Site.all.map{ |site| "<li>" + link_to( site.name, "#{request.path}?site_id=#{site.id}", :class => site == current_site ? 'fg' : '') + "</li>" }.join("")
|
6
6
|
chooser = %{<div id="site_chooser">}
|
7
7
|
#chooser << link_to("sites", admin_sites_url, {:id => 'show_site_list', :class => 'expandable'})
|
8
8
|
chooser << %{<ul id="nav"><li>Current Site: #{current_site.name}}
|
@@ -4,10 +4,9 @@ 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 = "
|
7
|
+
s.version = "2.0.0-beta"
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.authors = ["Eric Sipple"]
|
10
|
-
s.date = %q{2014-10-07}
|
9
|
+
s.authors = ["Sean Cribbs", "Eric Sipple", "Danielle Greaves"]
|
11
10
|
s.description = %q{Extends Trusty CMS Layouts to support multiple sites, defined by domain}
|
12
11
|
s.email = %q{sipple@trustarts.org}
|
13
12
|
s.homepage = %q{https://github.com/pgharts/trusty-multi-site-extension}
|
@@ -23,6 +22,6 @@ Gem::Specification.new do |s|
|
|
23
22
|
# s.executables = Dir['bin/*'] - ignores
|
24
23
|
s.require_paths = ["lib"]
|
25
24
|
s.add_dependency "acts_as_list", "0.4.0"
|
26
|
-
s.add_dependency "trusty-snippets-extension", "~>
|
27
|
-
s.add_dependency "trusty-cms", "~>
|
25
|
+
s.add_dependency "trusty-snippets-extension", "~> 2.0.0-beta"
|
26
|
+
s.add_dependency "trusty-cms", "~> 2.0.0-beta"
|
28
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trusty-multi-site-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Sean Cribbs
|
7
8
|
- Eric Sipple
|
9
|
+
- Danielle Greaves
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: acts_as_list
|
@@ -30,34 +32,36 @@ dependencies:
|
|
30
32
|
requirements:
|
31
33
|
- - ~>
|
32
34
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
35
|
+
version: 2.0.0.pre.beta
|
34
36
|
type: :runtime
|
35
37
|
prerelease: false
|
36
38
|
version_requirements: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
40
|
- - ~>
|
39
41
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
42
|
+
version: 2.0.0.pre.beta
|
41
43
|
- !ruby/object:Gem::Dependency
|
42
44
|
name: trusty-cms
|
43
45
|
requirement: !ruby/object:Gem::Requirement
|
44
46
|
requirements:
|
45
47
|
- - ~>
|
46
48
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
49
|
+
version: 2.0.0.pre.beta
|
48
50
|
type: :runtime
|
49
51
|
prerelease: false
|
50
52
|
version_requirements: !ruby/object:Gem::Requirement
|
51
53
|
requirements:
|
52
54
|
- - ~>
|
53
55
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
56
|
+
version: 2.0.0.pre.beta
|
55
57
|
description: Extends Trusty CMS Layouts to support multiple sites, defined by domain
|
56
58
|
email: sipple@trustarts.org
|
57
59
|
executables: []
|
58
60
|
extensions: []
|
59
61
|
extra_rdoc_files: []
|
60
62
|
files:
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
61
65
|
- README.markdown
|
62
66
|
- Rakefile
|
63
67
|
- app/assets/images/admin/move_higher.png
|
@@ -82,6 +86,7 @@ files:
|
|
82
86
|
- app/views/site/not_configured.html.haml
|
83
87
|
- config/initializers/radiant_config.rb
|
84
88
|
- config/routes.rb
|
89
|
+
- config/trustygems.yml
|
85
90
|
- db/migrate/001_create_sites.rb
|
86
91
|
- db/migrate/002_add_order_to_sites.rb
|
87
92
|
- db/migrate/003_add_base_domain_to_sites.rb
|