From 18de62b015ea2fcda543111b75cd6453c66378f0 Mon Sep 17 00:00:00 2001
From: Pat David <patdavid@gmail.com>
Date: Mon, 8 May 2017 11:58:36 -0500
Subject: [PATCH] Add get_embeddable_css_class to assist multi-site embed
 styling

If present, pass embeddable_host.class_name to view for inclusion
on the <html> element as a class for targeted styling.
---
 app/controllers/embed_controller.rb | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb
index 9407f847f20..f64cc8035c7 100644
--- a/app/controllers/embed_controller.rb
+++ b/app/controllers/embed_controller.rb
@@ -2,6 +2,7 @@ class EmbedController < ApplicationController
   skip_before_filter :check_xhr, :preload_json, :verify_authenticity_token
 
   before_filter :ensure_embeddable, except: [ :info ]
+  before_filter :get_embeddable_css_class, except: [ :info ]
   before_filter :ensure_api_request, only: [ :info ]
 
   layout 'embed'
@@ -92,6 +93,12 @@ class EmbedController < ApplicationController
 
   private
 
+    def get_embeddable_css_class
+      @embeddable_css_class = ""
+      embeddable_host = EmbeddableHost.record_for_url(request.referer)
+      @embeddable_css_class = " class=\"#{embeddable_host.class_name}\"" if embeddable_host.present? and embeddable_host.class_name.present?
+    end
+
     def ensure_api_request
       raise Discourse::InvalidAccess.new('api key not set') if !is_api?
     end