Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 98 additions & 67 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</div>
<% end %>

<% is_me = @user.same_as?(current_user) %>
<div class="grid <%= deleted_user?(@user) ? 'deleted-content' : '' %>">
<div class="grid--cell is-9-lg is-12">
<div class="h-p-0 h-p-t-0">
Expand Down Expand Up @@ -56,7 +57,7 @@
</div>
<% end %>
<% end %>

<p>
<% if @user.discord.present? %>
<span class="h-m-r-4">
Expand All @@ -72,18 +73,19 @@
<% end %>
<% end %>
<% if current_user&.at_least_moderator? %>
<a href="<%= mod_user_path(@user) %>" class="button is-danger is-outlined is-small" data-drop="#mod-tools-drop"><i class="fas fa-shield-alt"></i> Moderator Tools <% if @user.community_user.mod_warnings&.size.positive? %> (<%= pluralize(@user.community_user.mod_warnings.count, 'message') %>) <% end %></a>
<a href="<%= mod_user_path(@user) %>" class="button is-danger is-outlined is-small" data-drop="#mod-tools-drop"><i class="fas fa-shield-alt"></i> Moderator Tools <% if @user.community_user.mod_warnings&.size.positive? %> (<%= pluralize(@user.community_user.mod_warnings.count, 'message') %>) <% end %></a>
<div class="droppanel" id="mod-tools-drop">
<div class="droppanel--header">quick actions</div>
<div class="droppanel--menu">
<a href="/users/<%= @user.id %>/mod/activity-log">full activity log</a>
<a href="/users/<%= @user.id %>/mod/annotations">annotations on user</a>
<a href="/users/<%= @user.id %>/mod/privileges">privileges</a>
<a href="/warning/log/<%= @user.id %>">warnings and suspensions sent to user
<% if @user.community_user.suspended? %><em>(includes lifting the suspension)</em>
<% elsif @user.community_user.mod_warnings&.size.positive? %>
(latest <%= time_ago_in_words(@user.community_user.latest_warning) %> ago)
<% end %></a>
<% if @user.community_user.suspended? %>
<em>(includes lifting the suspension)</em>
<% elsif @user.community_user.mod_warnings&.size.positive? %>
(latest <%= time_ago_in_words(@user.community_user.latest_warning) %> ago)
<% end %></a>
<a href="/warning/new/<%= @user.id %>">warn or suspend user</a>
</div>
<div class="h-m-t-6">
Expand Down Expand Up @@ -146,26 +148,39 @@
<td class="overflow-ellipsis" title="<%= @user.reputation %>"><%= @user.reputation %></td>
</tr>
<tr>
<td colspan="2"><i class="far fa-fw fa-comment-alt"></i> Number of top-level posts</td>
<td colspan="2"><i class="far fa-fw fa-comment-alt"></i> Top-level posts</td>
<td class="overflow-ellipsis" title="<%= @user.metric '1' %>"><%= @user.metric '1' %></td>
</tr>
<tr>
<td colspan="2"><i class="fas fa-fw fa-reply-all"></i> Number of answers</td>
<td colspan="2">
<i class="fas fa-fw fa-reply-all"></i>
<%= link_to search_path(search: "user:#{@user.id} post_type:2"),
'aria-label': is_me ? 'View your answers' : "View answers from #{rtl_safe_username(@user)}" do %>
Answers
<% end %>
</td>
<td class="overflow-ellipsis" title="<%= @user.metric '2' %>"><%= @user.metric '2' %></td>
</tr>
<tr>
<td colspan="2"><i class="fas fa-fw fa-star-half-alt"></i> Sum of received votes (up minus down)</td>
<td colspan="2"><i class="fas fa-fw fa-star-half-alt"></i>
<%= link_to is_me ? my_vote_summary_path : vote_summary_path,
'aria-label':
is_me ? 'View your received votes' : "View received votes for #{rtl_safe_username(@user)}" do %>
Received votes
<% end %>
<br>(up minus down)
</td>
<td class="overflow-ellipsis" title="<%= @user.metric 's' %>"><%= @user.metric 's' %></td>
</tr>
<tr>
<td colspan="2"><i class="fas fa-fw fa-pen"></i> Number of edits made</td>
<td colspan="2"><i class="fas fa-fw fa-pen"></i> Edits made</td>
<td class="overflow-ellipsis" title="<%= @user.metric 'E' %>"><%= @user.metric 'E' %></td>
</tr>
<% if current_user&.id == @user.id || current_user&.at_least_moderator? %>
<tr><td colspan="3">User since <%= @user.community_user.created_at %></td></tr>
<% if is_me || current_user&.at_least_moderator? %>
<tr><td colspan="3">Joined <%= @user.community_user.created_at %></td></tr>
<% end %>
</table>

<% unless @abilities.empty? %>
<h2>Earned Abilities</h2>

Expand All @@ -181,14 +196,10 @@
<% end %>
<% end %>
<div class="widget--footer">
<% if current_user&.id == @user.id %>
<%= link_to abilities_path, class: 'has-font-weight-bold', 'aria-label': 'View your abilities' do %>
Abilities &raquo;
<% end %>
<% else %>
<%= link_to abilities_path(for: @user.id), class: 'has-font-weight-bold', 'aria-label': "View abilities of #{rtl_safe_username(@user)}" do %>
Abilities &raquo;
<% end %>
<%= link_to is_me ? abilities_path : abilities_path(for: @user.id),
class: 'has-font-weight-bold',
'aria-label': is_me ? 'View your abilities' : "View abilities of #{rtl_safe_username(@user)}" do %>
Abilities &raquo;
<% end %>
</div>
</div>
Expand All @@ -203,25 +214,45 @@
<th colspan="3">Posts</th>
</tr>
<tr>
<td colspan="2">Count</td>
<td colspan="2">
<%= link_to user_posts_path,
'aria-label': is_me ? 'View your posts' : "View posts for #{rtl_safe_username(@user)}" do %>
Total
<% end %>
</td>
<td class="overflow-ellipsis" title="<%= @user.posts.undeleted.count %>">
<%= @user.posts.undeleted.count %>
</td>
</tr>
<tr>
<td colspan="2">Questions</td>
<td colspan="2">
<%= link_to search_path(search: "user:#{@user.id} post_type:1"),
'aria-label': is_me ? 'View your questions' : "View questions from #{rtl_safe_username(@user)}" do %>
Questions
<% end %>
</td>
<td class="overflow-ellipsis" title="<%= posts_for(posts_by_post_type, Question) %>">
<%= posts_for(posts_by_post_type, Question) %>
</td>
</tr>
<tr>
<td colspan="2">Answers</td>
<td colspan="2">
<%= link_to search_path(search: "user:#{@user.id} post_type:2"),
'aria-label': is_me ? 'View your answers' : "View answers from #{rtl_safe_username(@user)}" do %>
Answers
<% end %>
</td>
<td class="overflow-ellipsis" title="<%= posts_for(posts_by_post_type, Answer) %>">
<%= posts_for(posts_by_post_type, Answer) %>
</td>
</tr>
<tr>
<td colspan="2">Articles</td>
<td colspan="2">
<%= link_to search_path(search: "user:#{@user.id} post_type:5"),
'aria-label': is_me ? 'View your articles' : "View articles from #{rtl_safe_username(@user)}" do %>
Articles
<% end %>
</td>
<td class="overflow-ellipsis" title="<%= posts_for(posts_by_post_type, Article) %>">
<%= posts_for(posts_by_post_type, Article) %>
</td>
Expand All @@ -238,48 +269,48 @@
<th colspan="3">Votes cast</th>
</tr>
<tr>
<td colspan="2">Count</td>
<td colspan="2">Total</td>
<td class="overflow-ellipsis" title="<%= @user.votes.count %>"><%= @user.votes.count %></td>
</tr>
<% if @user.id == current_user&.id || current_user&.admin? %>
<tr>
<td colspan="2">
<div class="flex items-center gap-sm">
<svg class="has-color-tertiary-600" width="1em" height="0.67em" viewbox="0 0 100 50">
<path d="M50,0 L100,50 L0,50 Z" fill="currentColor" />
</svg>Upvotes
</div>
</td>
<td class="overflow-ellipsis" title="<%= votes_by_type[1] || 0 %>"><%= votes_by_type[1] || 0 %></td>
</tr>
<tr>
<td colspan="2">
<div class="flex items-center gap-sm">
<svg class="has-color-tertiary-600" width="1em" height="0.67em" viewbox="0 0 100 50">
<path d="M0,0 L100,0 L50,50 Z" fill="currentColor" />
</svg>Downvotes
</div>
</td>
<td class="overflow-ellipsis" title="<%= votes_by_type[-1] || 0 %>"><%= votes_by_type[-1] || 0 %></td>
</tr>
<tr>
<td colspan="2">on Question</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Question) %>">
<%= votes_for(votes_by_post_type, Question) %>
</td>
</tr>
<tr>
<td colspan="2">on Answer</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Answer) %>">
<%= votes_for(votes_by_post_type, Answer) %>
</td>
</tr>
<tr>
<td colspan="2">on Article</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Article) %>">
<%= votes_for(votes_by_post_type, Article) %>
</td>
</tr>
<% if is_me || current_user&.admin? %>
<tr>
<td colspan="2">
<div class="flex items-center gap-sm">
<svg class="has-color-tertiary-600" width="1em" height="0.67em" viewbox="0 0 100 50">
<path d="M50,0 L100,50 L0,50 Z" fill="currentColor" />
</svg>Upvotes
</div>
</td>
<td class="overflow-ellipsis" title="<%= votes_by_type[1] || 0 %>"><%= votes_by_type[1] || 0 %></td>
</tr>
<tr>
<td colspan="2">
<div class="flex items-center gap-sm">
<svg class="has-color-tertiary-600" width="1em" height="0.67em" viewbox="0 0 100 50">
<path d="M0,0 L100,0 L50,50 Z" fill="currentColor" />
</svg>Downvotes
</div>
</td>
<td class="overflow-ellipsis" title="<%= votes_by_type[-1] || 0 %>"><%= votes_by_type[-1] || 0 %></td>
</tr>
<tr>
<td colspan="2">on Questions</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Question) %>">
<%= votes_for(votes_by_post_type, Question) %>
</td>
</tr>
<tr>
<td colspan="2">on Answers</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Answer) %>">
<%= votes_for(votes_by_post_type, Answer) %>
</td>
</tr>
<tr>
<td colspan="2">on Articles</td>
<td class="overflow-ellipsis" title="<%= votes_for(votes_by_post_type, Article) %>">
<%= votes_for(votes_by_post_type, Article) %>
</td>
</tr>
<% end %>
</table>
<br>
Expand All @@ -288,9 +319,9 @@
<th colspan="3">Flags raised</th>
</tr>
<tr>
<td colspan="2">Count</td>
<td colspan="2">Total</td>
<td class="overflow-ellipsis" title="<%= @user.flags.count %>">
<% if current_user&.id == @user.id || at_least_moderator? %>
<% if is_me || at_least_moderator? %>
<%= link_to @user.flags.count, flag_history_path(@user.id), class: 'is-muted',
'aria-label': "View flag history for #{@user.flags.count} flags" %>
<% else %>
Expand Down