introduced ability to auto detect CNAME of custom domain

This commit is contained in:
shlok007 2017-08-08 22:47:04 +05:30
parent a612c2e5ea
commit b1624a6812
5 changed files with 41 additions and 8 deletions

View file

@ -31,6 +31,8 @@ linters:
- "app/views/admin/conferences/_targets.html.haml"
- "app/views/admin/conferences/_todo_list.html.haml"
- "app/views/admin/conferences/_top_submitter.html.haml"
- "app/views/admin/conferences/attach_custom_domain.html.haml"
- "app/views/admin/conferences/custom_domain.html.haml"
- "app/views/admin/conferences/edit.html.haml"
- "app/views/admin/conferences/index.html.haml"
- "app/views/admin/conferences/new.html.haml"

View file

@ -4,7 +4,9 @@ module Admin
load_resource :program, through: :conference, singleton: true, except: :index
load_resource :user, only: [:remove_user]
def custom_domain; end
def custom_domain
redirect_to attach_custom_domain_admin_conference_path(@conference.short_title) unless @conference.custom_domain.present?
end
def attach_custom_domain; end

View file

@ -92,6 +92,28 @@ class Conference < ActiveRecord::Base
user.present? && registrations.where(user_id: user.id).count > 0
end
##
# Checks if domain correctly points to the hosted version
# This feature is enabled only if ENV['OSEM_HOSTNAME'] is present
#
# ====Returns
# * +true+ -> If the custom domain has a CNAME record for the hosted version
# * +false+ -> If the custom domain does not have a CNAME record for the hosted version
def check_custom_domain
require 'resolv'
unless ENV['OSEM_HOSTNAME'].nil?
cname_record = Resolv::DNS.new.getresources(custom_domain, Resolv::DNS::Resource::IN::CNAME)
if cname_record.present?
return ENV['OSEM_HOSTNAME'] == Resolv::DNS.new.getresources(custom_domain, Resolv::DNS::Resource::IN::CNAME).first.name.to_s
else
return false
end
end
'--feature disabled--'
end
##
# Delete all EventSchedules that are not in the hours range
# After the conference has been successfully updated

View file

@ -23,13 +23,13 @@
%h2
Step 3:
%strong
Unfortunately, we can't do this for you and you have to perform this step with the help your domain registrar!
Unfortunately, we can't do this for you and you have to perform this step with the help your domain registrar!
%p
The last step is adding a CNAME record in your registrars DNS Settings. Different registrars have different ways of adding a CNAME record. The following guides would help you setup a CNAME record depending upon the registrar of your domain. If it doesnt, you probably should get in touch with your domain registrar and ask him how to register a CNAME record in their platform.
%ul
%li
%li
= link_to 'GoDaddy', 'https://in.godaddy.com/help/add-a-cname-record-19236'
%li
%li
= link_to 'Namecheap', 'https://www.namecheap.com/support/knowledgebase/article.aspx/9646/2237/how-can-i-set-up-a-cname-record-for-my-domain'
%li
= link_to 'BlueHost', 'https://my.bluehost.com/cgi/help/cname#creating_a_cname'

View file

@ -17,7 +17,14 @@
%td
= @conference.custom_domain
%td
= ""
- ck_domain = @conference.check_custom_domain
- if ck_domain == true
%span.glyphicon.glyphicon-ok
- elsif ck_domain == false
%span.glyphicon.glyphicon-remove
- else
%i
= ck_domain
%td
.btn-group
= link_to 'Edit', attach_custom_domain_admin_conference_path(@conference.short_title),
@ -51,7 +58,7 @@
CNAME:
A Canonical Name record is a resource used which defines that your domain name is an alias for another domain name.
%p
To add your own domain you can follow these
To add your own domain you can follow these
%i
three
steps:
@ -63,9 +70,9 @@
%li
The last step is adding a CNAME record in your registrars DNS Settings. Different registrars have different ways of adding a CNAME record. The following guides would help you setup a CNAME record depending upon the registrar of your domain. If it doesnt, you probably should get in touch with your domain registrar and ask him how to register a CNAME record in their platform.
%ul
%li
%li
= link_to 'GoDaddy', 'https://in.godaddy.com/help/add-a-cname-record-19236'
%li
%li
= link_to 'Namecheap', 'https://www.namecheap.com/support/knowledgebase/article.aspx/9646/2237/how-can-i-set-up-a-cname-record-for-my-domain'
%li
= link_to 'BlueHost', 'https://my.bluehost.com/cgi/help/cname#creating_a_cname'