-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View #8
Merged
Merged
View #8
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b44e659
dinamic user list creation
tomasesquivelgc e671d92
divide code into partial
tomasesquivelgc 6774664
reduce code
tomasesquivelgc aa482fe
convert show.html.erb into partials
tomasesquivelgc 58fa786
turn user_bio into partial
tomasesquivelgc 3369bf4
minimize app css
tomasesquivelgc 9311be1
add link-to posts button
tomasesquivelgc 462b78f
create posts index template
tomasesquivelgc 0971ed7
create post index template
tomasesquivelgc 5146eb6
add post_comments and link to post/:id
tomasesquivelgc 9e52f72
add empty posts message, post/:post_id template, back to main page link
tomasesquivelgc 57cbeee
fix linters
tomasesquivelgc 0300462
fix typo
tomasesquivelgc 8c42c22
fix recent_posts
tomasesquivelgc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
class PostsController < ApplicationController | ||
def index; end | ||
def index | ||
@user = User.find(params[:user_id]) | ||
@user_posts = @user.recent_posts | ||
end | ||
|
||
def show; end | ||
def show | ||
@user = User.find(params[:user_id]) | ||
@post = @user.posts.find(params[:id]) | ||
@comments = @post.comments.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
class UsersController < ApplicationController | ||
def index; end | ||
def index | ||
@users = User.all | ||
end | ||
|
||
def show; end | ||
def show | ||
@user = User.find(params[:id]) | ||
@posts = @user.recent_posts | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="comments-card info-card"> | ||
<% post.recent_comments.reverse.each do |comment| %> | ||
<p><%= comment.user.name %>: <%= comment.text %></p> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="info-card"> | ||
<h3 class="user-bio-title">Bio</h3> | ||
</br> | ||
<p class="user-bio-text"> | ||
<%= user.bio %> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="user-card"> | ||
<%= image_tag user.photo, class: "user-image" if user.photo.present? %> | ||
<a href="<%= user_path(user) %>" class="card-info"> | ||
<h2 class="card-name"><%= user.name %></h2> | ||
<p class="counter">Number of posts: <%= user.post_counter || 0 %></p> | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<a href="<%= user_post_path(user, post) %>" class="info-card"> | ||
<h4 class="user-post-title"><%= post.title %></h4> | ||
</br> | ||
<p class="user-post-text"><%= post.text %></p> | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<p class="counter">Comments: <%= post.comments_counter || 0 %>, Likes: <%= post.likes_counter || 0 %></p> | ||
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
<h1>Hello posts</h1> | ||
<%= link_to "back to main page", root_path %> | ||
<%= render 'partials/user_card', user: @user %> | ||
|
||
<div class="user-posts-list"> | ||
<% if @user_posts.empty? %> | ||
<p class="no-posts">No posts yet</p> | ||
<% end %> | ||
<% @user_posts.each do |post| %> | ||
<%= render 'partials/user_post', post: post, user: @user %> | ||
<%= render 'partials/post_comments', post: post %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<h1>Goodbye posts</h1> | ||
<%= link_to "back to main page", root_path %> | ||
<%= render 'partials/user_post', post: @post, user: @user %> | ||
<%= render 'partials/post_comments', post: @post %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,4 @@ | ||
<ul> | ||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
<li class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</li> | ||
|
||
</ul> | ||
<h1 class="title" >Users</h1> | ||
<% @users.each do |user| %> | ||
<%= render 'partials/user_card', user: user %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
<div class="user-card"> | ||
<img src="https://cdn-icons-png.flaticon.com/512/1077/1077114.png" alt="user-image" class="user-image" /> | ||
<div class="card-info"> | ||
<h2 class="card-name" >User Name</h2> | ||
<p class="card-counter" >Number of posts: 0</p> | ||
</div> | ||
</div> | ||
<%= link_to "back to main page", root_path %> | ||
<%= render 'partials/user_card', user: @user %> | ||
|
||
<div class="user-bio"> | ||
<h3 class="user-bio-title">Bio</h3> | ||
</br> | ||
<p class="user-bio-text"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
</p> | ||
</div> | ||
<%= render 'partials/user_bio', user: @user %> | ||
|
||
<h3 class="title">Posts</h3> | ||
<div class="user-posts-list"> | ||
<h3 class="user-posts-title">Posts</h3> | ||
<div class="user-post"> | ||
<h4 class="user-post-title">Post Title</h4> | ||
</br> | ||
<p class="user-post-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<p class="user-post-date">Post Date</p> | ||
</div> | ||
|
||
<div class="user-post"> | ||
<h4 class="user-post-title">Post Title</h4> | ||
</br> | ||
<p class="user-post-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<p class="user-post-date">Post Date</p> | ||
</div> | ||
|
||
<div class="user-post"> | ||
<h4 class="user-post-title">Post Title</h4> | ||
</br> | ||
<p class="user-post-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<p class="user-post-date">Post Date</p> | ||
</div> | ||
|
||
<button class="user-posts-button">See all posts</button> | ||
<% if @posts.empty? %> | ||
<p class="no-posts">No posts yet</p> | ||
<% end %> | ||
<% @posts.each do |post| %> | ||
<%= render 'partials/user_post', post: post, user: @user %> | ||
<% end %> | ||
<%= link_to "See all posts", user_posts_path(@user), class: "user-posts-button" %> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.