Skip to content

Commit

Permalink
Upload new sample images
Browse files Browse the repository at this point in the history
Refresh sample images of the store demo, with items branded by Solidus and by a
redesigned version of the Ruby logo.

Update the image sizes to support the retina screens (is not an appropriate
way, maybe we need an helper that load bigger images only on retina screens),
except the smaller one preview that is in use on the product page when there
are many variants, and in admin area on product list; the issue is that on the
product page there is any max-width defined for the thumbnail list items.
  • Loading branch information
mfrecchiami committed Aug 8, 2019
1 parent a06fe57 commit 8221dcb
Show file tree
Hide file tree
Showing 51 changed files with 454 additions and 212 deletions.
2 changes: 1 addition & 1 deletion core/app/models/spree/image/paperclip_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Spree::Image::PaperclipAttachment
validate :no_attachment_errors

has_attached_file :attachment,
styles: { mini: '48x48>', small: '100x100>', product: '240x240>', large: '600x600>' },
styles: { mini: '48x48>', small: '400x400>', product: '680x680>', large: '1200x1200>' },
default_style: :product,
default_url: 'noimage/:style.png',
url: '/spree/products/:id/:style/:basename.:extension',
Expand Down
113 changes: 73 additions & 40 deletions sample/db/samples/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,99 +4,132 @@
Spree::Sample.load_sample("variants")

products = {}
products[:ror_baseball_jersey] = Spree::Product.find_by!(name: "Ruby on Rails Baseball Jersey")
products[:ror_tote] = Spree::Product.find_by!(name: "Ruby on Rails Tote")
products[:ror_bag] = Spree::Product.find_by!(name: "Ruby on Rails Bag")
products[:ror_jr_spaghetti] = Spree::Product.find_by!(name: "Ruby on Rails Jr. Spaghetti")
products[:ror_mug] = Spree::Product.find_by!(name: "Ruby on Rails Mug")
products[:ror_ringer] = Spree::Product.find_by!(name: "Ruby on Rails Ringer T-Shirt")
products[:ror_stein] = Spree::Product.find_by!(name: "Ruby on Rails Stein")
products[:ruby_baseball_jersey] = Spree::Product.find_by!(name: "Ruby Baseball Jersey")
products[:apache_baseball_jersey] = Spree::Product.find_by!(name: "Apache Baseball Jersey")
products[:solidus_tshirt] = Spree::Product.find_by!(name: "Solidus T-Shirt")
products[:solidus_long] = Spree::Product.find_by!(name: "Solidus Long Sleeve")
products[:solidus_girly] = Spree::Product.find_by!(name: "Solidus Girly")
products[:solidus_snapback_cap] = Spree::Product.find_by!(name: "Solidus Snapback Cap")
products[:solidus_hoodie] = Spree::Product.find_by!(name: "Solidus Hoodie Zip")
products[:ruby_hoodie] = Spree::Product.find_by!(name: "Ruby Hoodie")
products[:ruby_hoodie_zip] = Spree::Product.find_by!(name: "Ruby Hoodie Zip")
products[:ruby_polo] = Spree::Product.find_by!(name: "Ruby Polo")
products[:solidus_mug] = Spree::Product.find_by!(name: "Solidus Mug")
products[:ruby_mug] = Spree::Product.find_by!(name: "Ruby Mug")
products[:solidus_tote] = Spree::Product.find_by!(name: "Solidus Tote")
products[:ruby_tote] = Spree::Product.find_by!(name: "Ruby Tote")

def image(name, type = "jpeg")
def image(name, type = "jpg")
images_path = Pathname.new(File.dirname(__FILE__)) + "images"
path = images_path + "#{name}.#{type}"
return false if !File.exist?(path)
path
end

images = {
products[:ror_tote].master => [
products[:solidus_tshirt].master => [
{
attachment: image("ror_tote")
attachment: image("solidus_tshirt")
},
{
attachment: image("ror_tote_back")
attachment: image("solidus_tshirt_back")
}
],
products[:ror_bag].master => [
products[:solidus_long].master => [
{
attachment: image("ror_bag")
attachment: image("solidus_long")
},
{
attachment: image("solidus_long_back")
}
],
products[:ror_baseball_jersey].master => [
{
attachment: image("ror_baseball")
},
products[:solidus_snapback_cap].master => [
{
attachment: image("ror_baseball_back")
attachment: image("solidus_snapback_cap")
}
],
products[:ror_jr_spaghetti].master => [
products[:solidus_hoodie].master => [
{
attachment: image("ror_jr_spaghetti")
attachment: image("solidus_hoodie")
}
],
products[:ror_mug].master => [
products[:ruby_hoodie].master => [
{
attachment: image("ror_mug")
},
attachment: image("ruby_hoodie")
}
],
products[:ruby_hoodie_zip].master => [
{
attachment: image("ror_mug_back")
attachment: image("ruby_hoodie_zip")
}
],
products[:ror_ringer].master => [
products[:ruby_polo].master => [
{
attachment: image("ror_ringer")
attachment: image("ruby_polo")
},
{
attachment: image("ror_ringer_back")
attachment: image("ruby_polo_back")
}
],
products[:ror_stein].master => [
products[:solidus_mug].master => [
{
attachment: image("ror_stein")
},
attachment: image("solidus_mug")
}
],
products[:ruby_mug].master => [
{
attachment: image("ror_stein_back")
attachment: image("ruby_mug")
}
],
products[:apache_baseball_jersey].master => [
products[:solidus_tote].master => [
{
attachment: image("apache_baseball", "png")
attachment: image("tote_bag_solidus")
}
],
products[:ruby_baseball_jersey].master => [
products[:ruby_tote].master => [
{
attachment: image("ruby_baseball", "png")
attachment: image("tote_bag_ruby")
}
],
products[:solidus_girly].master => [
{
attachment: image("solidus_girly")
}
]
}

products[:ror_baseball_jersey].variants.each do |variant|
products[:solidus_tshirt].variants.each do |variant|
color = variant.option_value("tshirt-color").downcase
main_image = image("ror_baseball_jersey_#{color}", "png")
main_image = image("solidus_tshirt_#{color}", "png")
File.open(main_image) do |f|
variant.images.create!(attachment: f)
end
back_image = image("ror_baseball_jersey_back_#{color}", "png")
back_image = image("solidus_tshirt_back_#{color}", "png")
next unless back_image
File.open(back_image) do |f|
variant.images.create!(attachment: f)
end
end

products[:solidus_long].variants.each do |variant|
color = variant.option_value("tshirt-color").downcase
main_image = image("solidus_long_#{color}", "png")
File.open(main_image) do |f|
variant.images.create!(attachment: f)
end
back_image = image("solidus_long_back_#{color}", "png")
next unless back_image
File.open(back_image) do |f|
variant.images.create!(attachment: f)
end
end

products[:solidus_girly].variants.each do |variant|
color = variant.option_value("tshirt-color").downcase
main_image = image("solidus_girly_#{color}", "png")
File.open(main_image) do |f|
variant.images.create!(attachment: f)
end
end

images.each do |variant, attachments|
puts "Loading images for #{variant.product.name}"
attachments.each do |attachment|
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added sample/db/samples/images/ruby_hoodie.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/ruby_hoodie_zip.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/ruby_mug.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/ruby_polo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/ruby_polo_back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_girly.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_girly_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_girly_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_girly_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_hoodie.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_long.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_long_back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/db/samples/images/solidus_long_black.png
Binary file added sample/db/samples/images/solidus_long_blue.png
Binary file added sample/db/samples/images/solidus_long_white.png
Binary file added sample/db/samples/images/solidus_mug.jpg
Binary file added sample/db/samples/images/solidus_snapback_cap.jpg
Binary file added sample/db/samples/images/solidus_tshirt.jpg
Binary file added sample/db/samples/images/solidus_tshirt_back.jpg
Binary file added sample/db/samples/images/solidus_tshirt_black.png
Binary file added sample/db/samples/images/solidus_tshirt_blue.png
Binary file added sample/db/samples/images/solidus_tshirt_white.png
Binary file added sample/db/samples/images/tote_bag_ruby.jpg
Binary file added sample/db/samples/images/tote_bag_solidus.jpg
14 changes: 13 additions & 1 deletion sample/db/samples/option_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@
{
name: "Red",
presentation: "Red",
position: 1,
position: 5,
option_type: color
},
{
name: "Green",
presentation: "Green",
position: 4,
option_type: color
},
{
name: "Black",
presentation: "Black",
position: 1,
option_type: color
},
{
name: "White",
presentation: "White",
position: 2,
option_type: color
},
Expand Down
4 changes: 2 additions & 2 deletions sample/db/samples/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
)

orders[0].line_items.create!(
variant: Spree::Product.find_by!(name: "Ruby on Rails Tote").master,
variant: Spree::Product.find_by!(name: "Solidus Tote").master,
quantity: 1,
price: 15.99
)

orders[1].line_items.create!(
variant: Spree::Product.find_by!(name: "Ruby on Rails Bag").master,
variant: Spree::Product.find_by!(name: "Solidus Snapback Cap").master,
quantity: 1,
price: 22.99
)
Expand Down
6 changes: 3 additions & 3 deletions sample/db/samples/product_option_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
size = Spree::OptionType.find_by!(presentation: "Size")
color = Spree::OptionType.find_by!(presentation: "Color")

ror_baseball_jersey = Spree::Product.find_by!(name: "Ruby on Rails Baseball Jersey")
ror_baseball_jersey.option_types = [size, color]
ror_baseball_jersey.save!
solidus_tshirt = Spree::Product.find_by!(name: "Solidus T-Shirt")
solidus_tshirt.option_types = [size, color]
solidus_tshirt.save!
117 changes: 89 additions & 28 deletions sample/db/samples/product_properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,122 @@

products =
{
"Ruby on Rails Baseball Jersey" =>
"Solidus Tote" =>
{
"Type" => "Tote",
"Size" => %{15" x 18" x 6"},
"Material" => "Canvas"
},
"Ruby Tote" =>
{
"Type" => "Tote",
"Size" => %{15" x 18" x 6"},
"Material" => "Canvas"
},
"Solidus Snapback Cap" =>
{
"Type" => "Snapback Cap",
"Size" => "One Size",
"Material" => "100% Cotton"
},
"Solidus T-Shirt" =>
{
"Manufacturer" => "Jerseys",
"Brand" => "Conditioned",
"Model" => "TL9002",
"Shirt Type" => "Ringer T",
"Sleeve Type" => "Short",
"Made from" => "100% Cotton",
"Fit" => "Loose",
"Gender" => "Men's"
},
"Solidus Long Sleeve" =>
{
"Manufacturer" => "Wilson",
"Brand" => "Wannabe Sports",
"Model" => "JK1002",
"Shirt Type" => "Baseball Jersey",
"Model" => "TL9002",
"Shirt Type" => "Jersey",
"Sleeve Type" => "Long",
"Made from" => "100% cotton",
"Fit" => "Loose",
"Gender" => "Men's"
},
"Ruby on Rails Jr. Spaghetti" =>
"Solidus Hoodie Zip" =>
{
"Manufacturer" => "Jerseys",
"Brand" => "Wannabe Sports",
"Model" => "HD9001",
"Shirt Type" => "Jersey",
"Sleeve Type" => "Long",
"Made from" => "100% cotton",
"Fit" => "Loose",
"Gender" => "Unisex"
},
"Ruby Hoodie" =>
{
"Manufacturer" => "Wilson",
"Brand" => "Resiliance",
"Model" => "TL174",
"Shirt Type" => "Jr. Spaghetti T",
"Sleeve Type" => "None",
"Model" => "HD2001",
"Shirt Type" => "Baseball",
"Sleeve Type" => "Long",
"Made from" => "90% Cotton, 10% Nylon",
"Fit" => "Form",
"Gender" => "Women's"
"Fit" => "Loose",
"Gender" => "Unisex"
},
"Ruby on Rails Ringer T-Shirt" =>
"Ruby Hoodie Zip" =>
{
"Manufacturer" => "Jerseys",
"Brand" => "Conditioned",
"Model" => "TL9002",
"Shirt Type" => "Ringer T",
"Sleeve Type" => "Short",
"Made from" => "100% Vellum",
"Brand" => "Wannabe Sports",
"Model" => "HD9001",
"Shirt Type" => "Jersey",
"Sleeve Type" => "Long",
"Made from" => "100% cotton",
"Fit" => "Loose",
"Gender" => "Men's"
"Gender" => "Unisex"
},
"Ruby on Rails Tote" =>
"Ruby Polo" =>
{
"Type" => "Tote",
"Size" => %{15" x 18" x 6"},
"Material" => "Canvas"
"Manufacturer" => "Wilson",
"Brand" => "Resiliance",
"Model" => "PL9001",
"Shirt Type" => "Ringer T",
"Sleeve Type" => "Short",
"Made from" => "100% Cotton",
"Fit" => "Slim",
"Gender" => "Men's"
},
"Ruby on Rails Bag" =>
"Solidus Mug" =>
{
"Type" => "Messenger",
"Size" => %{14 1/2" x 12" x 5"},
"Material" => "600 Denier Polyester"
"Type" => "Mug",
"Size" => %{4.5" tall, 3.25" dia.}
},
"Ruby on Rails Mug" =>
"Ruby Mug" =>
{
"Type" => "Mug",
"Size" => %{4.5" tall, 3.25" dia.}
},
"Ruby on Rails Stein" =>
"Solidus Girly" =>
{
"Type" => "Stein",
"Size" => %{6.75" tall, 3.75" dia. base, 3" dia. rim}
"Manufacturer" => "Jerseys",
"Brand" => "Conditioned",
"Model" => "WM6001",
"Shirt Type" => "Skinny",
"Sleeve Type" => "Short",
"Made from" => "90% Cotton, 10% Nylon",
"Fit" => "Slim",
"Gender" => "Women's"
}
# "Solidus Woman T-Shirt" =>
# {
# "Manufacturer" => "Jerseys",
# "Brand" => "Conditioned",
# "Model" => "WM6001",
# "Shirt Type" => "Skinny",
# "Sleeve Type" => "Short",
# "Made from" => "90% Cotton, 10% Nylon",
# "Fit" => "Slim",
# "Gender" => "Women's"
# }
}

products.each do |name, properties|
Expand Down
Loading

0 comments on commit 8221dcb

Please sign in to comment.