Compare commits

..

No commits in common. "1e9937644991e59c284eda1d0107b4ba72703828" and "72c739ca0fc2a41cf14dfa1e24e8cd08029705c7" have entirely different histories.

3 changed files with 13 additions and 36 deletions

View file

@ -1,5 +1,3 @@
require "addressable/template"
class AltStyle < ApplicationRecord class AltStyle < ApplicationRecord
belongs_to :species belongs_to :species
belongs_to :color belongs_to :color
@ -8,10 +6,6 @@ class AltStyle < ApplicationRecord
has_many :swf_assets, through: :parent_swf_asset_relationships has_many :swf_assets, through: :parent_swf_asset_relationships
has_many :contributions, as: :contributed, inverse_of: :contributed has_many :contributions, as: :contributed, inverse_of: :contributed
validates :body_id, presence: true
before_create :infer_series_name
scope :matching_name, ->(series_name, color_name, species_name) { scope :matching_name, ->(series_name, color_name, species_name) {
color = Color.find_by_name!(color_name) color = Color.find_by_name!(color_name)
species = Species.find_by_name!(species_name) species = Species.find_by_name!(species_name)
@ -41,20 +35,11 @@ class AltStyle < ApplicationRecord
"#{series_name} #{color.human_name}" "#{series_name} #{color.human_name}"
end end
THUMBNAIL_URL_TEMPLATE = Addressable::Template.new(
"https://images.neopets.com/items/{series}_{color}_{species}.gif"
)
DEFAULT_THUMBNAIL_URL = "https://images.neopets.com/items/mall_bg_circle.gif"
def thumbnail_url def thumbnail_url
return DEFAULT_THUMBNAIL_URL unless has_real_series_name? # HACK: Just assume this is a Nostalgic Alt Style, and that the thumbnail
# is named reliably!
# HACK: We're assuming this is the format long-term! But if it changes, we "https://images.neopets.com/items/nostalgic_" +
# may need to add it as a database field instead. "#{color.name.gsub(/\s+/, '').downcase}_#{species.name.downcase}.gif"
THUMBNAIL_URL_TEMPLATE.expand(
series: series_name.gsub(/\s+/, '').downcase,
color: color.name.gsub(/\s+/, '').downcase,
species: species.name.gsub(/\s+/, '').downcase,
).to_s
end end
def preview_image_url def preview_image_url
@ -78,19 +63,6 @@ class AltStyle < ApplicationRecord
end end
end end
# Until the end of 2024, assume new alt styles are from the "Nostalgic"
# series. That way, we can stop having to manually label them all as they
# come out and get modeled (TNT is prolific rn!), but we aren't gonna get too
# greedy and forget about this and use Nostalgic for some far-future thing,
# in ways that will certainly be fixable but would also be confusing and
# embarrassing.
NOSTALGIC_FINAL_DAY = Date.new(2024, 12, 31)
def infer_series_name
if !has_real_series_name? && Date.today <= NOSTALGIC_FINAL_DAY
self.series_name = "Nostalgic"
end
end
# For convenience in the console! # For convenience in the console!
def self.find_by_name(color_name, species_name) def self.find_by_name(color_name, species_name)
color = Color.find_by_name(color_name) color = Color.find_by_name(color_name)

View file

@ -338,7 +338,7 @@ class SwfAsset < ApplicationRecord
end end
SwfAsset.transaction do SwfAsset.transaction do
swf_assets.select(&:changed?).each(&:save!) swf_assets.each(&:save!)
end end
end end

View file

@ -9,9 +9,14 @@
name on the homepage! Thank you! 💖 name on the homepage! Thank you! 💖
%p %p
Also, heads-up: Because our system can only collect "item data" for normal Also, heads-up: Style tokens are pretty different from normal wearables, so
wearable items, there's not a great way for us to get style tokens onto we haven't decided how to bring them into the customizer yet! Whatever we do,
tradelists… this may change someday, but probably not soon, sorry! it'll be a bit tricky and new 😅❗️
%p
Also, second heads-up: Because our system can only collect "item data" for
normal wearable items, there's not a great way for us to get style tokens
onto tradelists… this may change someday, but probably not soon, sorry!
- @alt_styles.group_by(&:species).each do |species, species_styles| - @alt_styles.group_by(&:species).each do |species, species_styles|
%h2.alt-styles-header= species.human_name %h2.alt-styles-header= species.human_name