@bigbinary/neeto-custom-domains-frontend 3.1.3 → 3.1.4
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.
- package/README.md +27 -7
- package/dist/CustomDomain.js +2 -1
- package/dist/CustomDomain.js.map +1 -1
- package/dist/cjs/CustomDomain.js +2 -1
- package/dist/cjs/CustomDomain.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ bundle install
|
|
|
33
33
|
3. Run migrations
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
-
rails
|
|
36
|
+
rails neeto_custom_domains_engine:install:migrations
|
|
37
37
|
rails db:migrate
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -42,8 +42,24 @@ rails db:migrate
|
|
|
42
42
|
1. Add association
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
|
+
# If custom domain is associated to Organization
|
|
45
46
|
class Organization > ApplicationRecord
|
|
46
|
-
|
|
47
|
+
has_many :custom_domains, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
|
|
48
|
+
|
|
49
|
+
# Optional
|
|
50
|
+
def primary_custom_domain
|
|
51
|
+
custom_domains&.where.missing(:redirection)&.first
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# If custom domain is associated to other resources (eg: Site)
|
|
56
|
+
class Site > ApplicationRecord
|
|
57
|
+
has_many :custom_domains, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
|
|
58
|
+
|
|
59
|
+
# Optional
|
|
60
|
+
def primary_custom_domain
|
|
61
|
+
custom_domains&.where.missing(:redirection)&.first
|
|
62
|
+
end
|
|
47
63
|
end
|
|
48
64
|
```
|
|
49
65
|
|
|
@@ -56,12 +72,14 @@ to load some records from the host app controller.
|
|
|
56
72
|
class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
|
|
57
73
|
private
|
|
58
74
|
|
|
75
|
+
# If custom_domain is associated to Organization
|
|
59
76
|
def load_custom_domainable!
|
|
60
|
-
@custom_domainable = organization
|
|
77
|
+
@custom_domainable = organization
|
|
61
78
|
end
|
|
62
79
|
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
# If custom_domain is associated to other resources (eg: site)
|
|
81
|
+
def load_custom_domainable!
|
|
82
|
+
@custom_domainable = organization.sites.find(params[:site_id])
|
|
65
83
|
end
|
|
66
84
|
end
|
|
67
85
|
```
|
|
@@ -79,8 +97,8 @@ include NeetoCustomDomainsEngine::Routes::Draw
|
|
|
79
97
|
# config/routes.rb
|
|
80
98
|
custom_domains_routes :acme
|
|
81
99
|
|
|
82
|
-
# routes/
|
|
83
|
-
|
|
100
|
+
# routes/api.rb within the admin routes
|
|
101
|
+
custom_domains_routes :domain
|
|
84
102
|
```
|
|
85
103
|
|
|
86
104
|
5. Add frontend component. `url` should be the api to the custom domains
|
|
@@ -205,3 +223,5 @@ guide for details on how to publish.
|
|
|
205
223
|
- NeetoRecord
|
|
206
224
|
- NeetoPublish
|
|
207
225
|
- NeetoCourse
|
|
226
|
+
- NeetoCode
|
|
227
|
+
- NeetoDesk
|
package/dist/CustomDomain.js
CHANGED
|
@@ -448,7 +448,8 @@ var DomainField = function DomainField(_ref) {
|
|
|
448
448
|
var strategy = _ref3.strategy;
|
|
449
449
|
return handleDomainCreation(handleStrategy[strategy]);
|
|
450
450
|
};
|
|
451
|
-
var getHostname = function getHostname(
|
|
451
|
+
var getHostname = function getHostname(hostname) {
|
|
452
|
+
var url = hostname.includes("://") ? hostname : "https://".concat(hostname);
|
|
452
453
|
try {
|
|
453
454
|
var parsedUrl = new URL(url);
|
|
454
455
|
return parsedUrl.hostname;
|