site_framework 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62be8f127063701148dbaea74352fe781c1f78a2
4
- data.tar.gz: 39437c595f044e4a4ef5d6733b5178fa678b464c
3
+ metadata.gz: 2b4252d95379b102c247dc309c261d045fe84937
4
+ data.tar.gz: 68c40e49d6cff491ca81c2f57253753d0fa986b6
5
5
  SHA512:
6
- metadata.gz: a9e3ca92919e98c4db6a46a08aaafc54045ef7ddf5192b2c74389b1222510f729b57fe418e9f138262ae7964e40f3bc9d001054af753dd8a4ac2824326257198
7
- data.tar.gz: 8a51d6565a1b2725fa0bcad57cab31f213119c7c12d235a5728c6dd9eab37c14a5673c23a2dd886b28d672232cd820c5e2e60debc4f0c10b26e1827f0671ee1a
6
+ metadata.gz: 040026c637f50af1f17a72eec6ea6df09d99e508cf0805eeb47e15d6037d30eef3a7669aed08610264a07bcda4efc70e20690c10c9a57c026234d74ee4b7e438
7
+ data.tar.gz: 7f68cb7cf99211f460a8069e670e66ddc4cc7e550581376308b70320ace6f17970ee19db341f942ba27ec753c8cf690299099f892d3c96da022f48815f7852d2
@@ -3,10 +3,10 @@ ActionController::Base.class_eval do
3
3
  private
4
4
 
5
5
  def set_template_path
6
- unless request.site
6
+ if request.site
7
7
  # We are in site namespace
8
8
  unless request.site.default_template.blank?
9
- prepend_view_path[request.site.default_template]
9
+ prepend_view_path "app/views/#{request.site.default_template}"
10
10
  end
11
11
  end
12
12
  end
@@ -13,29 +13,34 @@ class SiteFramework::Routing::DefaultConstraint
13
13
  @domain_name = request.host
14
14
 
15
15
  if @default_domains.include? @domain_name
16
- logger.debug("Loading default site configuration")
16
+ logger.debug('Loading default site configuration')
17
+ patch_request(request)
18
+ true
19
+
20
+ else
21
+ logger.info("Domain name '#{request.host}' does not match with any exist domains")
22
+ patch_request(request)
23
+ false
24
+ end
25
+ end
17
26
 
18
- SiteFramework::CurrentState.instance.domain_name = nil
19
- SiteFramework::CurrentState.instance.domain = nil
20
- SiteFramework::CurrentState.instance.site = nil
27
+ private
21
28
 
22
- request.instance_eval do
23
- def site
24
- end
29
+ def patch_request(request)
30
+ SiteFramework::CurrentState.instance.domain_name = nil
31
+ SiteFramework::CurrentState.instance.domain = nil
32
+ SiteFramework::CurrentState.instance.site = nil
25
33
 
26
- def domain
27
- end
34
+ request.instance_eval do
35
+ def site
36
+ end
28
37
 
29
- def domamin_name
30
- end
38
+ def domain
39
+ end
31
40
 
41
+ def domain_name
32
42
  end
33
43
 
34
- true
35
- else
36
- logger.info("Domain name '#{request.host}' does not match with any exist domains")
37
- false
38
44
  end
39
45
  end
40
-
41
46
  end
@@ -8,51 +8,67 @@ class SiteFramework::Routing::SiteConstraint
8
8
  end
9
9
 
10
10
  def domain(name)
11
- @domain ||= if defined? ActiveRecord
12
- SiteFramework::Domain.find_by(name: name)
11
+ return @domain if @domain_name == name
12
+
13
+ if defined? ActiveRecord
14
+ @domain = SiteFramework::Domain.find_by(name: name)
13
15
  elsif defined? Mongoid
14
- SiteFramework::Site.where('domains.name' => name).domains.first
16
+ @domain = SiteFramework::Site.where('domains.name' => name).domains.first
15
17
  else
16
18
  nil
17
19
  end
18
20
  end
19
21
 
20
22
  def matches?(request)
21
- @domain_name = request.host
22
-
23
23
  if domain_obj = domain(request.host)
24
- logger.debug("''#{@domain_name}' matched.")
25
- setup(domain_obj)
24
+ @domain_name = request.host
25
+ logger.debug("'#{@domain_name}' matched.")
26
+ setup(domain_obj, request)
26
27
  initialize_site_default_state
27
28
 
28
- request.instance_eval do
29
- def site
30
- domain_obj.site
31
- end
32
-
33
- def domain
34
- domain_obj.domain
35
- end
36
-
37
- def domamin_name
38
- domain_obj.domain_name
39
- end
40
- end
41
-
42
29
  true
43
30
  else
44
31
  logger.info("Domain name '#{request.host}' does not match with any exist domains")
32
+ set_request_data_to_nil(request)
33
+ @domain_name = request.host
45
34
  false
46
35
  end
47
36
  end
48
37
 
49
38
  private
50
39
 
51
- def setup(domain)
52
- SiteFramework::CurrentState.instance.domain_name = domain.name
53
- SiteFramework::CurrentState.instance.domain = domain
54
- SiteFramework::CurrentState.instance.site = domain.site
55
- @site = domain.site
40
+ def setup(domain_, request)
41
+ SiteFramework::CurrentState.instance.domain_name = domain_.name
42
+ SiteFramework::CurrentState.instance.domain = domain_
43
+ SiteFramework::CurrentState.instance.site = domain_.site
44
+ @site = domain_.site
45
+
46
+ request.instance_eval do
47
+ def site
48
+ SiteFramework::CurrentState.instance.site
49
+ end
50
+
51
+ def domain
52
+ SiteFramework::CurrentState.instance.domain
53
+ end
54
+
55
+ def domain_name
56
+ SiteFramework::CurrentState.instance.domain_name
57
+ end
58
+ end
59
+ end
60
+
61
+ def set_request_data_to_nil(request)
62
+ request.instance_eval do
63
+ def site
64
+ end
65
+
66
+ def domain
67
+ end
68
+
69
+ def domain_name
70
+ end
71
+ end
56
72
  end
57
73
 
58
74
  def initialize_site_default_state
@@ -1,3 +1,3 @@
1
1
  module SiteFramework
2
- VERSION = '4.0.0'
2
+ VERSION = '4.0.1'
3
3
  end
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.0.0
4
+ version: 4.0.1
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-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties