diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index b42ccb06..21ad67ab 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -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" diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index 65def838..ed8e6d02 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index b528d755..484e3a66 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/app/views/admin/conferences/attach_custom_domain.html.haml b/app/views/admin/conferences/attach_custom_domain.html.haml index 42d91bbc..9b389c80 100644 --- a/app/views/admin/conferences/attach_custom_domain.html.haml +++ b/app/views/admin/conferences/attach_custom_domain.html.haml @@ -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 registrar’s 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 doesn’t, 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' diff --git a/app/views/admin/conferences/custom_domain.html.haml b/app/views/admin/conferences/custom_domain.html.haml index 17316550..55aa4782 100644 --- a/app/views/admin/conferences/custom_domain.html.haml +++ b/app/views/admin/conferences/custom_domain.html.haml @@ -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 registrar’s 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 doesn’t, 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'