Compare commits

..

No commits in common. "cb90b79efe60cf6560b67b06fb485d13924faf76" and "ab8c9f6242f6996afe837a5c05ed7f299e45c084" have entirely different histories.

5 changed files with 14 additions and 36 deletions

View file

@ -12,12 +12,7 @@ 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: { include: {swf_assets: {include: [:zone], methods: [:image_url]}},
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],
) )
} }

View file

@ -73,9 +73,10 @@ 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!
svgUrl: swfAssetData.html5_svg_url, // TODO: For example, these do generally have SVGs, we could use them!
svgUrl: null,
canvasMovieLibraryUrl: null, canvasMovieLibraryUrl: null,
imageUrl: swfAssetData.html5_image_url, imageUrl: swfAssetData.image_url,
swfUrl: swfAssetData.url, swfUrl: swfAssetData.url,
}; };
} }

View file

@ -34,11 +34,19 @@ 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?
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 end
def biology=(biology) def biology=(biology)

View file

@ -169,6 +169,7 @@ 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

View file

@ -110,33 +110,6 @@ 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