diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f323a6caa..9413c7220 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -369,4 +369,9 @@ def authenticate_user!(_fav = nil, **_opts) end end end + + # Whether this host is on the codidact network + def codidact? + helpers.codidact? + end end diff --git a/app/helpers/codidact_helper.rb b/app/helpers/codidact_helper.rb new file mode 100644 index 000000000..71e2567a7 --- /dev/null +++ b/app/helpers/codidact_helper.rb @@ -0,0 +1,11 @@ +# Provides helper methods to determine whether this site is part of the codidact network +module CodidactHelper + # Whether this server is part of the codidact network. + def codidact? + Rails.cache.fetch 'is_codidact' do + Rails.env.development? || + RequestContext.community.host.end_with?('.codidact.com') || + RequestContext.community.host.end_with?('.codidact.org') + end + end +end diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb index 84617ad42..be518f93f 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.erb +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -1,4 +1,8 @@ -

Welcome to Codidact, <%= @resource.username %>! We're glad you're here.

+<% if codidact? %> +

Welcome to Codidact, <%= @resource.username %>! We're glad you're here.

+<% else %> +

Welcome, <%= @resource.username %>! We're glad you're here.

+<% end %>

Please confirm your registration by clicking below (or copy and paste the URL into your browser).

diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 8fc1a62a7..5830af0d9 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -7,10 +7,12 @@ <% end %> -
- If you have an account on another Codidact site, - don't create a new account here - <%= link_to 'sign in', new_user_session_path %> with your existing details instead. -
+<% if codidact? %> +
+ If you have an account on another Codidact site, + don't create a new account here - <%= link_to 'sign in', new_user_session_path %> with your existing details instead. +
+<% end %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb index b98194a30..1ff668ff2 100644 --- a/app/views/errors/internal_server_error.html.erb +++ b/app/views/errors/internal_server_error.html.erb @@ -12,11 +12,13 @@

This error has been logged. We even look at them sometimes.

-

- You can also report this - on Meta - to help us keep track of what's going wrong — quote error ID <%= @log.uuid %>. -

+<% if codidact? %> +

+ You can also report this + on Meta + to help us keep track of what's going wrong — quote error ID <%= @log.uuid %>. +

+<% end %>

<%= link_to 'Go back', :back, class: 'button is-outlined' %> diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb index ab5ed403e..8230ceae3 100644 --- a/app/views/errors/unprocessable_entity.html.erb +++ b/app/views/errors/unprocessable_entity.html.erb @@ -5,11 +5,16 @@

Your request couldn't be processed.

-

- Our server's sulking today. Log out and back in, and if this keeps happening, let us know - on Meta. -

- +<% if codidact? %> +

+ Our server's sulking today. Log out and back in, and if this keeps happening, let us know + on Meta. +

+<% else %> +

+ Our server's sulking today. Log out and back in, and if this keeps happening, let us know. +

+<% end %>

<%= link_to 'Go back', :back, class: 'button is-outlined' %> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index b00c2c03f..77611978c 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -7,19 +7,23 @@

  • <%= link_to 'Terms of Service', '/policy/tos' %>
  • <%= link_to 'Privacy Policy', '/policy/privacy-policy' %>
  • <%= link_to 'Code of Conduct', '/policy/code-of-conduct' %>
  • -
  • <%= link_to 'About us', 'https://codidact.org/' %>
  • -
  • <%= link_to 'Contact us', 'https://codidact.com/contact' %>
  • -
  • <%= link_to 'Other communities', 'https://codidact.com/' %>
  • - - -
    -

    Other Codidact Communities

    -
    + <% if codidact? %> +
    +

    Other Codidact Communities

    + +
    + <% end %> <% commit = Rails.cache.persistent('current_commit') %>

    diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index c9bf20abd..a50b373c8 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -1,7 +1,10 @@ -<% desc = "#{SiteSetting['SiteName']} on Codidact - open, community-run Q&A knowledge sharing" %> +<% desc = codidact? ? + "#{SiteSetting['SiteName']} on Codidact - open, community-run Q&A knowledge sharing" : + "#{SiteSetting['SiteName']} - Q&A knowledge sharing" +%> <% page_title = (Rails.env.development? ? '[DEV] ' : '') + @@ -14,7 +17,7 @@ <% icon_path = SiteSetting['IconPath'] %> + title="<%= "#{codidact? ? 'Codidact ' : ''}#{RequestContext.community.name}" %> search" href="<%= osd_url(format: :xml) %>" /> diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 33a713a42..78c6a724c 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -106,14 +106,20 @@

    - + <% if codidact? %> + + <% else %> + + <% end %>
    <% chat = SiteSetting['ChatLink'] %> -

    - This community is part of the Codidact network. - We have other communities too — take a look! -

    + <% if codidact? %> +

    + This community is part of the Codidact network. + We have other communities too — take a look! +

    + <% end %> <% if chat.present? %>

    You can also <%= link_to 'join us in chat', chat %>! diff --git a/app/views/layouts/devise_mailer.html.erb b/app/views/layouts/devise_mailer.html.erb index b3a260e52..f8dc724c8 100644 --- a/app/views/layouts/devise_mailer.html.erb +++ b/app/views/layouts/devise_mailer.html.erb @@ -10,8 +10,8 @@

    <%= link_to root_url, class: 'header--site-name' do %> - <%= image_tag asset_path('codidact.png', host: 'meta.codidact.com', protocol: 'https'), height: 40, width: 167, - alt: 'Codidact logo' %> + <%= image_tag "https://#{RequestContext.community.host}#{SiteSetting['SiteLogoPath']}", height: 40, width: 167, + alt: "#{SiteSetting['SiteName']} logo" %> <% end %>
    diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index bdf01890b..2ed1303ef 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -10,8 +10,8 @@
    <%= link_to root_url, class: 'header--site-name' do %> - <%= image_tag asset_path('codidact.png', host: 'meta.codidact.com', protocol: 'https'), height: 40, width: 167, - alt: 'Codidact logo' %> + <%= image_tag "https://#{RequestContext.community.host}#{SiteSetting['SiteLogoPath']}", height: 40, width: 167, + alt: "#{SiteSetting['SiteName']} logo" %> <% end %>