FEATURE: support registration of custom html by plugins
This commit is contained in:
parent
8ec9288a5c
commit
f1a28d62a3
3 changed files with 18 additions and 4 deletions
|
@ -243,12 +243,20 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_html_json
|
def custom_html_json
|
||||||
MultiJson.dump({
|
data = {
|
||||||
top: SiteContent.content_for(:top),
|
top: SiteContent.content_for(:top),
|
||||||
bottom: SiteContent.content_for(:bottom)
|
bottom: SiteContent.content_for(:bottom)
|
||||||
}.merge(
|
}
|
||||||
(SiteSetting.tos_accept_required && !current_user) ? {tos_signup_form_message: SiteContent.content_for(:tos_signup_form_message)} : {}
|
|
||||||
))
|
if SiteSetting.tos_accept_required && !current_user
|
||||||
|
data[:tos_signup_form_message] = SiteContent.content_for(:tos_signup_form_message)
|
||||||
|
end
|
||||||
|
|
||||||
|
if DiscoursePluginRegistry.custom_html
|
||||||
|
data.merge! DiscoursePluginRegistry.custom_html
|
||||||
|
end
|
||||||
|
|
||||||
|
MultiJson.dump(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_json_error(obj)
|
def render_json_error(obj)
|
||||||
|
|
|
@ -12,6 +12,7 @@ class DiscoursePluginRegistry
|
||||||
attr_accessor :desktop_stylesheets
|
attr_accessor :desktop_stylesheets
|
||||||
attr_accessor :sass_variables
|
attr_accessor :sass_variables
|
||||||
attr_accessor :handlebars
|
attr_accessor :handlebars
|
||||||
|
attr_accessor :custom_html
|
||||||
|
|
||||||
# Default accessor values
|
# Default accessor values
|
||||||
def javascripts
|
def javascripts
|
||||||
|
|
|
@ -108,6 +108,11 @@ class Plugin::Instance
|
||||||
@javascripts << js
|
@javascripts << js
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def register_custom_html(hash)
|
||||||
|
DiscoursePluginRegistry.custom_html ||= {}
|
||||||
|
DiscoursePluginRegistry.custom_html.merge!(hash)
|
||||||
|
end
|
||||||
|
|
||||||
def register_asset(file, opts=nil)
|
def register_asset(file, opts=nil)
|
||||||
full_path = File.dirname(path) << "/assets/" << file
|
full_path = File.dirname(path) << "/assets/" << file
|
||||||
assets << [full_path, opts]
|
assets << [full_path, opts]
|
||||||
|
|
Reference in a new issue