@bigbinary/neeto-custom-domains-frontend 1.1.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.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # neeto-custom-domains-engine
2
+
3
+ The `neeto-custom-domains-engine` manages custom domains across neeto applications.
4
+
5
+ ## Contents
6
+ 1. [Development with Host application](#development-with-host-application)
7
+ - [Engine](#engine)
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ 2. [Instructions for publishing](#instructions-for-publishing)
11
+
12
+ ## Development with Host application
13
+
14
+ ### Engine
15
+
16
+ The engine provides the backend setup for neetoCustomDomains.
17
+
18
+ #### Installation
19
+
20
+ 1. Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ source "NEETO_GEM_SERVER_URL" do
24
+ # ... existing gems
25
+
26
+ gem "neeto-custom-domains-engine"
27
+ end
28
+ ```
29
+
30
+ 2. And then execute:
31
+
32
+ ```shell
33
+ bundle install
34
+ ```
35
+
36
+ 3. Add this line to your application's `config/routes.rb` file:
37
+
38
+ ```ruby
39
+ mount NeetoCustomDomainsEngine::Engine => "/custom_domains"
40
+ ```
41
+
42
+ 4. Run migrations
43
+
44
+ ```
45
+ rails neeto-custom-domains-engine:install:migrations
46
+ rails db:migrate
47
+ ```
48
+
49
+ #### Usage
50
+
51
+ The steps below depend on the association that we use. In some cases, we need to attach multiple custom domains to a model, while in other cases, we only need a single custom domain. We have to make necessary configurations depending on this.
52
+
53
+ Let's say we have a "Site" model, and we want to publish our site on a custom domain.
54
+
55
+ ##### Configure `has_one` association
56
+
57
+ The site only needs to be published in a single custom domain, so we chose `has_one` association.
58
+
59
+ 1. Add association
60
+
61
+ ```ruby
62
+ class Site > ApplicationRecord
63
+ has_one :custom_domain, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
64
+ end
65
+ ```
66
+
67
+ 2. Add controller
68
+
69
+ All common controller logic is extracted to the engine. However, we still need to load some records depending on the association that we use.
70
+
71
+ ```ruby
72
+ class Api::V1::Sites::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
73
+ private
74
+
75
+ def load_custom_domainable!
76
+ @custom_domainable = organization.sites.find(params[:site_id])
77
+ end
78
+
79
+ def load_custom_domain!
80
+ @custom_domain = @custom_domainable.custom_domain
81
+ end
82
+ end
83
+ ```
84
+
85
+ 3. Add routes
86
+
87
+ ```ruby
88
+ include NeetoCustomDomainsEngine::Routes::Draw
89
+
90
+ scope module: :sites do
91
+ custom_domains_routes(route: :custom_domain)
92
+ end
93
+ ```
94
+ 4. Add front-end component
95
+
96
+ ```js
97
+ import { CustomDomain } from "@bigbinary/neeto-molecules/CustomDomain";
98
+ ```
99
+ For more info related to front-end component: https://github.com/bigbinary/neeto-molecules/blob/main/docs/components.md#customdomain
100
+
101
+ ##### Configure `has_many` association
102
+
103
+ The site needs to be published in multiple custom domains, so we chose `has_many` association.
104
+
105
+ 1. Add association
106
+
107
+ ```ruby
108
+ class Site > ApplicationRecord
109
+ has_many :custom_domain, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
110
+ end
111
+ ```
112
+
113
+ 2. Add controller
114
+ ```ruby
115
+ class Api::V1::Sites::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
116
+ private
117
+
118
+ def load_custom_domainable!
119
+ @custom_domainable = organization.sites.find(params[:site_id])
120
+ end
121
+
122
+ def load_custom_domain!
123
+ @custom_domain = @custom_domainable.custom_domains.find(params[:id])
124
+ end
125
+ end
126
+ ```
127
+
128
+ 3. Add routes
129
+
130
+ ```ruby
131
+ include NeetoCustomDomainsEngine::Routes::Draw
132
+
133
+ scope module: :sites do
134
+ custom_domains_routes(route: :custom_domain)
135
+ end
136
+ ```
137
+
138
+ 4. Add front-end component
139
+
140
+ ```js
141
+ import { CustomDomainDashBoard } from "@bigbinary/neeto-molecules/CustomDomainDashboard";
142
+ ```
143
+ For more info related to front-end component: https://github.com/bigbinary/neeto-molecules/blob/main/docs/components.md#customdomainDashboard
144
+
145
+ ##### Loading site from custom domain
146
+ Let's say we have attached the custom domain `test.neeto.com` to a site. Now, when the user tries to access `test.neeto.com` in the browser, we should display the corresponding site in the front-end. In order to achieve this, we need to load the site from the custom domain.
147
+
148
+ ```ruby
149
+ custom_domain = NeetoCustomDomainsEngine::Domain.find_by(hostname: params[:custom_domain])
150
+ if custom_domain.present?
151
+ @published_site = custom_domain.custom_domainable.published_site
152
+ else
153
+ site = Site.find_by! subdomain: params[:subdomain]
154
+ @published_site = site.published_site
155
+ end
156
+ ```
157
+
158
+ ##### ENV variables
159
+
160
+ For the working of this engine we need the following env variables.
161
+
162
+ ```
163
+ LETS_ENCRYPT_PRIVATE_KEY: < For requesting SSL certificates >
164
+ LETS_ENCRYPT_DIRECTORY_URL: < For requesting SSL certificates >
165
+ LETS_ENCRYPT_VALIDATION_DOMAIN_ACCESS_TOKEN: < For domain authentication>
166
+ LETS_ENCRYPT_VALIDATION_DOMAIN_ID: < For domain authentication>
167
+ LETS_ENCRYPT_VALIDATION_DOMAIN_NAME: < For domain authentication>
168
+ LETS_ENCRYPT_APP_NAME: < For pushing SSL certificate and custom domains >
169
+ HEROKU_AUTH_TOKEN: < For pushing SSL certificate and custom domains >
170
+ ```
171
+
172
+ ## Instructions for Publishing
173
+
174
+ Consult the [building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages) guide for details on how to publish.
@@ -0,0 +1,63 @@
1
+ {
2
+ "neetoCustomDomains": {
3
+ "common": {
4
+ "record": "record",
5
+ "name": "name",
6
+ "value": "value",
7
+ "status": "status",
8
+ "success": "Success",
9
+ "pending": "Pending"
10
+ },
11
+ "actions": {
12
+ "cancel": "Cancel",
13
+ "delete": "Delete",
14
+ "edit": "Edit",
15
+ "continue": "Continue",
16
+ "done": "Done"
17
+ },
18
+ "customDomain_one": "Custom domain",
19
+ "customDomain_other": "Custom domains",
20
+ "customDomainWithCount_one": "{{count}} custom domain",
21
+ "customDomainWithCount_other": "{{count}} custom domains",
22
+ "settings": "Custom domain settings",
23
+ "yourDomain": "Your domain",
24
+ "addNew": "Add new custom domain",
25
+ "delete": "Delete custom domain?",
26
+ "search": "Search custom domains",
27
+ "notFound": "There are no custom domains to show.",
28
+ "placeholder": "help.neeto.com",
29
+ "cname": "CNAME",
30
+ "label": "Enter domain",
31
+ "domainValidation": "Domain validation",
32
+ "domainRedirection": "Domain redirection",
33
+ "cnameRecordInfo": "Go to your domain host's DNS settings to add the following CNAME record.{{proxyMessage, anyCase}} <Link>View help article</Link> for more information.",
34
+ "proxyMessage": " Do not enable proxy for the record.",
35
+ "domainRedirectionInfo": "It can take up to 2-24 hours for your custom domain to start working. Please visit your site in 24 hours from now and if after 24 hours <strong>{{hostname}}</strong> is not working then please view <Link>help article</Link> for more information and contact us.",
36
+ "domainValidationInfo": "CNAME record not found, if you added CNAME record in last 24 hours then please wait sometime and try it again. Verifying your domain usually only takes a few hours, but in some cases can take up to 24-48 hours. View <Link>help article</Link> for more information.",
37
+ "learnMoreMessage": "Learn about <button>how to setup custom domains</button>",
38
+ "cnameAdded": "I have added redirection CNAME record",
39
+ "validation": {
40
+ "successMessage": "Custom domain successfully validated.",
41
+ "buttonLabel": {
42
+ "domain": "Validate"
43
+ }
44
+ },
45
+ "status": {
46
+ "domain": {
47
+ "active": "Domain validated",
48
+ "pendingCnameValidation": "Domain validated",
49
+ "pendingDomainValidation": "Domain validation pending"
50
+ },
51
+ "cname": {
52
+ "active": "Domain redirected",
53
+ "pendingCnameValidation": "Domain redirection pending"
54
+ },
55
+ "failed": "Failed"
56
+ },
57
+ "alertMessage": "You are permanently deleting the custom domain <strong>{{hostname}}</strong> and will no longer point to your default domain. This can't be undone.",
58
+ "formikValidation": {
59
+ "required": "Domain is required",
60
+ "valid": "Please add valid domain or URL"
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,3 @@
1
+ import en from "./en.json";
2
+
3
+ export { en };