journalduhacker/app/views/stories/_listdetail.html.erb
joshua stein 9535b05490 remove story downvoting, add story hiding
stories should either be reported for spam (coming later), upvoted,
or left alone rather than being downvoted for being uninteresting.
since users don't like leaving uninteresting things alone, they can
now hide stories from their view without affecting the story's
score.

hiding is implemented as a Vote with its vote set to 0 and the
reason set to "H"

add a /hidden url which shows all of a user's hidden stories

while i'm here, simplify Vote guts and add some tests to make sure
all the flip-flopping stuff works right
2014-03-03 17:20:21 -06:00

92 lines
3.4 KiB
Plaintext

<li id="story_<%= story.short_id %>" data-shortid="<%= story.short_id %>"
class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
"downvoted" : "" %> <%= story.vote == 0 ? "hidden" : "" %> <%= story.is_expired? ?
"expired" : "" %>">
<div class="story_liner">
<div class="voters">
<% if @user %>
<a class="upvoter"></a>
<% else %>
<%= link_to "", login_url, :class => "upvoter" %>
<% end %>
<div class="score"><%= story.score %></div>
</div>
<div class="details">
<span class="link">
<% if story.can_be_seen_by_user?(@user) %>
<a href="<%= story.url_or_comments_url %>"><%= story.title %></a>
<% end %>
<% if story.is_gone? %>
[Story removed by <%= story.is_moderated? ? "moderator" :
"original submitter" %>]
<% end %>
</span>
<% if story.can_be_seen_by_user?(@user) %>
<span class="tags">
<% story.taggings.sort_by{|t| t.tag.tag }.sort_by{|t|
t.tag.tag == "pdf" ? -1 : 0 }.each do |tagging| %>
<a href="<%= tag_url(tagging.tag.tag) %>"
class="<%= tagging.tag.css_class %>"
title="<%= tagging.tag.description %>"><%= tagging.tag.tag %></a>
<% end %>
</span>
<span class="domain"><%= story.domain %></span>
<% end %>
<div class="byline">
<% if story.previewing %>
by <a><%= story.user.username %></a>
just now
<% else %>
by <a href="/u/<%= story.user.username %>"><%= story.user.username
%></a> <%= raw(time_ago_in_words_label(story.created_at).
gsub(/^about /, "")) %> ago
<% if story.is_editable_by_user?(@user) %>
|
<a href="<%= edit_story_url(story.short_id) %>">edit</a>
<% if story.is_gone? && story.is_undeletable_by_user?(@user) %>
|
<%= link_to "undelete", story_undelete_url(story.short_id),
:method => :post, :data => {
:confirm => "Are you sure you want to undelete this story?" } %>
<% elsif !story.is_gone? %>
|
<% if story.user_id != @user.try(:id) &&
@user.try(:is_moderator?) %>
<%= link_to "delete", story_url(story.short_id),
:method => :delete, :class => "mod_story_link" %>
<% else %>
<%= link_to "delete", story_url(story.short_id),
:method => :delete, :data => {
:confirm => "Are you sure you want to delete this story?" } %>
<% end %>
<% end %>
<% end %>
<% if !story.is_gone? && @user %>
<% if story.vote == 0 %>
| <%= link_to "unhide", story_unhide_url(story.short_id),
:class => "hider" %>
<% else %>
| <%= link_to "hide", story_hide_url(story.short_id),
:class => "hider" %>
<% end %>
<% end %>
<% if !story.is_gone? && (@user || story.comments_count > 0) %>
<span class="comments_label">
|
<a href="<%= story.comments_url %>"><%= story.comments_count == 0 ?
"discuss" : "#{story.comments_count} comment" <<
(story.comments_count == 1 ? "" : "s") %></a>
</span>
<% end %>
<% end %>
</div>
</div>
</div>
<div class="mobile_comments <%= story.comments_count == 0 ? "zero" : "" %>"
style="display: none;">
<a href="<%= story.comments_url %>"><%= story.comments_count %></a>
</div>
</li>