mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
0b7ed8ffaf
* FEATURE: backend support for user-selectable components * fix problems with previewing default theme * rename preview_key => preview_theme_id * omit default theme from child themes dropdown and try a different fix * cache & freeze stylesheets arrays
28 lines
811 B
Ruby
28 lines
811 B
Ruby
class ThemesController < ::ApplicationController
|
|
def assets
|
|
theme_ids = params[:ids].to_s.split("-").map(&:to_i)
|
|
|
|
if params[:ids] == "default"
|
|
theme_ids = nil
|
|
else
|
|
raise Discourse::NotFound unless guardian.allow_themes?(theme_ids)
|
|
end
|
|
|
|
targets = view_context.mobile_view? ? [:mobile, :mobile_theme] : [:desktop, :desktop_theme]
|
|
targets << :admin if guardian.is_staff?
|
|
|
|
object = targets.map do |target|
|
|
Stylesheet::Manager.stylesheet_data(target, theme_ids).map do |hash|
|
|
return hash unless Rails.env.development?
|
|
|
|
dup_hash = hash.dup
|
|
dup_hash[:new_href] << (dup_hash[:new_href].include?("?") ? "&" : "?")
|
|
dup_hash[:new_href] << SecureRandom.hex
|
|
dup_hash
|
|
end
|
|
end.flatten
|
|
|
|
render json: object.as_json
|
|
end
|
|
end
|