Compare commits
No commits in common. "cb90b79efe60cf6560b67b06fb485d13924faf76" and "ab8c9f6242f6996afe837a5c05ed7f299e45c084" have entirely different histories.
cb90b79efe
...
ab8c9f6242
5 changed files with 14 additions and 36 deletions
|
@ -12,12 +12,7 @@ class AltStylesController < ApplicationController
|
|||
format.html { render }
|
||||
format.json {
|
||||
render json: @alt_styles.includes(swf_assets: [:zone]).as_json(
|
||||
include: {
|
||||
swf_assets: {
|
||||
include: [:zone],
|
||||
methods: [:html5_image_url, :html5_svg_url],
|
||||
}
|
||||
},
|
||||
include: {swf_assets: {include: [:zone], methods: [:image_url]}},
|
||||
methods: [:series_name, :adjective_name, :thumbnail_url],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -73,9 +73,10 @@ function normalizeSwfAssetToLayer(swfAssetData) {
|
|||
|
||||
// HACK: We're just simplifying this adapter, but it would be better to
|
||||
// actually check what file formats the manifest says!
|
||||
svgUrl: swfAssetData.html5_svg_url,
|
||||
// TODO: For example, these do generally have SVGs, we could use them!
|
||||
svgUrl: null,
|
||||
canvasMovieLibraryUrl: null,
|
||||
imageUrl: swfAssetData.html5_image_url,
|
||||
imageUrl: swfAssetData.image_url,
|
||||
swfUrl: swfAssetData.url,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -34,11 +34,19 @@ class AltStyle < ApplicationRecord
|
|||
"#{color.name.gsub(/\s+/, '').downcase}_#{species.name.downcase}.gif"
|
||||
end
|
||||
|
||||
MANIFEST_PATTERN = %r{^https://images.neopets.com/(?<prefix>.+)/(?<id>[0-9]+)(?<hash_part>_[^/]+)?/manifest\.json}
|
||||
def preview_image_url
|
||||
swf_asset = swf_assets.first
|
||||
return nil if swf_asset.nil?
|
||||
|
||||
swf_asset.html5_image_url
|
||||
# HACK: Just assuming all of these were well-formed by the same process,
|
||||
# and infer the image URL from the manifest URL! But strictly speaking we
|
||||
# should be reading the manifest to check!
|
||||
match = swf_asset.manifest_url.match(MANIFEST_PATTERN)
|
||||
return nil if match.nil?
|
||||
|
||||
"https://images.neopets.com/#{match[:prefix]}/" +
|
||||
"#{match[:id]}#{match[:hash_part]}/#{match[:id]}.png"
|
||||
end
|
||||
|
||||
def biology=(biology)
|
||||
|
|
|
@ -169,6 +169,7 @@ class PetState < ApplicationRecord
|
|||
end
|
||||
end
|
||||
pet_state.parent_swf_asset_relationships_to_update = relationships
|
||||
pet_state.unconverted = (relationships.size == 1)
|
||||
pet_state
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,33 +110,6 @@ class SwfAsset < ApplicationRecord
|
|||
}
|
||||
end
|
||||
|
||||
MANIFEST_PATTERN = %r{^https://images.neopets.com/(?<prefix>.+)/(?<id>[0-9]+)(?<hash_part>_[^/]+)?/manifest\.json}
|
||||
def html5_image_url
|
||||
return nil if manifest_url.nil?
|
||||
|
||||
# HACK: Just assuming all of these were well-formed by the same process,
|
||||
# and infer the image URL from the manifest URL! But strictly speaking we
|
||||
# should be reading the manifest to check!
|
||||
match = manifest_url.match(MANIFEST_PATTERN)
|
||||
return nil if match.nil?
|
||||
|
||||
"https://images.neopets.com/#{match[:prefix]}/" +
|
||||
"#{match[:id]}#{match[:hash_part]}/#{match[:id]}.png"
|
||||
end
|
||||
|
||||
def html5_svg_url
|
||||
return nil if manifest_url.nil?
|
||||
|
||||
# HACK: Just assuming all of these were well-formed by the same process,
|
||||
# and infer the image URL from the manifest URL! But strictly speaking we
|
||||
# should be reading the manifest to check!
|
||||
match = manifest_url.match(MANIFEST_PATTERN)
|
||||
return nil if match.nil?
|
||||
|
||||
"https://images.neopets.com/#{match[:prefix]}/" +
|
||||
"#{match[:id]}#{match[:hash_part]}/#{match[:id]}.svg"
|
||||
end
|
||||
|
||||
def known_glitches
|
||||
self[:known_glitches].split(',')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue