forked from OpenNeo/impress
Delete more rake tasks
I tried to port the Rainbow Pool ones forward, but ran into issues with the service that uses browser-specific stuff to check that traffic is valid :/ Incidentally, those were the only places we were using `rest-client`. Goodbye!
This commit is contained in:
parent
93511b3d51
commit
d2de971a60
14 changed files with 0 additions and 127 deletions
1
Gemfile
1
Gemfile
|
@ -35,7 +35,6 @@ gem 'globalize', '~> 6.2', '>= 6.2.1'
|
|||
|
||||
# For reading and parsing HTML from Neopets.com, like importing Closet pages.
|
||||
gem 'nokogiri', '~> 1.15', '>= 1.15.3'
|
||||
gem 'rest-client', '~> 2.1'
|
||||
|
||||
# For safely rendering users' Markdown + HTML on item list pages.
|
||||
gem 'rdiscount', '~> 2.2', '>= 2.2.7.1'
|
||||
|
|
18
Gemfile.lock
18
Gemfile.lock
|
@ -125,8 +125,6 @@ GEM
|
|||
warden (~> 1.2.3)
|
||||
devise-encryptable (0.2.0)
|
||||
devise (>= 2.1.0)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.8.1)
|
||||
dotenv-rails (2.8.1)
|
||||
dotenv (= 2.8.1)
|
||||
|
@ -148,9 +146,6 @@ GEM
|
|||
temple (>= 0.8.2)
|
||||
thor
|
||||
tilt
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.0.5)
|
||||
domain_name (~> 0.5)
|
||||
http_accept_language (2.1.1)
|
||||
httparty (0.21.0)
|
||||
mini_mime (>= 1.0.0)
|
||||
|
@ -178,9 +173,6 @@ GEM
|
|||
net-smtp
|
||||
marcel (1.0.2)
|
||||
memory_profiler (1.0.1)
|
||||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2023.0218.1)
|
||||
mini_mime (1.1.5)
|
||||
mini_portile2 (2.8.4)
|
||||
minitest (5.19.0)
|
||||
|
@ -197,7 +189,6 @@ GEM
|
|||
timeout
|
||||
net-smtp (0.4.0)
|
||||
net-protocol
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.9)
|
||||
nokogiri (1.15.3)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
|
@ -280,11 +271,6 @@ GEM
|
|||
responders (3.1.1)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
ruby2_keywords (0.0.5)
|
||||
sanitize (6.0.2)
|
||||
crass (~> 1.0.2)
|
||||
|
@ -324,9 +310,6 @@ GEM
|
|||
traces (0.11.1)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8.2)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
web-console (4.2.1)
|
||||
|
@ -371,7 +354,6 @@ DEPENDENCIES
|
|||
rdiscount (~> 2.2, >= 2.2.7.1)
|
||||
react-rails (~> 2.7, >= 2.7.1)
|
||||
record_tag_helper (~> 1.0, >= 1.0.1)
|
||||
rest-client (~> 2.1)
|
||||
sanitize (~> 6.0, >= 6.0.2)
|
||||
sass-rails (~> 6.0)
|
||||
sentry-rails (~> 5.12)
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
namespace :colors do
|
||||
desc 'Create a color'
|
||||
task :create, [:id, :name, :standard, :basic, :prank] => :environment do |t, args|
|
||||
args.with_defaults(standard: true, basic: false, prank: false)
|
||||
# TIL: ActiveRecord will convert strings to booleans automatically. Cool.
|
||||
color = Color.new
|
||||
color.id = args[:id]
|
||||
color.name = args[:name]
|
||||
color.standard = args[:standard]
|
||||
color.basic = args[:basic]
|
||||
color.prank = args[:prank]
|
||||
color.save!
|
||||
puts "Color #{color.inspect} created"
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
namespace :pet_types do
|
||||
desc "Download the Rainbow Pool data for the given locale"
|
||||
task :download_basic_image_hashes => :environment do
|
||||
Species.find_each do |species|
|
||||
pool_url = "https://www.neopets.com/pool/all_pb.phtml"
|
||||
pool_options = {
|
||||
:cookies => {:neologin => URI.encode(ENV['NEOLOGIN'])},
|
||||
:params => {:lang => 'en', :f_species_id => species.id}
|
||||
}
|
||||
pool_response = RestClient.get(pool_url, pool_options)
|
||||
pool_doc = Nokogiri::HTML(pool_response)
|
||||
|
||||
counts = {saved: 0, skipped: 0}
|
||||
PetType.transaction do
|
||||
pool_doc.css('a[onclick^="set_pet_img("]').each do |link|
|
||||
color = Color.find_by_name link.text
|
||||
pet_type = PetType.find_by_species_id_and_color_id species, color
|
||||
if pet_type
|
||||
image_hash = PetType.get_hash_from_cp_path(link['onclick'][36..55])
|
||||
pet_type.basic_image_hash = image_hash
|
||||
pet_type.save!
|
||||
counts[:saved] += 1
|
||||
puts "* #{pet_type.human_name}: #{pet_type.basic_image_hash}"
|
||||
else
|
||||
dummy_pet_type = PetType.new color: color, species: species
|
||||
counts[:skipped] += 1
|
||||
puts " #{dummy_pet_type.human_name}: skip: not yet modeled"
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "- #{species.human_name}: saved #{counts[:saved]}, skipped #{counts[:skipped]}"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,59 +0,0 @@
|
|||
require 'rocketamf/remote_gateway'
|
||||
|
||||
namespace :translate do
|
||||
desc "Download the Neopets zone data for the given locale"
|
||||
task :zones => :environment do
|
||||
with_given_locale do |neopets_language_code|
|
||||
gateway = RocketAMF::RemoteGateway.new(Pet::GATEWAY_URL)
|
||||
action = gateway.service('CustomPetService').action('getApplicationData')
|
||||
envelope = action.request([]).post(
|
||||
:headers => {
|
||||
'Cookie' => "lang=#{neopets_language_code}"
|
||||
}
|
||||
)
|
||||
application_data = envelope.messages[0].data.body
|
||||
|
||||
zones_by_id = Zone.all.inject({}) { |h, z| h[z.id] = z ; h }
|
||||
application_data[:zones].each do |zone_data|
|
||||
zone = zones_by_id[zone_data[:id].to_i]
|
||||
zone.label = zone_data[:label]
|
||||
zone.plain_label = Zone.plainify_label(zone.label)
|
||||
zone.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Download the Rainbow Pool data for the given locale"
|
||||
task :pet_attributes => :environment do
|
||||
with_given_locale do |neopets_language_code|
|
||||
pool_url = "https://www.neopets.com/pool/all_pb.phtml"
|
||||
pool_options = {
|
||||
:cookies => {:neologin => URI.encode(ENV['NEOLOGIN'])},
|
||||
:params => {:lang => neopets_language_code}
|
||||
}
|
||||
pool_response = RestClient.get(pool_url, pool_options)
|
||||
pool_doc = Nokogiri::HTML(pool_response)
|
||||
|
||||
[Species, Color].each do |klass|
|
||||
klass_name = klass.name.underscore
|
||||
records_by_id = klass.all.inject({}) { |h, r| h[r.id] = r; h }
|
||||
pool_doc.css("select[name=f_#{klass_name}_id] option").each do |option|
|
||||
record = records_by_id[option['value'].to_i]
|
||||
record.name = option.text.downcase
|
||||
record.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def with_given_locale
|
||||
I18n.with_locale(ENV['LOCALE']) do
|
||||
language_code = I18n.compatible_neopets_language_code_for(I18n.locale)
|
||||
unless language_code
|
||||
raise "Locale #{I18n.locale.inspect} has no neopets language code"
|
||||
end
|
||||
|
||||
yield(language_code)
|
||||
end
|
||||
end
|
||||
end
|
BIN
vendor/cache/domain_name-0.5.20190701.gem
vendored
BIN
vendor/cache/domain_name-0.5.20190701.gem
vendored
Binary file not shown.
BIN
vendor/cache/http-accept-1.7.0.gem
vendored
BIN
vendor/cache/http-accept-1.7.0.gem
vendored
Binary file not shown.
BIN
vendor/cache/http-cookie-1.0.5.gem
vendored
BIN
vendor/cache/http-cookie-1.0.5.gem
vendored
Binary file not shown.
BIN
vendor/cache/mime-types-3.4.1.gem
vendored
BIN
vendor/cache/mime-types-3.4.1.gem
vendored
Binary file not shown.
BIN
vendor/cache/mime-types-data-3.2023.0218.1.gem
vendored
BIN
vendor/cache/mime-types-data-3.2023.0218.1.gem
vendored
Binary file not shown.
BIN
vendor/cache/netrc-0.11.0.gem
vendored
BIN
vendor/cache/netrc-0.11.0.gem
vendored
Binary file not shown.
BIN
vendor/cache/rest-client-2.1.0.gem
vendored
BIN
vendor/cache/rest-client-2.1.0.gem
vendored
Binary file not shown.
BIN
vendor/cache/unf-0.1.4.gem
vendored
BIN
vendor/cache/unf-0.1.4.gem
vendored
Binary file not shown.
BIN
vendor/cache/unf_ext-0.0.8.2.gem
vendored
BIN
vendor/cache/unf_ext-0.0.8.2.gem
vendored
Binary file not shown.
Loading…
Reference in a new issue