====== Custom Domain for Sites ====== ===== Requirement ===== Initially all learning sites will have a Website Address that is based on a learnexa.com domain. When a user wants to have his custom domain he can specify it in Domain Settings section in Manage Site and configure it. **Note:** Untill the custom domain is configured the site will be accessible only using the Website Address which is based on learnexa.com (eg. foobar.learnexa.com) ===== Implementation ===== The custom domain specified in the Domain Settings section will get saved in a new column. If a site has custom domain then all system generated emails will contain the URL with custom domain address. ==== Flow ==== 1) A site can be created only with subdomain. (eg. something.learnexa.com) 2) When a user wants to have custom domain he can specify one in Domain settings section in manage site. The 'see instruction link' in this page will open a popup with the instructions on how to customize the domain address. 3) When a user specifies a custom domain a notification mail will be sent to the user and learnexa admin. A user can remove the custom domain by setting it as blank. If the user has removed his custom domain then a separate mail will be sent to learnexa admin. 4) From now on all the emails and url references contains the URL with custom domain to refer this site. But still users can use only the URL with subdomain even if the custom domain is specified, untill the custom domain is customized by the procedure in https://wiki.exphosted.com/doku.php/byodomain. ==== Code Changes ==== 1) Build the UI for Domain settings page. Add a new column //custom_domain// in companies table. 2) //find_current_account// method in //application_controller.rb// should be modified to find the site based on the subdomain for the sites which have custom domain specified. 3) //params_for_url_path//, //learning_site_url// and //uses_subdomain?// methods in //models/company.rb// should be modified to return custom domain url if custom domain is specified. ==== Database Changes ==== Add column custom_domain to table - companies ^ Column_name ^type ^ Description ^ | custom_domain | String | The own domain which is specified in the custom domain address field under Domain settings section in manage site | ==== Existing data fixes ==== For sites with out subdomain_flag move data from subdomain column to custom_domain column and from generated_subdomain column to subdomain column in companies table. ==== Notification Changes ==== These notifications are sent only in production. [[documents#NOTIFICATION TO LEARNEXA ADMIN ON CUSTOM HOST REQUEST FOR A SITE |NOTIFICATION TO LEARNEXA ADMIN ON CUSTOM HOST REQUEST FOR A SITE]]\\ [[documents#NOTIFICATION TO LEARNEXA ADMIN ON CUSTOM HOST DELETION |NOTIFICATION TO LEARNEXA ADMIN ON CUSTOM HOST DELETION]]