mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
ac896755bb
Previously, the app HTML served by the Ember-CLI proxy was generated based on a 'bootstrap json' payload generated by Rails. This inevitably leads to differences between the Rails HTML and the Ember-CLI HTML. This commit overhauls our proxying strategy. Now, we totally ignore the ember-cli `index.html` file. Instead, we take the full HTML from Rails and surgically replace script URLs based on a `data-discourse-entrypoint` attribute. This should be faster (only one request to Rails), more robust, and less confusing for developers.
23 lines
655 B
Ruby
23 lines
655 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BootstrapController < ApplicationController
|
|
skip_before_action :redirect_to_login_if_required, :check_xhr
|
|
|
|
def plugin_css_for_tests
|
|
urls =
|
|
Discourse
|
|
.find_plugin_css_assets(include_disabled: true, desktop_view: true)
|
|
.map do |target|
|
|
details = Stylesheet::Manager.new().stylesheet_details(target, "all")
|
|
details[0][:new_href]
|
|
end
|
|
|
|
stylesheet = <<~CSS
|
|
/* For use in tests only - `@import`s all plugin stylesheets */
|
|
#{urls.map { |url| "@import \"#{url}\";" }.join("\n")}
|
|
CSS
|
|
|
|
render plain: stylesheet, content_type: "text/css"
|
|
end
|
|
end
|