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