Skip to content

Commit

Permalink
Profile page : Add topic Cards for profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
CleverFool77 committed Jul 23, 2019
1 parent 799b3ea commit 6b886ce
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 101 deletions.
42 changes: 42 additions & 0 deletions app/views/tag/_profileCard.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

<div class="card-view">
<% @profile_user.tags.each do |tag| %>
<div class="card shadow-sm p-2 mb-3 bg-white rounded" >
<div class="card-header mt-2" style=" padding:0.8em; background-color: inherit; border:none;">
<h4 style="display: inline-block;"><%= tag.name %></h3>
<p style="display: inline-block; color: #808080;"><a style="text-decoration: underline; color: #808080;" href="/tag/<%= tag.name %>"><%= Tag.follower_count(tag.name) %> people</a> discussing</p>
</div>
<div class="card-body" style="padding:0.8em;">
<div>
<% Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).each do |node| %>
<div>
<% if node.author.name == @profile_user.name %>
<% if node.main_image %>
<img class="rounded-circle" id="profile-photo" style="width:20px; height:20px; margin-right:8px; display: inline-block;" src="<%= node.main_image.path(:default) %>" />
<% elsif node.scraped_image %>
<img class="rounded-circle" id="profile-photo" style="width:20px; height:20px; margin-right:8px; display: inline-block;" src="<%= node.scraped_image %>" />
<% end %>
<p style="display: inline-block;"><a style="color: inherit;" <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><%= (node.type == 'note') ? node.title : node.latest.title %></a></p>
<p style="display: inline-block; margin-left: 10px;color: #808080;">by <a style="color: #808080;" <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.author.name %>">@<%= node.author.name %></a></p>
<% end %>
</div>
<% end %>
</div>
</div>
<div class="card-footer" style="background-color: inherit; border:none;">
<a style="text-decoration: underline; color: #808080; display: inline-block;" href="/tag/<%= tag.name %>"><%= tag.count %> <%= t('tag.index.more_posts') %> <i class="fa fa-angle-double-right"></i></a>

<a style="float: right; width: 100px;" rel="tooltip" title="<%= t('sidebar._post_button.share_your_work') %>" data-placement="bottom" href="/post?tags=<%= tag.name %>" class="btn btn-primary btn-sm">New post <i class="fa fa-plus fa-white"></i></a>
<% if current_user %>
<div id="follow-unfollow-column-<%=tag.tid%>" style="float: right; margin-right: 10px;">
<% if current_user.following(tag.name) %>
<a style="width: 100px;" rel="tooltip" title="<%= t('tag.show.unfollow') %>" class="btn btn-light btn-sm active" href="/unsubscribe/tag/<%= tag.name %>"></i> <%= t('tag.index.unsubscribe') %></a>
<% else %>
<a style="width: 100px;" class="btn btn-outline-secondary btn-sm index-follow-buttons follow-btn-remote" href="/subscribe/tag/<%= tag.name %>" data-remote="true"><%= t('tag.index.subscribe') %></a>
<% end %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
93 changes: 3 additions & 90 deletions app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,110 +28,23 @@
</div>
<hr />

<br>

<ul class="nav nav-tabs">
<li class="nav-item"><a class="nav-link active" href="#research" data-toggle="tab"><i class="fa fa-file"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.research') %></span><% if current_user && current_user.uid == @profile_user.uid %> <%= "(#{@notes.count + @coauthored.count + @drafts.count })" %><% else %><%= "(#{ @notes.count + @coauthored.count })" %><% end %></a></li>
<li class="nav-item"><a class="nav-link" href="#questions" data-toggle="tab"><i class="fa fa-question-circle"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.questions') %></span> (<%= Node.questions.where(status: 1, uid: @profile_user.id).length %>)</a></li>
<li class="nav-item"><a class="nav-link" href="#comments" id="comments-tab" data-toggle="tab"><i class="fa fa-comment"></i><span class="hidden-sm hidden-xs"> Comments</span> (<%= @comment_count %>)</a></li>
<li class="nav-item"><a class="nav-link" href="#likes" data-toggle="tab"><i class="fa fa-star"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.liked') %></span> (<%= @likes.count %>)</a></li>
<li class="nav-item"><a class="nav-link" href="#barnstars" data-toggle="tab"><i class="fa fa-certificate"></i><span class="hidden-sm hidden-xs"> Barnstars</span> (<%= @profile_user.try(:barnstars).try(:length) %>)</a></li>
</ul>

<br />

<div class="tab-content">

<div class="tab-pane active" id="research">
<div class="btn-group text-center" style="margin-bottom:10px;">
<ul class="nav nav-tabs">
<li class="nav-item" style="list-style-type:none;">
<a href="#notes" class="btn btn-outline-secondary" data-toggle="tab">Authored <%= "(#{ @notes.count })" %></a>
<li class="nav-item" style="list-style-type:none;">
<a href="#coauthored" class="btn btn-outline-secondary" data-toggle="tab">Coauthored <%= "(#{ @coauthored.count })" %></a>
<li class="nav-item" style="list-style-type:none;">
<% if current_user && current_user.uid == @profile_user.uid %>
<a href="#draft" class="btn btn-outline-secondary" data-toggle="tab">Drafts <%= "(#{ @drafts.count })" %></a><% end %>
</ul>
</div>
<%= render :partial => "tag/profileCard" %>

<br />

<div class="tab-content">
<div class="tab-pane active" id="notes">
<%= render :partial => "notes/notes" %>
</div>

<div class="tab-pane" id="coauthored">
<%= render :partial => "notes/coauthored_notes" %>
</div>
<div class="text-center"> <%= will_paginate @tags, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer if @paginated %></div>

<% if current_user && current_user.uid == @profile_user.uid %>
<div class="tab-pane" id="draft">
<%= render :partial => "notes/draft_notes" %>
</div>
<% end %>
</div>
</div>

<div class="tab-pane" id="questions">
<div class="btn-group text-center">
<a href="#asked" class="btn btn-outline-secondary" data-toggle="tab">Asked</a>
<a href="#answered" class="btn btn-outline-secondary" data-toggle="tab">Commented</a>
</div>

<div class="tab-content">
<div class="tab-pane active" id="asked">
<%= render :partial => "questions/questions" %>
</div>

<div class="tab-pane" id="answered">
<%= render :partial => "users/answered" %>
</div>
</div>
</div>

<div class="tab-pane" id="maps">
<p><i><%= raw t('users.profile.view_these_maps', :url1 => "//mapknitter.org/profile/"+@profile_user.name) %></i></p>
<table class="table">
<tr>
<th style="width:200px;"><%= t('users.profile.title') %></th>
<th style="width:200px;"><%= t('users.profile.creation_date') %></th>
<th><%= t('users.profile.image') %></th>
</tr>
</table>
</div>

<div class="tab-pane" id="comments">
<%= render partial: 'comments/comments', locals: { comments: current_user &.can_moderate? ? @all_comments : @normal_comments } %>
</div>

<div class="tab-pane" id="likes">
<%= render :partial => "users/likes" %>
</div>

<div class="tab-pane" id="barnstars">
<% @profile_user.barnstars.each do |tag| %>
<p style="color:#aaa;"><i style="color:#db4;" class="fa fa-large fa fa-star-o"></i> <i><%= raw t('users.profile.barnstar_awarded_to_by', :url1 => "/profile/"+tag.node.author.name, :author => tag.node.author.name, :url2 => "/wiki/barnstars#"+tag.name.split(':').last.split('-').each{|w| w.capitalize!}.join('+'), :barnstar => tag.name.split(':').last.split('-').each{|w| w.capitalize!}.join(' '), :url3 => "/profile/"+tag.author.username, :awarder => tag.author.username, :url4 => tag.node.path, :work => tag.node.title) %></i></p>
<hr />
<% end %>
</div>
</div>

<hr />


</div>

<<<<<<< 27c6f423494aa7fc19ea0463f9c5bf0a45bf9a11
<div class="col-lg-3">
<img class="d-none d-lg-inline rounded-circle" id="profile-photo" style="width:100%;margin-bottom:10px;" src="<%= @profile_user.profile_image %>" />
=======
<div class="col-lg-1">
</div>

<div class="col-lg-4">
<img class="d-none d-lg-inline rounded-circle" id="profile-photo" style="width:100%;margin-bottom:10px;" src="<%= @profile_user.profile_image %>" />
>>>>>>> Profile page : Chnage col spans and bring map to top-left
<div style="text-align:center;" class="d-lg-none">
<img class="rounded-circle" id="profile-photo" style="width:50%;margin-bottom:20px;" src="<%= @profile_user.photo_path %>" />
</div>
Expand Down
11 changes: 0 additions & 11 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,6 @@ def setup
end
end

test 'should list notes and questions in user profile' do
user = users(:jeff)
get :profile, params: { id: user.username }
assert_not_nil assigns(:notes)
assert_not_nil assigns(:questions)
selector = css_select '#asked .note-question'
assert_equal selector.size, 2
selector = css_select '#answered .note-answer'
assert_equal selector.size, 1
end

test 'should get comments and render comments/index template' do
user = users(:jeff)
get :comments, params: { id: user.id }
Expand Down

0 comments on commit 6b886ce

Please sign in to comment.