Compare commits
No commits in common. "ab572b6576f59621b58d31a51b9a936b1575beae" and "2b8fe68387982aff0fa60bb5a6cf60f4db209a24" have entirely different histories.
ab572b6576
...
2b8fe68387
11 changed files with 28 additions and 65 deletions
|
|
@ -1 +1 @@
|
||||||
3.3.6
|
3.3.5
|
||||||
|
|
|
||||||
2
Gemfile
2
Gemfile
|
|
@ -1,5 +1,5 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
ruby '3.3.6'
|
ruby '3.3.5'
|
||||||
|
|
||||||
gem 'rails', '~> 7.2', '>= 7.2.1'
|
gem 'rails', '~> 7.2', '>= 7.2.1'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -565,7 +565,7 @@ DEPENDENCIES
|
||||||
will_paginate (~> 4.0)
|
will_paginate (~> 4.0)
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 3.3.6p108
|
ruby 3.3.5p100
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.5.18
|
2.5.18
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
class MagicMagnifier extends HTMLElement {
|
class MagicMagnifier extends HTMLElement {
|
||||||
#internals = this.attachInternals();
|
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
setTimeout(() => this.#attachLens(), 0);
|
setTimeout(() => this.#attachLens(), 0);
|
||||||
this.addEventListener("mousemove", this.#onMouseMove);
|
this.addEventListener("mousemove", this.#onMouseMove);
|
||||||
|
|
@ -20,7 +18,6 @@ class MagicMagnifier extends HTMLElement {
|
||||||
const y = e.clientY - rect.top;
|
const y = e.clientY - rect.top;
|
||||||
this.style.setProperty("--magic-magnifier-x", x + "px");
|
this.style.setProperty("--magic-magnifier-x", x + "px");
|
||||||
this.style.setProperty("--magic-magnifier-y", y + "px");
|
this.style.setProperty("--magic-magnifier-y", y + "px");
|
||||||
this.#internals.states.add("ready");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
magic-magnifier
|
magic-magnifier
|
||||||
display: block
|
|
||||||
position: relative
|
position: relative
|
||||||
|
|
||||||
// Only show the lens when we are hovering, and the magnifier's X and Y
|
// Only show the lens when we are hovering, and the magnifier's X and Y
|
||||||
|
|
@ -8,14 +7,12 @@ magic-magnifier
|
||||||
magic-magnifier-lens
|
magic-magnifier-lens
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
// TODO: Once container query support is broader, we can remove the CSS state
|
&:hover
|
||||||
// and read for the presence of the X and Y custom properties instead.
|
@container style(--magic-magnifier-x) and style(--magic-magnifier-y)
|
||||||
&:hover:state(ready)
|
|
||||||
magic-magnifier-lens
|
magic-magnifier-lens
|
||||||
display: block
|
display: block
|
||||||
|
|
||||||
magic-magnifier-lens
|
magic-magnifier-lens
|
||||||
display: block
|
|
||||||
width: var(--magic-magnifier-lens-width, 100px)
|
width: var(--magic-magnifier-lens-width, 100px)
|
||||||
height: var(--magic-magnifier-lens-height, 100px)
|
height: var(--magic-magnifier-lens-height, 100px)
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
|
|
|
||||||
|
|
@ -38,20 +38,8 @@ module Neopets::NCMall
|
||||||
uniq
|
uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_styles(species_id:, neologin:)
|
|
||||||
Sync do
|
|
||||||
tabs = [
|
|
||||||
Async { load_styles_tab(species_id:, neologin:, tab: 1) },
|
|
||||||
Async { load_styles_tab(species_id:, neologin:, tab: 2) },
|
|
||||||
]
|
|
||||||
tabs.map(&:wait).flatten(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
STYLING_STUDIO_URL = "https://www.neopets.com/np-templates/ajax/stylingstudio/studio.php"
|
STYLING_STUDIO_URL = "https://www.neopets.com/np-templates/ajax/stylingstudio/studio.php"
|
||||||
def self.load_styles_tab(species_id:, neologin:, tab:)
|
def self.load_styles(species_id:, neologin:)
|
||||||
Sync do
|
Sync do
|
||||||
DTIRequests.post(
|
DTIRequests.post(
|
||||||
STYLING_STUDIO_URL,
|
STYLING_STUDIO_URL,
|
||||||
|
|
@ -60,7 +48,7 @@ module Neopets::NCMall
|
||||||
["Cookie", "neologin=#{neologin}"],
|
["Cookie", "neologin=#{neologin}"],
|
||||||
["X-Requested-With", "XMLHttpRequest"],
|
["X-Requested-With", "XMLHttpRequest"],
|
||||||
],
|
],
|
||||||
{tab:, mode: "getStyles", species: species_id}.to_query,
|
{tab: 1, mode: "getStyles", species: species_id}.to_query,
|
||||||
) do |response|
|
) do |response|
|
||||||
if response.status != 200
|
if response.status != 200
|
||||||
raise ResponseNotOK.new(response.status),
|
raise ResponseNotOK.new(response.status),
|
||||||
|
|
@ -72,8 +60,7 @@ module Neopets::NCMall
|
||||||
|
|
||||||
# HACK: styles is a hash, unless it's empty, in which case it's an
|
# HACK: styles is a hash, unless it's empty, in which case it's an
|
||||||
# array? Weird. Normalize this by converting to hash.
|
# array? Weird. Normalize this by converting to hash.
|
||||||
data.fetch(:styles).to_h.values.
|
data.fetch(:styles).to_h.values
|
||||||
map { |s| s.slice(:oii, :name, :image, :limited) }
|
|
||||||
rescue JSON::ParserError, KeyError
|
rescue JSON::ParserError, KeyError
|
||||||
raise UnexpectedResponseFormat
|
raise UnexpectedResponseFormat
|
||||||
end
|
end
|
||||||
|
|
@ -81,6 +68,8 @@ module Neopets::NCMall
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def self.load_page_by_url(url)
|
def self.load_page_by_url(url)
|
||||||
Sync do
|
Sync do
|
||||||
DTIRequests.get(url) do |response|
|
DTIRequests.get(url) do |response|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ OpenneoImpressItems::Application.routes.draw do
|
||||||
end
|
end
|
||||||
resources :swf_assets, path: 'swf-assets', only: [:show]
|
resources :swf_assets, path: 'swf-assets', only: [:show]
|
||||||
scope "rainbow-pool" do
|
scope "rainbow-pool" do
|
||||||
resources :alt_styles, path: 'styles', only: [:index, :edit, :update]
|
resources :alt_styles, path: 'alt-styles', only: [:index, :edit, :update],
|
||||||
|
path: 'styles'
|
||||||
end
|
end
|
||||||
resources :pet_types, path: 'rainbow-pool', param: "name",
|
resources :pet_types, path: 'rainbow-pool', param: "name",
|
||||||
only: [:index, :show] do
|
only: [:index, :show] do
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
vars:
|
vars:
|
||||||
local_app_root: "{{ playbook_dir }}/.."
|
local_app_root: "{{ playbook_dir }}/.."
|
||||||
remote_project_root: "/srv/impress"
|
remote_project_root: "/srv/impress"
|
||||||
ruby_version: "3.3.6"
|
ruby_version: "3.3.5"
|
||||||
|
|
||||||
# deploy:setup should have added us to the "impress-deployers" group, so we
|
# deploy:setup should have added us to the "impress-deployers" group, so we
|
||||||
# should be able to become the "impress" user without a password.
|
# should be able to become the "impress" user without a password.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
vars:
|
vars:
|
||||||
email_address: "emi@matchu.dev" # TODO: Extract this to personal config?
|
email_address: "emi@matchu.dev" # TODO: Extract this to personal config?
|
||||||
impress_hostname: impress.openneo.net
|
impress_hostname: impress.openneo.net
|
||||||
ruby_version: "3.3.6"
|
ruby_version: "3.3.5"
|
||||||
vars_files:
|
vars_files:
|
||||||
# mysql_root_password, mysql_user_password, mysql_user_password_2020,
|
# mysql_root_password, mysql_user_password, mysql_user_password_2020,
|
||||||
# dev_ips
|
# dev_ips
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
git:
|
git:
|
||||||
repo: https://github.com/rbenv/ruby-build.git
|
repo: https://github.com/rbenv/ruby-build.git
|
||||||
dest: /opt/ruby-build
|
dest: /opt/ruby-build
|
||||||
version: v20241225.2
|
version: v20240917
|
||||||
|
|
||||||
- name: Check if Ruby {{ ruby_version }} is already installed
|
- name: Check if Ruby {{ ruby_version }} is already installed
|
||||||
stat:
|
stat:
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace "neopets:import" do
|
||||||
record = style_records_by_id[style[:oii]]
|
record = style_records_by_id[style[:oii]]
|
||||||
label = "#{style[:name]} (#{style[:oii]})"
|
label = "#{style[:name]} (#{style[:oii]})"
|
||||||
if record.nil?
|
if record.nil?
|
||||||
puts "❔ [#{label}]: Not modeled yet, skipping"
|
puts "⚠️ [#{label}]: Not modeled yet, skipping"
|
||||||
counts[:skipped] += 1
|
counts[:skipped] += 1
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ require_relative '../rails_helper'
|
||||||
|
|
||||||
RSpec.describe Neopets::NCMall, type: :model do
|
RSpec.describe Neopets::NCMall, type: :model do
|
||||||
describe ".load_styles" do
|
describe ".load_styles" do
|
||||||
def stub_styles_request(tab:)
|
def stub_styles_request
|
||||||
stub_request(:post, "https://www.neopets.com/np-templates/ajax/stylingstudio/studio.php").
|
stub_request(:post, "https://www.neopets.com/np-templates/ajax/stylingstudio/studio.php").
|
||||||
with(
|
with(
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -12,15 +12,10 @@ RSpec.describe Neopets::NCMall, type: :model do
|
||||||
"Cookie": "neologin=STUB_NEOLOGIN",
|
"Cookie": "neologin=STUB_NEOLOGIN",
|
||||||
"User-Agent": Rails.configuration.user_agent_for_neopets,
|
"User-Agent": Rails.configuration.user_agent_for_neopets,
|
||||||
},
|
},
|
||||||
body: "mode=getStyles&species=2&tab=#{tab}",
|
body: "mode=getStyles&species=2&tab=1",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty_styles_response
|
|
||||||
# You'd think styles would be `{}` in this case, but it's `[]`. Huh!
|
|
||||||
{ body: '{"success":true,"styles":[]}' }
|
|
||||||
end
|
|
||||||
|
|
||||||
subject(:styles) do
|
subject(:styles) do
|
||||||
Neopets::NCMall.load_styles(
|
Neopets::NCMall.load_styles(
|
||||||
species_id: 2,
|
species_id: 2,
|
||||||
|
|
@ -29,12 +24,9 @@ RSpec.describe Neopets::NCMall, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "loads current NC styles from the NC Mall" do
|
it "loads current NC styles from the NC Mall" do
|
||||||
stub_styles_request(tab: 1).to_return(
|
stub_styles_request.to_return(
|
||||||
body: '{"success":true,"styles":{"87966":{"oii":87966,"name":"Nostalgic Alien Aisha","image":"https:\/\/images.neopets.com\/items\/nostalgic_alien_aisha.gif","limited":false},"87481":{"oii":87481,"name":"Nostalgic Sponge Aisha","image":"https:\/\/images.neopets.com\/items\/nostalgic_sponge_aisha.gif","limited":false},"90031":{"oii":90031,"name":"Celebratory Anniversary Aisha","image":"https:\/\/images.neopets.com\/items\/624dc08bcf.gif","limited":true},"90050":{"oii":90050,"name":"Nostalgic Tyrannian Aisha","image":"https:\/\/images.neopets.com\/items\/b225e06541.gif","limited":true}}}',
|
body: '{"success":true,"styles":{"87966":{"oii":87966,"name":"Nostalgic Alien Aisha","image":"https:\/\/images.neopets.com\/items\/nostalgic_alien_aisha.gif","limited":false},"87481":{"oii":87481,"name":"Nostalgic Sponge Aisha","image":"https:\/\/images.neopets.com\/items\/nostalgic_sponge_aisha.gif","limited":false},"90031":{"oii":90031,"name":"Celebratory Anniversary Aisha","image":"https:\/\/images.neopets.com\/items\/624dc08bcf.gif","limited":true},"90050":{"oii":90050,"name":"Nostalgic Tyrannian Aisha","image":"https:\/\/images.neopets.com\/items\/b225e06541.gif","limited":true}}}',
|
||||||
)
|
)
|
||||||
stub_styles_request(tab: 2).to_return(
|
|
||||||
body: '{"success":true,"styles":{"90338":{"oii":90338,"name":"Prismatic Pine: Christmas Aisha","image":"https:\/\/images.neopets.com\/items\/3m182ff5.gif","limited":true,"style":90252},"90348":{"oii":90348,"name":"Prismatic Tinsel: Christmas Aisha","image":"https:\/\/images.neopets.com\/items\/4j29mb91.gif","limited":true,"style":90252}}}'
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(styles).to contain_exactly(
|
expect(styles).to contain_exactly(
|
||||||
{
|
{
|
||||||
|
|
@ -60,50 +52,37 @@ RSpec.describe Neopets::NCMall, type: :model do
|
||||||
name: "Nostalgic Tyrannian Aisha",
|
name: "Nostalgic Tyrannian Aisha",
|
||||||
image: "https://images.neopets.com/items/b225e06541.gif",
|
image: "https://images.neopets.com/items/b225e06541.gif",
|
||||||
limited: true,
|
limited: true,
|
||||||
},
|
|
||||||
{
|
|
||||||
oii: 90338,
|
|
||||||
name: "Prismatic Pine: Christmas Aisha",
|
|
||||||
image: "https://images.neopets.com/items/3m182ff5.gif",
|
|
||||||
limited: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
oii: 90348,
|
|
||||||
name: "Prismatic Tinsel: Christmas Aisha",
|
|
||||||
image: "https://images.neopets.com/items/4j29mb91.gif",
|
|
||||||
limited: true,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles the NC Mall's odd API behavior for zero styles" do
|
it "handles the NC Mall's odd API behavior for zero styles" do
|
||||||
stub_styles_request(tab: 1).to_return(empty_styles_response)
|
stub_styles_request.to_return(
|
||||||
stub_styles_request(tab: 2).to_return(empty_styles_response)
|
# You'd think styles would be `{}` in this case, but it's `[]`. Huh!
|
||||||
|
body: '{"success":true,"styles":[]}',
|
||||||
|
)
|
||||||
|
|
||||||
expect(styles).to be_empty
|
expect(styles).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if the request returns a non-200 status" do
|
it "raises an error if the request returns a non-200 status" do
|
||||||
stub_styles_request(tab: 1).to_return(status: 400)
|
stub_styles_request.to_return(status: 400)
|
||||||
stub_styles_request(tab: 2).to_return(empty_styles_response)
|
|
||||||
|
|
||||||
expect { styles }.to raise_error(Neopets::NCMall::ResponseNotOK)
|
expect { styles }.to raise_error(Neopets::NCMall::ResponseNotOK)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if the request returns a non-JSON response" do
|
it "raises an error if the request returns a non-JSON response" do
|
||||||
stub_styles_request(tab: 1).to_return(
|
stub_styles_request.to_return(
|
||||||
body: "Oops, this request failed for some weird reason!",
|
body: "Oops, this request failed for some weird reason!",
|
||||||
)
|
)
|
||||||
stub_styles_request(tab: 2).to_return(empty_styles_response)
|
|
||||||
|
|
||||||
expect { styles }.to raise_error(Neopets::NCMall::UnexpectedResponseFormat)
|
expect { styles }.to raise_error(Neopets::NCMall::UnexpectedResponseFormat)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if the request returns unexpected JSON" do
|
it "raises an error if the request returns unexpected JSON" do
|
||||||
stub_styles_request(tab: 1).to_return(
|
stub_styles_request.to_return(
|
||||||
body: '{"success": false}',
|
body: '{"success": false}',
|
||||||
)
|
)
|
||||||
stub_styles_request(tab: 2).to_return(empty_styles_response)
|
|
||||||
|
|
||||||
expect { styles }.to raise_error(Neopets::NCMall::UnexpectedResponseFormat)
|
expect { styles }.to raise_error(Neopets::NCMall::UnexpectedResponseFormat)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue