diff --git a/app/assets/javascripts/discourse/views/html_view.js b/app/assets/javascripts/discourse/views/html_view.js index d399095611b..8728a80b016 100644 --- a/app/assets/javascripts/discourse/views/html_view.js +++ b/app/assets/javascripts/discourse/views/html_view.js @@ -2,13 +2,10 @@ Discourse.HtmlView = Ember.View.extend({ render: function(buffer) { var key = this.get("key"), - noscript = $("noscript").text(); + htmlContent = PreloadStore.get("htmlContent"); - if (noscript.length) { - var regexp = new RegExp("((?:.|[\\n\\r])*)"), - content = noscript.match(regexp)[1]; - - buffer.push(content); + if (htmlContent && htmlContent[key] && htmlContent[key].length) { + buffer.push(htmlContent[key]); } } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3702835e3b8..376772391c8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -191,6 +191,7 @@ class ApplicationController < ActionController::Base def preload_anonymous_data store_preloaded("site", Site.cached_json(guardian)) store_preloaded("siteSettings", SiteSetting.client_settings_json) + store_preloaded("htmlContent", html_content_json) end def preload_current_user_data @@ -199,6 +200,13 @@ class ApplicationController < ActionController::Base store_preloaded("topicTrackingStates", MultiJson.dump(serializer)) end + def html_content_json + MultiJson.dump({ + top: SiteContent.content_for(:top), + bottom: SiteContent.content_for(:bottom), + }) + end + def render_json_error(obj) if obj.present? render json: MultiJson.dump(errors: obj.errors.full_messages), status: 422 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8a5ec44bb55..94770605c90 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -87,17 +87,11 @@ - - <%= raw SiteContent.content_for(:top) %> -