2017-04-12 10:52:52 -04:00
|
|
|
class ThemesController < ::ApplicationController
|
|
|
|
def assets
|
2018-08-08 00:46:34 -04:00
|
|
|
theme_ids = params[:ids].to_s.split("-").map(&:to_i)
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2018-08-08 00:46:34 -04:00
|
|
|
if params[:ids] == "default"
|
|
|
|
theme_ids = nil
|
2017-04-12 10:52:52 -04:00
|
|
|
else
|
2018-08-08 00:46:34 -04:00
|
|
|
raise Discourse::NotFound unless guardian.allow_themes?(theme_ids)
|
2017-04-12 10:52:52 -04:00
|
|
|
end
|
|
|
|
|
2018-08-08 00:46:34 -04:00
|
|
|
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|
|
2018-08-08 03:58:45 -04:00
|
|
|
next hash unless Rails.env.development?
|
2018-08-08 00:46:34 -04:00
|
|
|
|
|
|
|
dup_hash = hash.dup
|
|
|
|
dup_hash[:new_href] << (dup_hash[:new_href].include?("?") ? "&" : "?")
|
|
|
|
dup_hash[:new_href] << SecureRandom.hex
|
|
|
|
dup_hash
|
2017-04-12 10:52:52 -04:00
|
|
|
end
|
2018-08-08 00:46:34 -04:00
|
|
|
end.flatten
|
2017-04-12 10:52:52 -04:00
|
|
|
|
|
|
|
render json: object.as_json
|
|
|
|
end
|
|
|
|
end
|