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.
This commit is contained in:
Pat David 2017-05-08 11:58:36 -05:00 committed by Robin Ward
parent 4bf8548dc5
commit 18de62b015
1 changed files with 7 additions and 0 deletions

View File

@ -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