Skip to content

Commit c5719c8

Browse files
Merge pull request #112 from Code-the-Dream-School/83_profile_page_fixes
added profile pic and links to profile pages where missing
2 parents 7f31fb9 + 390d957 commit c5719c8

File tree

8 files changed

+117
-10
lines changed

8 files changed

+117
-10
lines changed

.DS_Store

0 Bytes
Binary file not shown.

app/assets/stylesheets/application.scss

+5
Original file line numberDiff line numberDiff line change
@@ -1103,3 +1103,8 @@ h1 {
11031103
outline: none;
11041104
}
11051105

1106+
.dashboard_profile_picture_container{
1107+
border-radius: 50%;
1108+
object-fit: cover;
1109+
}
1110+

app/controllers/users_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def index
66
@users = User.all
77
end
88

9+
def friend_profile
10+
@user = User.find(params[:id])
11+
end
12+
913
def show
1014
@friends = @user.friends
1115
@entries = @user.entries

app/views/entries/friend_entry_show.html.erb

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<section class=" entries__show-content-container">
22
<div class="entries__show-emotion-symbol">
3-
<%= image_tag(@entry.user.profile_picture, class: 'entries__show-profile-picture') %>
3+
<a href="<%= friend_profile_path(@entry.user) %>">
4+
<%= image_tag(@entry.user.profile_picture, class: 'entries__show-profile-picture') %>
5+
</a>
46
</div>
57

68
<div class="entries__show-emotion-header">
@@ -33,10 +35,10 @@
3335
<%= link_to 'Comment', new_entry_comment_path(@entry), class: "btn btn-primary" %>
3436
<% @entry.comments.each do |comment| %>
3537
<div class="entries__show-comment-container">
36-
<div class="entries__show-comment-container-start">
37-
<%= image_tag(comment.user.profile_picture) %>
38-
<p><%= comment.user.username %>:</p>
39-
</div>
38+
<div class="entries__show-comment-container-start">
39+
<%= image_tag(comment.user.profile_picture) %>
40+
<p><%= comment.user.username %>:</p>
41+
</div>
4042

4143
<div class="entries__show-comment-container-text">
4244
<p><%= comment.text %></p>

app/views/layouts/_navigation.html.erb

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
</div>
2828

2929
<div class="app__navbar_right">
30-
<div class="avatar_container">
31-
<p>avatar</p>
32-
</div>
30+
<%= link_to profile_path(current_user), class: "avatar_link" do %>
31+
<div class="dashboard_profile_picture_container">
32+
<% if current_user.profile_picture.attached? %>
33+
<%= image_tag current_user.profile_picture, class: "img-fluid rounded-circle", alt: "Profile picture of #{current_user.username}", style: "width: 150px; height: 150px; object-fit: cover;" %>
34+
<% else %>
35+
<%= image_tag 'default.png', class: "img-fluid rounded-circle", alt: "Default profile picture" %>
36+
<% end %>
37+
</div>
38+
<% end %>
3339
</div>
3440
</section>
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<div class="container mt-4">
2+
<div class="d-flex justify-content-center mb-4">
3+
<%= link_to 'Back to Dashboard', dashboard_index_path, class: 'btn btn-secondary' %>
4+
</div>
5+
<div class="row mb-4">
6+
<div class="col-md-4">
7+
<div class="card">
8+
<div class="card-body text-center">
9+
<h3 class="card-title"><%= @user.username %></h3>
10+
<% if @user.profile_picture.attached? %>
11+
<%= image_tag @user.profile_picture, class: "img-fluid rounded-circle", alt: "Profile picture of #{@user.username}", style: "width: 150px; height: 150px; object-fit: cover;" %>
12+
<% else %>
13+
<%= image_tag 'default.png', class: "img-fluid rounded-circle", alt: "Default profile picture" %>
14+
<% end %>
15+
</div>
16+
</div>
17+
</div>
18+
19+
<div class="col-md-8">
20+
<div class="card">
21+
<div class="card-body">
22+
<h4>Bio</h4>
23+
<p><%= @user.bio.present? ? @user.bio : "No bio yet" %></p>
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div class="row">
30+
<div class="col-md-4">
31+
<div class="card">
32+
<div class="card-body">
33+
<h4>Friends</h4>
34+
<div class="list-group">
35+
<% @user.friends.each do |friend| %>
36+
<a href="<%= friend_profile_path(friend) %>" class="list-group-item list-group-item-action">
37+
<%= image_tag(friend.profile_picture, class: 'img-thumbnail mr-2', alt: friend.username) if friend.profile_picture.attached? %>
38+
<%= friend.username %>
39+
</a>
40+
<% end %>
41+
</div>
42+
</div>
43+
</div>
44+
</div>
45+
46+
<div class="col-md-8">
47+
<div class="card">
48+
<div class="card-body">
49+
<h4 class="mt-4">Entries</h4>
50+
<% @user.entries.each do |entry| %>
51+
<div class="card mb-3">
52+
<div class="card-body">
53+
<p><%= entry.text %></p>
54+
<small><%= entry.created_at.strftime("%B %d, %Y") %></small>
55+
56+
<div class="comments-section mt-3">
57+
<h5>Comments</h5>
58+
<div class="comments-container" style="max-height: 200px; overflow-y: auto;">
59+
<% entry.comments.each do |comment| %>
60+
<div class="comment">
61+
<div class="d-flex mb-2">
62+
<%= image_tag(comment.user.profile_picture, class: 'img-thumbnail mr-2', alt: comment.user.username) if comment.user.profile_picture.attached? %>
63+
<div>
64+
<strong><%= comment.user.username %></strong>
65+
<p><%= comment.text %></p>
66+
</div>
67+
</div>
68+
</div>
69+
<% end %>
70+
</div>
71+
72+
<%= form_with model: [entry, Comment.new], local: true do |f| %>
73+
<div class="form-group">
74+
<%= f.text_area :text, class: 'form-control', placeholder: 'Add a comment...' %>
75+
</div>
76+
<%= f.submit 'Post Comment', class: 'btn btn-primary btn-sm' %>
77+
<% end %>
78+
</div>
79+
</div>
80+
</div>
81+
<% end %>
82+
</div>
83+
</div>
84+
</div>
85+
</div>
86+
</div>

app/views/users/show.html.erb

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<div class="container mt-4">
2+
<div class="d-flex justify-content-center mb-4">
3+
<%= link_to 'Back to Dashboard', dashboard_index_path, class: 'btn btn-secondary' %>
4+
</div>
25
<div class="row mb-4">
36
<div class="col-md-4">
47
<div class="card">
@@ -13,7 +16,7 @@
1316

1417
<%= form_with model: @user, url: upload_profile_picture_user_path(@user), method: :patch, local: true, enctype: "multipart/form-data" do |f| %>
1518
<div class="form-group mt-3">
16-
<%= f.file_field :profile_picture, class: 'form-control' %>
19+
<%= f.file_field :profile_picture, class: 'form-control', required: true %>
1720
</div>
1821
<%= f.submit 'Upload Picture', class: 'btn btn-primary mt-3' %>
1922
<% end %>
@@ -44,7 +47,7 @@
4447
<h4>Friends</h4>
4548
<div class="list-group">
4649
<% @user.friends.each do |friend| %>
47-
<a href="<%= profile_path(friend) %>" class="list-group-item list-group-item-action">
50+
<a href="<%= friend_profile_path(friend) %>" class="list-group-item list-group-item-action">
4851
<%= image_tag(friend.profile_picture, class: 'img-thumbnail mr-2', alt: friend.username) if friend.profile_picture.attached? %>
4952
<%= friend.username %>
5053
</a>

config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
end
2525

2626
get 'profile', to: 'users#show', as: 'profile'
27+
get 'profile/:id', to: 'users#friend_profile', as: 'friend_profile'
2728

2829
resources :friendships, only: [:index, :show] do
2930
collection do

0 commit comments

Comments
 (0)