journalduhacker/app/views/stories/_listdetail.html.erb
joshua stein 61b08c7dee story list detail: flip flop again, show 'no comments' for non-users
I've changed this a few times because I didn't want to show
"discuss" to non-users, but they at least need a link to the story
to copy, so show a link with "no comments" to them.
2016-02-02 11:56:10 -06:00

198 lines
7.3 KiB
Plaintext

<li id="story_<%= story.short_id %>" data-shortid="<%= story.short_id %>"
class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
<%= story.vote && story.vote[:vote] == -1 ? "downvoted" : "" %>
<%= story.score <= -1 ? "negative_1" : "" %>
<%= story.score <= -3 ? "negative_3" : "" %>
<%= story.score <= -5 ? "negative_5" : "" %>
<%= story.is_hidden_by_cur_user ? "hidden" : "" %>
<%= story.is_expired? ? "expired" : "" %>">
<div class="story_liner">
<div class="voters">
<% if @user %>
<a class="upvoter"></a>
<% else %>
<%= link_to "", login_path, :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_path %>"><%=
break_long_words(story.title) %></a>
<% end %>
<% if story.is_gone? %>
[Story removed by <%= story.is_moderated? ? "moderator" :
"original submitter" %>]
<% end %>
</span>
<% if story.markeddown_description.present? %>
<a class="description_present" title="Additional text available"
href="<%= story.comments_path %>">&#x2636;</a>
<% end %>
<% if story.can_be_seen_by_user?(@user) %>
<span class="tags">
<% story.sorted_taggings.each do |tagging| %>
<a href="<%= tag_path(tagging.tag.tag) %>"
class="<%= tagging.tag.css_class %>"
title="<%= tagging.tag.description %>"><%= tagging.tag.tag %></a>
<% end %>
</span>
<% if story.domain.present? %>
<a class="domain" href="<%= story.domain_search_url %>"><%=
break_long_words(story.domain) %></a>
<% end %>
<% if defined?(single_story) && single_story %>
<% story.merged_stories.each do |ms| %>
<br>
<span class="merge"></span>
<span class="link">
<a href="<%= ms.url_or_comments_path %>"><%=
break_long_words(ms.title) %></a>
</span>
<span class="tags">
<% ms.sorted_taggings.each do |tagging| %>
<a href="<%= tag_path(tagging.tag.tag) %>"
class="<%= tagging.tag.css_class %>"
title="<%= tagging.tag.description %>"><%= tagging.tag.tag %></a>
<% end %>
</span>
<% if ms.domain.present? %>
<a class="domain" href="<%= ms.domain_search_url %>"><%=
break_long_words(ms.domain) %></a>
<% end %>
<span class="byline">
<% if (@user && @user.show_avatars?) || !@user %>
<a href="/u/<%= ms.user.username %>"><img
src="<%= ms.user.avatar_url(16) %>"
srcset="<%= ms.user.avatar_url(16) %> 1x,
<%= ms.user.avatar_url(32) %> 2x" class="avatar"></a>
<% end %>
<% if story.user_is_author? %>
authored by
<% else %>
via
<% end %>
<a href="/u/<%= ms.user.username %>" class="<%=
ms.html_class_for_user %>"><%= ms.user.username %></a>
<%= time_ago_in_words_label(ms.created_at, :strip_about => true) %>
</span>
<% end %>
<% end %>
<% end %>
<% if !(defined?(single_story) && single_story) && @user &&
@user.show_story_previews? %>
<% if (sc = story.description_or_story_cache(500)).present? %>
<div class="story_content">
<%= break_long_words(sc) %>
</div>
<% end %>
<% end %>
<div class="byline">
<% if (@user && @user.show_avatars?) || !@user %>
<a href="/u/<%= story.user.username %>"><img
src="<%= story.user.avatar_url(16) %>"
srcset="<%= story.user.avatar_url(16) %> 1x,
<%= story.user.avatar_url(32) %> 2x" class="avatar"></a>
<% end %>
<% if story.previewing %>
<% if story.user_is_author? %>
authored by
<% else %>
via
<% end %>
<a class="<%= story.html_class_for_user %>"><%=
story.user.username %></a>
just now
<% else %>
<% if story.user_is_author? %>
authored by
<% else %>
via
<% end %>
<a href="/u/<%= story.user.username %>" class="<%=
story.html_class_for_user %>"><%= story.user.username %></a>
<%= time_ago_in_words_label(story.created_at, :strip_about => true) %>
<% if story.is_editable_by_user?(@user) %>
|
<a href="<%= edit_story_path(story.short_id) %>">edit</a>
<% if story.is_gone? && story.is_undeletable_by_user?(@user) %>
|
<%= link_to "undelete", story_undelete_path(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_path(story.short_id),
:method => :delete, :class => "mod_story_link" %>
<% else %>
<%= link_to "delete", story_path(story.short_id),
:method => :delete, :data => {
:confirm => "Are you sure you want to delete this story?" } %>
<% end %>
<% end %>
<% end %>
<% if story.can_have_suggestions_from_user?(@user) %>
| <%= link_to "suggest", story_suggest_path(story.short_id),
:class => "suggester" %>
<% end %>
<% if !story.is_gone? && @user %>
<% if @user && story.vote && story.vote[:vote] == -1 %>
| <a class="flagger">unflag (<%=
Vote::STORY_REASONS[story.vote[:reason]].to_s.downcase %>)</a>
<% elsif @user && @user.can_downvote?(story) %>
| <a class="flagger">flag</a>
<% end %>
<% if story.is_hidden_by_cur_user %>
| <%= link_to "unhide", story_unhide_path(story.short_id),
:class => "hider" %>
<% else %>
| <%= link_to "hide", story_hide_path(story.short_id),
:class => "hider" %>
<% end %>
<% if defined?(single_story) && single_story && story.hider_count > 0 %>
(hidden by <%= pluralize(story.hider_count, "user") %>)
<% end %>
<% end %>
<% if !story.is_gone? %>
<span class="comments_label">
|
<a href="<%= story.comments_path %>">
<% if story.comments_count == 0 %>
<% if @user %>
discuss
<% else %>
no comments
<% end %>
<% else %>
<%= story.comments_count %>
comment<%= story.comments_count == 1 ? "" : "s" %>
<% end %>
</a>
</span>
<% end %>
<% if defined?(single_story) && single_story &&
((story.downvotes > 0 && @user && @user.is_moderator?) ||
(story.downvotes >= 3 || story.score <= 0)) %>
| <%= story.vote_summary_for(@user).downcase %>
<% end %>
<% end %>
</div>
</div>
</div>
<div class="mobile_comments <%= story.comments_count == 0 ? "zero" : "" %>"
style="display: none;">
<a href="<%= story.comments_path %>"><%= story.comments_count %></a>
</div>
</li>