Skip to content

Commit 39d1a02

Browse files
committed
Added assets and modified seed file to upload images
1 parent 43bf13c commit 39d1a02

File tree

106 files changed

+65823
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+65823
-42
lines changed
47.7 KB
45.5 KB
73 KB
6 KB
Binary file not shown.

app/assets/stylesheets/application.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ body {
3434
}
3535

3636
.card-img-top {
37-
width: 250px;
37+
width: 100%;
3838
height: 250px;
3939
}
4040

app/views/devise/registrations/edit.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="d-flex justify-content-center flex-column mb-5">
33
<div class="align-self-center">
44
<% if current_user.avatar.attached? %>
5-
<%= image_tag current_user.avatar, class: "rounded" %>
5+
<%= image_tag current_user.avatar.service_url, class: "rounded" %>
66
<% else %>
77
<%= image_tag "placeholder-avatar.png", class: "rounded" %>
88
<% end %>

app/views/pages/home.html.erb

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,29 @@
33
<li data-target="#carouseIndicators" data-slide-to="0" class="active"></li>
44
<li data-target="#carouselIndicators" data-slide-to="1"></li>
55
<li data-target="#carouselIndicators" data-slide-to="2"></li>
6+
<li data-target="#carouselIndicators" data-slide-to="3"></li>
7+
<li data-target="#carouselIndicators" data-slide-to="4"></li>
8+
<li data-target="#carouselIndicators" data-slide-to="5"></li>
69
</ol>
10+
711
<div class="carousel-inner">
812
<div class="carousel-item active">
9-
<%= image_tag "home_logos/home_bape.png", class: "d-block w-100" %>
13+
<%= link_to (image_tag "home_logos/home_bape.png", alt: "Bape", class: "d-block w-100"), listings_path %>
14+
</div>
15+
<div class="carousel-item">
16+
<%= link_to (image_tag "home_logos/home_off-white.png", alt: "Off-White", class: "d-block w-100"), listings_path %>
17+
</div>
18+
<div class="carousel-item">
19+
<%= link_to (image_tag "home_logos/home_supreme.png", alt: "Supreme", class: "d-block w-100"), listings_path %>
20+
</div>
21+
<div class="carousel-item">
22+
<%= link_to (image_tag "home_logos/home_palace.png", alt: "Palace", class: "d-block w-100"), listings_path %>
1023
</div>
1124
<div class="carousel-item">
12-
<%= image_tag "home_logos/home_offwhite.png", class: "d-block w-100" %>
25+
<%= link_to (image_tag "home_logos/home_adidas.png", alt: "Adidas", class: "d-block w-100"), listings_path %>
1326
</div>
1427
<div class="carousel-item">
15-
<%= image_tag "home_logos/home_supreme.png", class: "d-block w-100" %>
28+
<%= link_to (image_tag "home_logos/home_nike.png", alt: "Supreme", class: "d-block w-100"), listings_path %>
1629
</div>
1730
</div>
1831
<a class="carousel-control-prev" href="#carouselIndicators" role="button" data-slide="prev">
@@ -25,9 +38,7 @@
2538
</a>
2639
</div>
2740

28-
29-
30-
<h3 class="text-center">Latest Listings</h3>
41+
<h3 class="text-center">Latest Listings</h3>
3142

3243
<div class="container">
3344
<%= render "shared/display_listings" %>
@@ -37,9 +48,6 @@
3748
<%= link_to "Browse More", listings_path, class: "btn btn-primary float-center" %>
3849
</div>
3950

40-
41-
42-
4351
<script>
4452
$('.carousel').carousel()
4553
</script>

app/views/shared/_display_listings.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class>
44
<div class= "listing-cards card m-3">
55
<% if listing.picture.attached? %>
6-
<%= image_tag listing.picture, class: "card-img-top" %>
6+
<%= image_tag listing.picture.service_url, class: "card-img-top" %>
77
<% else %>
88
<%= image_tag "placeholder-avatar.png", class: "card-img-top" %>
99
<% end %>

app/views/shared/_listing_details.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="row">
66
<div class="col">
77
<% if @listing.picture.attached? %>
8-
<%= image_tag @listing.picture %>
8+
<%= image_tag @listing.picture.service_url %>
99
<% end %>
1010
</div>
1111

app/views/shared/_navigation_bar.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<%= link_to "Help", help_path, class: "nav-link" %>
88
<% if current_user %>
99
<% if current_user.avatar.attached? %>
10-
<%= image_tag current_user.avatar, class: "rounded avatar" %>
10+
<%= image_tag current_user.avatar.service_url, class: "rounded avatar" %>
1111
<% else %>
1212
<%= image_tag "placeholder-avatar.png", class: "rounded avatar" %>
1313
<% end %>

config/environments/test.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
# Configure public file server for tests with Cache-Control for performance.
1616
config.public_file_server.enabled = true
1717
config.public_file_server.headers = {
18-
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
18+
"Cache-Control" => "public, max-age=#{1.hour.to_i}",
1919
}
2020

2121
# Show full error reports and disable caching.
22-
config.consider_all_requests_local = true
22+
config.consider_all_requests_local = true
2323
config.action_controller.perform_caching = false
2424

2525
# Raise exceptions instead of rendering exception templates.
@@ -43,4 +43,7 @@
4343

4444
# Raises error for missing translations
4545
# config.action_view.raise_on_missing_translations = true
46+
47+
# Active Storage with Amazon
48+
config.active_storage.service = :amazon
4649
end

config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
get "/payments/success", to: "payments#success"
2424
post "/payments/webhook", to: "payments#webhook"
2525
#If path is invalid redirect to root
26-
# get "*path", to: redirect("/")
26+
get "*path", to: redirect("/")
2727
end

db/seeds.rb

+42-24
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,52 @@ def total_count()
77
listing_count = Listing.count
88

99
p "=================TOTAL=================="
10-
p "CLOTHING CATEGORIES CREATED: #{category_count}"
11-
p "BRANDS CREATED: #{brand_count}"
12-
p "CONDITIONS CREATED: #{condition_count}"
13-
p "USERS CREATED: #{user_count}"
14-
p "LISTING CREATED: #{listing_count}"
10+
p "CLOTHING CATEGORIES: #{category_count}"
11+
p "BRANDS: #{brand_count}"
12+
p "CONDITIONS: #{condition_count}"
13+
p "USERS: #{user_count}"
14+
p "LISTING: #{listing_count}"
1515
p "========================================"
1616
end
1717

18-
clothing_category = ["Accessories", "Bottoms", "Headwear", "Outerwear", "Shirt", "T-Shirt", "Bags"]
19-
brands = ["Adidas", "Nike", "Supreme", "Off-White", "Palace", "Bape", "Kaws"]
20-
conditions = ["New with tags", "New without tags", "New with box", "New without box", "New with defects", "Pre-owned"]
18+
clothing_category = ["Accessories", "Bottoms", "Headwear", "Outerwear", "T-Shirt"]
19+
brands = ["Adidas", "Nike", "Supreme", "Off-White", "Bape"]
20+
conditions = ["New with tags", "New without tags", "New with defects", "Pre-owned"]
2121

2222
clothing_category.each do |category|
23-
Category.create(
24-
name: category,
25-
)
23+
if Category.exists?(name: category) == false
24+
Category.create(
25+
name: category,
26+
)
27+
end
2628
end
2729

2830
brands.each do |brand|
29-
Brand.create(
30-
name: brand,
31-
)
31+
if Brand.exists?(name: brand) == false
32+
Brand.create(
33+
name: brand,
34+
)
35+
end
3236
end
3337

3438
conditions.each do |condition|
35-
Condition.create(
36-
name: condition,
37-
)
39+
if Condition.exists?(name: condition) == false
40+
Condition.create(
41+
name: condition,
42+
)
43+
end
3844
end
3945

4046
# Generate test account
41-
User.create(
42-
full_name: "Test Account",
43-
44-
password: "password",
45-
password_confirmation: "password",
46-
biography: Faker::Lorem.sentence(word_count: 3),
47-
)
47+
if User.exists?(full_name: "Test Account", email: "[email protected]") == false
48+
User.create(
49+
full_name: "Test Account",
50+
51+
password: "password",
52+
password_confirmation: "password",
53+
biography: Faker::Lorem.sentence(word_count: 3),
54+
)
55+
end
4856

4957
# Generate random user accounts
5058
for i in 1..10
@@ -69,4 +77,14 @@ def total_count()
6977
)
7078
end
7179

80+
#attach image
81+
listings = Listing.all
82+
83+
listings.each do |listing|
84+
if listing.brand.name
85+
random = rand(1..3)
86+
listing.picture.attach(io: File.open("app/assets/images/stock_image/#{listing.brand.name}/#{listing.brand.name}_#{listing.category.name}_#{random}.png"), filename: "#{listing.brand.name}_#{listing.category.name}_#{random}.png", content_type: "image/png")
87+
end
88+
end
89+
7290
total_count()

0 commit comments

Comments
 (0)