2024-01-24 06:53:37 -08:00
|
|
|
class AltStylesController < ApplicationController
|
|
|
|
def index
|
|
|
|
@alt_styles = AltStyle.includes(:species, :color, :swf_assets).
|
2024-01-28 07:30:06 -08:00
|
|
|
order(:species_id, :color_id)
|
|
|
|
|
|
|
|
if params[:species_id]
|
|
|
|
@species = Species.find(params[:species_id])
|
|
|
|
@alt_styles = @alt_styles.merge(@species.alt_styles)
|
|
|
|
end
|
|
|
|
|
2024-02-23 13:45:12 -08:00
|
|
|
# We're going to link to the HTML5 image URL, so make sure we have all the
|
|
|
|
# manifests ready!
|
|
|
|
SwfAsset.preload_manifests @alt_styles.map(&:swf_assets).flatten
|
|
|
|
|
2024-01-28 07:30:06 -08:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { render }
|
2024-01-29 03:20:48 -08:00
|
|
|
format.json {
|
2024-01-30 07:01:03 -08:00
|
|
|
render json: @alt_styles.includes(swf_assets: [:zone]).as_json(
|
2024-02-24 16:25:55 -08:00
|
|
|
only: [:id, :species_id, :color_id, :body_id, :series_name,
|
|
|
|
:adjective_name, :thumbnail_url],
|
2024-01-31 03:02:19 -08:00
|
|
|
include: {
|
|
|
|
swf_assets: {
|
2024-02-24 16:25:55 -08:00
|
|
|
only: [:id, :body_id],
|
2024-01-31 03:02:19 -08:00
|
|
|
include: [:zone],
|
2024-02-24 16:31:05 -08:00
|
|
|
methods: [:urls, :known_glitches],
|
2024-01-31 03:02:19 -08:00
|
|
|
}
|
|
|
|
},
|
2024-01-30 05:54:20 -08:00
|
|
|
methods: [:series_name, :adjective_name, :thumbnail_url],
|
2024-01-29 03:20:48 -08:00
|
|
|
)
|
|
|
|
}
|
2024-01-28 07:30:06 -08:00
|
|
|
end
|
2024-01-24 06:53:37 -08:00
|
|
|
end
|
|
|
|
end
|