diff --git a/Gemfile b/Gemfile index 2c3fd33d..21597054 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,8 @@ gem 'addressable', :require => ['addressable/template', 'addressable/uri'] gem 'whenever', '~> 0.6.2', :require => false +gem 'swf_converter', '~> 0.0.1' + group :development_async do # async wrappers gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git' @@ -42,9 +44,9 @@ end group :production do gem 'thin', '~> 1.2.7' - + gem 'mysql2' - + gem 'memcache-client', '~> 1.8.5', :require => ['memcache', 'memcache/event_machine'] end @@ -52,3 +54,4 @@ group :test do gem 'factory_girl_rails', '~> 1.0' gem 'rspec-rails', '~> 2.0.0.beta.22' end + diff --git a/Gemfile.lock b/Gemfile.lock index 57257ae7..24c65a79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,7 @@ GEM arel (2.0.8) bcrypt-ruby (2.1.4) builder (2.1.2) + chunky_png (1.2.0) closure-compiler (1.0.0) compass (0.10.6) haml (>= 3.0.4) @@ -106,6 +107,8 @@ GEM mime-types (1.16) msgpack (0.4.4) mysql2 (0.2.6) + oily_png (1.0.1) + chunky_png (~> 1) openneo-auth-signatory (0.1.0) ruby-hmac polyglot (0.3.1) @@ -143,6 +146,9 @@ GEM rspec-rails (2.0.1) rspec (~> 2.0.0) ruby-hmac (0.4.0) + swf_converter (0.0.1) + chunky_png (~> 1.2.0) + oily_png (~> 1.0.1) thin (1.2.7) daemons (>= 1.0.9) eventmachine (>= 0.12.6) @@ -184,6 +190,7 @@ DEPENDENCIES rails (= 3.0.4) rdiscount (~> 1.6.5) rspec-rails (~> 2.0.0.beta.22) + swf_converter (~> 0.0.1) thin (~> 1.2.7) whenever (~> 0.6.2) will_paginate (~> 3.0.pre2) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 4455e8df..eb4fa5d1 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -1,9 +1,25 @@ class SwfAsset < ActiveRecord::Base PUBLIC_ASSET_DIR = File.join('swfs', 'outfit') LOCAL_ASSET_DIR = Rails.root.join('public', PUBLIC_ASSET_DIR) + PUBLIC_IMAGE_DIR = File.join('images', 'outfit') + LOCAL_IMAGE_DIR = Rails.root.join('public', PUBLIC_IMAGE_DIR) NEOPETS_ASSET_SERVER = 'http://images.neopets.com' + set_inheritance_column 'inheritance_type' + include SwfConverter + converts_swfs :size => [600, 600], :output_sizes => [[150, 150], [300, 300], [600, 600]] + + def local_swf_path + LOCAL_ASSET_DIR.join(local_path_within_outfit_swfs) + end + + def swf_image_path(size) + base_dir = File.dirname(local_path_within_outfit_swfs) + image_dir = LOCAL_IMAGE_DIR.join(base_dir).join(id.to_s) + image_dir.join("#{id}_#{size[0]}x#{size[1]}.png") + end + attr_accessor :item has_one :contribution, :as => :contributed diff --git a/public/images/outfit/.gitignore b/public/images/outfit/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/public/images/outfit/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/vendor/cache/chunky_png-1.2.0.gem b/vendor/cache/chunky_png-1.2.0.gem new file mode 100644 index 00000000..2f2bddbf Binary files /dev/null and b/vendor/cache/chunky_png-1.2.0.gem differ diff --git a/vendor/cache/oily_png-1.0.1.gem b/vendor/cache/oily_png-1.0.1.gem new file mode 100644 index 00000000..ebc9055a Binary files /dev/null and b/vendor/cache/oily_png-1.0.1.gem differ diff --git a/vendor/cache/swf_converter-0.0.1.gem b/vendor/cache/swf_converter-0.0.1.gem new file mode 100644 index 00000000..4900c2d3 Binary files /dev/null and b/vendor/cache/swf_converter-0.0.1.gem differ