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