site_framework 4.2.0 → 4.3.0
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 +4 -4
- data/README.md +3 -3
- data/app/models/site_framework/domain.rb +14 -2
- data/db/migrate/20140118200201_create_site_framework_domains.rb +11 -3
- data/db/migrate/20140303141448_create_site_framework_sites.rb +4 -1
- data/lib/site_framework/active_record/migration.rb +5 -1
- data/lib/site_framework/engine.rb +11 -4
- data/lib/site_framework/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 837e5016c615d68c84e770a07dbda43a710064d0
|
4
|
+
data.tar.gz: 332d2d238b919e11075f25aa138d69ffd7f39926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8973d21a898910927bfc74f1683faccff9d83e926579205d1eca8585196b4afe52a230f2191ee8881f3e9d88e072a8d0bf3d0134fb808957b3727950174b8d81
|
7
|
+
data.tar.gz: 0a726fd7956bb053df96c438e911c893af119086506aabf091c7ac24b58ca8ade1ddf94eff6c4accd23b25cba3cf762baf444ab81062fd3dc7cb431d2aa9b196
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ make them domain aware (ActiveRecord Only). e.g in your migration:
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
# Make posts table domain aware
|
36
|
-
|
36
|
+
site_aware(:posts)
|
37
37
|
```
|
38
38
|
|
39
39
|
If you're using **Mongoid** just add a reference to **SiteFramework::Domain** in your model.
|
@@ -73,7 +73,7 @@ Note: You can provide default domains for **SiteFramework** via an
|
|
73
73
|
initializer like this:
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
SiteFramework.setup do |config|
|
76
|
+
SiteFramework::Engine.setup do |config|
|
77
77
|
|
78
78
|
config.default_domains = ['localhost', 'example.com']
|
79
79
|
|
@@ -102,7 +102,7 @@ In case of default site these methods will return `nil`
|
|
102
102
|
### Model Concern
|
103
103
|
**SiteFramework** provides an **ActiveSupport** concern which transparently
|
104
104
|
makes your models aware of the current **Site** and **Domain**. By includeing
|
105
|
-
`SiteFramework::
|
105
|
+
`SiteFramework::SiteAware` into your model, default scope of your model will
|
106
106
|
change to return only records which belongs to current **Site**.
|
107
107
|
|
108
108
|
This way you can use external gems with your multi-site application easily.
|
@@ -4,7 +4,7 @@ module SiteFramework
|
|
4
4
|
# belongs to another **Domain**
|
5
5
|
class Domain < (defined?(ActiveRecord) ? ActiveRecord::Base : Object)
|
6
6
|
|
7
|
-
PATTERN = /\A[a-z0-9]
|
7
|
+
PATTERN = /\A[a-z0-9]*(\.?[a-z0-9]+)\.[a-z]{2,5}(:[0-9]{1,5})?(\/.)?$/ix
|
8
8
|
|
9
9
|
if defined? Mongoid
|
10
10
|
include Mongoid::Document
|
@@ -31,7 +31,9 @@ module SiteFramework
|
|
31
31
|
validates_associated :site
|
32
32
|
end
|
33
33
|
|
34
|
-
validates
|
34
|
+
validates :name, presence: true, if: :valid_domain_name?
|
35
|
+
|
36
|
+
|
35
37
|
validates_uniqueness_of :name
|
36
38
|
|
37
39
|
before_save :normalize_name
|
@@ -39,5 +41,15 @@ module SiteFramework
|
|
39
41
|
def normalize_name
|
40
42
|
self.name = name.downcase
|
41
43
|
end
|
44
|
+
|
45
|
+
def valid_domain_name?
|
46
|
+
if read_attribute :alias
|
47
|
+
false unless name =~ PATTERN
|
48
|
+
# TODO: Check the owner of domain
|
49
|
+
else
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
42
54
|
end
|
43
55
|
end
|
@@ -1,9 +1,17 @@
|
|
1
1
|
class CreateSiteFrameworkDomains < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if SiteFramework::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table :site_framework_domains, **args do |t|
|
4
7
|
t.string :name
|
5
|
-
|
6
|
-
|
8
|
+
if SiteFramework::Engine.use_uuid
|
9
|
+
t.uuid :site_id
|
10
|
+
t.uuid :parent_id, default: nil
|
11
|
+
else
|
12
|
+
t.integer :site_id
|
13
|
+
t.integer :parent_id, default: nil
|
14
|
+
end
|
7
15
|
t.boolean :alias, default: false
|
8
16
|
|
9
17
|
t.timestamps
|
@@ -1,6 +1,9 @@
|
|
1
1
|
class CreateSiteFrameworkSites < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if SiteFramework::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table :site_framework_sites, **args do |t|
|
4
7
|
t.string :title
|
5
8
|
t.string :description
|
6
9
|
|
@@ -9,13 +9,20 @@ module SiteFramework
|
|
9
9
|
g.test_framework :rspec
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
mattr_accessor :default_domains
|
12
|
+
|
13
|
+
mattr_accessor :default_domains do
|
14
|
+
['localhost']
|
15
|
+
end
|
14
16
|
|
15
17
|
# This option allows developers to specify the prefix of path
|
16
18
|
# which they wanted to prepend to view_paths array
|
17
|
-
mattr_accessor :view_path_prefix
|
18
|
-
|
19
|
+
mattr_accessor :view_path_prefix do
|
20
|
+
'app/views'
|
21
|
+
end
|
22
|
+
|
23
|
+
mattr_accessor :use_uuid do
|
24
|
+
false
|
25
|
+
end
|
19
26
|
|
20
27
|
def self.setup
|
21
28
|
yield self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sameer Rahmani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|