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:
parent
4bf8548dc5
commit
18de62b015
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue