/
show.html.erb
135 lines (122 loc) · 5.34 KB
/
show.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<h4>
<% if @post.flagged? %>
<%= link_to post_flag_logs_path(@post), :style => "text-decoration:none" do %>
<span class="text-danger glyphicon glyphicon-flag" title="This post is a candidate for automatic flagging." href="#"></span>
<% end %>
<% end %>
<%= title @post.title %>
<% feedbacks = @post.feedbacks.to_a %>
<strong class="post-feedbacks">
<% feedbacks.each do |feedback| %>
<% next if (feedback.is_positive? && feedback.is_negative?) || (!feedback.is_positive? && !feedback.is_negative? && !feedback.is_naa?) %>
<span style="<%= "font-weight:normal" if feedback.is_naa? %>" data-toggle="tooltip" data-placement="top" title="<%= (feedback.user.present? || feedback.api_key_id.present?) ? "#{feedback.user.try(:username)} (From #{feedback.api_key.try(:app_name) || "Review"})" : feedback.user_name %>: <%= feedback.feedback_type %>" class="<%= element_class_for_feedback feedback %>"><%= element_symbol_for_feedback(feedback).html_safe %></span>
<% end %>
</strong>
<% unless feedbacks.empty? %>
<% if current_user.present? && (current_user.has_role?(:admin) || @post.feedbacks.where(:user_id => current_user.id).exists?) %>
<small>
<%= link_to "(clear)", clear_post_feedback_path(@post) %>
</small>
<% end %>
<small><a data-post-id="<%= @post.id %>" href="#" class="admin-report" data-no-turbolinks=true>(needs admin)</a></small>
<% end %>
</h4>
<p>
<strong>Add feedback:</strong>
<%= link_to raw('✓'), review_feedback_path(post_id: @post.id, feedback_type: 'tpu'),
class: 'feedback-button on-post text-success', remote: true, method: :post, data: { post_id: @post.id } %>
<%= link_to raw('✗'), review_feedback_path(post_id: @post.id, feedback_type: 'fp'),
class: 'feedback-button on-post text-danger', remote: true, method: :post, data: { post_id: @post.id } %>
<% if @post.link.nil? or @post.link.include? '/a/' %>
<%= link_to raw('💩'), review_feedback_path(post_id: @post.id, feedback_type: 'naa'), class: 'feedback-button on-post text-warning',
remote: true, method: :post, data: { post_id: @post.id } %>
<% end %>
</p>
<% unless @post.body.nil? %>
<div data-postid="<%= @post.id.to_s %>" class="post-body">
<hr>
<pre class="post-body-pre-block"><%= @post.body %></pre>
</div>
<% end %>
<hr>
<% unless @post.link.nil? %>
<% unless @post.site_logo.nil? %>
<%= image_tag @post.site_logo, size: "20" %>
<% end %>
<%= link_to "View on site", @post.link %>
<% if @post.deleted_at %>
<span class="text-danger">
(deleted
<span title="<%= (@post.deleted_at - @post.created_at).round(0) %> seconds">
<%= distance_of_time_in_words(@post.created_at, @post.deleted_at, include_seconds: true) %>
</span>
after being reported)
</span>
<% end %>
<% end %>
<% unless @post.created_at.nil? %>
<span class="text-muted" style="float:right">
<span title="<%= @post.created_at %>">
<%= "reported " + time_ago_in_words(@post.created_at).sub("about ", "") + " ago " %>
</span>
<% if @post.revision_count.to_i >= 2 %>
| edited <%= number_to_multiplicative_quantifier @post.revision_count - 1 %>
<% end %>
<% unless @post.user_link.nil? %>
| posted by
<% unless @post.site_logo.nil? %>
<%= link_to @post.user_link do %>
<%= image_tag @post.site_logo, size: "20" %>
<% end %>
<% end %>
<%= link_to @post.username, stack_exchange_user_path(@post.stack_exchange_user_id) if @post.stack_exchange_user_id.present? %>
<% unless @post.user_reputation.nil? %>
(<%= @post.user_reputation %>)
<% end %>
<% end %>
</span>
<% end %>
<hr>
<p>Caught by:</p>
<ul>
<% @post.reasons.each do |reason| %>
<li><%= link_to reason.reason_name, "/reason/" + reason.id.to_s %> <span class="text-muted">(<%= reason.weight %>)</span></li>
<% end %>
</ul>
<% if @post.reason_weight.present? %>
<p class="text-muted">Reason weight: <%= @post.reason_weight %></p>
<% end %>
<% if @post.why.present? %>
<pre><%= render_links @post.why %></pre>
<% end %>
<% if user_signed_in? && current_user.api_token.present? && !@post.is_fp && !@post.is_deleted? && Time.now - (@post.created_at || 1.day.ago) <= 1.hour && current_user.has_role?(:reviewer) %>
<p>
<%= link_to url_for(:controller => :posts, :action => :cast_spam_flag, :id => @post.id), :method => :post, :class => "text-danger" do %>
<span class="glyphicon glyphicon-flag"></span> Spam flag
<% end %>
</p>
<% end %>
<hr/>
<p>Contains domains:</p>
<% if @post.spam_domains.any? %>
<ul>
<% @post.spam_domains.each do |d| %>
<li><%= render 'spam_domains/domain', domain: d %></li>
<% end %>
</ul>
<% else %>
<em>No domains</em>
<% end %>
<% if user_signed_in? && current_user.has_role?(:developer) %>
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Developer tools</h3>
</div>
<div class="panel-body">
<ul>
<li><%= link_to "Update feedback cache", url_for(:controller => :posts, :action => :reindex_feedback, :id => @post.id), :method => :post %></li>
<li><%= link_to "Delete post", dev_delete_post_path(@post.id), method: :post, data: { confirm: "Are you sure you want to delete this post? This can't be undone." } %></li>
</ul>
</div>
</div>
<% end %>