-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edited users and listed articles on profile page
- Loading branch information
1 parent
eab1cdd
commit 405d562
Showing
8 changed files
with
153 additions
and
90 deletions.
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,2 +1,14 @@ | ||
module ApplicationHelper | ||
|
||
def gravatar_for(user, options = { size: 80}) | ||
|
||
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | ||
|
||
size = options[:size] | ||
|
||
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" | ||
|
||
image_tag(gravatar_url, alt: user.username, class: "img-circle") | ||
|
||
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,47 @@ | ||
<% obj.each do |article| %> | ||
|
||
<div class="row"> | ||
|
||
<div class="col-xs-8 col-xs-offset-2"> | ||
|
||
<div class="well well-lg"> | ||
|
||
<div class="article-title"> | ||
|
||
<%= link_to article.title, article_path(article) %> | ||
|
||
</div> | ||
|
||
<div class="article-body"> | ||
|
||
<%= truncate(article.description, length: 100) %> | ||
<div class="article-meta-details"> | ||
|
||
|
||
<small> Created by: <%= article.user.username if article.user %>, | ||
<%= time_ago_in_words(article.created_at) %> ago, | ||
last updated: <%= time_ago_in_words(article.updated_at) %> ago | ||
</small> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="article-actions"> | ||
|
||
<%= link_to "Edit this article", edit_article_path(article), class: "btn btn-xs btn-primary" %> | ||
<%= link_to "Delete this article", article_path(article), method: :delete, | ||
|
||
data: { confirm: "Are you sure you want to delete the article?"}, | ||
|
||
class: "btn btn-xs btn-danger" %> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<% 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,49 +1,3 @@ | ||
<h1 align="center">Listing all articles</h1> | ||
|
||
<% @articles.each do |article| %> | ||
|
||
<div class="row"> | ||
|
||
<div class="col-xs-8 col-xs-offset-2"> | ||
|
||
<div class="well well-lg"> | ||
|
||
<div class="article-title"> | ||
|
||
<%= link_to article.title, article_path(article) %> | ||
|
||
</div> | ||
|
||
<div class="article-body"> | ||
|
||
<%= truncate(article.description, length: 100) %> | ||
<div class="article-meta-details"> | ||
|
||
|
||
<small> Created by: <%= article.user.username if article.user %>, | ||
<%= time_ago_in_words(article.created_at) %> ago, | ||
last updated: <%= time_ago_in_words(article.updated_at) %> ago | ||
</small> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="article-actions"> | ||
|
||
<%= link_to "Edit this article", edit_article_path(article), class: "btn btn-xs btn-primary" %> | ||
<%= link_to "Delete this article", article_path(article), method: :delete, | ||
|
||
data: { confirm: "Are you sure you want to delete the article?"}, | ||
|
||
class: "btn btn-xs btn-danger" %> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<% end %> | ||
<%= render 'article', obj: @articles %> |
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,43 @@ | ||
<%= render "shared/errors", obj: @user %> | ||
|
||
<div class="row"> | ||
<div class="col-xs-12"> | ||
|
||
<%= form_for(@user, :html => {class: "form-horizontal", row: "form"}) do |f| %> | ||
<div class="form-group"> | ||
<div class="control-label col-sm-2"> | ||
<%= f.label :username %> | ||
</div> | ||
<div class="col-sm-8"> | ||
<%= f.text_field :username, class: "form-control", placeholder: "Enter username", autofocus: true %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="control-label col-sm-2"> | ||
<%= f.label :email %> | ||
</div> | ||
<div class="col-sm-8"> | ||
<%= f.email_field :email, class: "form-control", placeholder: "Enter email" %> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="control-label col-sm-2"> | ||
<%= f.label :password %> | ||
</div> | ||
<div class="col-sm-8"> | ||
<%= f.password_field :password, class: "form-control", placeholder: "Enter password" %> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-10 col-sm-offset-2"> | ||
<%= f.submit 'Sign up', class: "btn btn-primary btn-lg" %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="col-xs-4 col-xs-offset-4"> | ||
[ <%= link_to "Cancel request and return to articles listing", articles_path %> ] | ||
</div> | ||
</div> | ||
</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,3 @@ | ||
<h1 align="center">Edit your account</h1> | ||
|
||
<%= render 'form' %> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<h1 align="center">Welcome to <%= @user.username %>'s page</h1> | ||
|
||
<div class="row"> | ||
|
||
<div class="col-md-4 col-md-offset-4 center"> | ||
|
||
<%= gravatar_for @user, size: 150 %> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<h4 align="center"><%= @user.username %>'s articles</h4> | ||
|
||
<%= render 'articles/article', obj: @user.articles %> |