docbrown/app/views/notifications/_article.html.erb
2019-04-29 09:58:29 -04:00

62 lines
3.3 KiB
Text

<% if notification.action == "Reaction" %>
<%= render "reaction", notification: notification %>
<% elsif notification.action.include? "Milestone" %>
<%= render "milestone", notification: notification %>
<% else %>
<% json_data = notification.json_data %>
<% if json_data["organization"] %>
<div class="article-organization-headline">
<a class="org-headline-filler" href="<%= json_data["organization"]["path"] %>">
<span class="article-organization-headline-inner">
<img alt="<%= json_data["organization"]["name"] %> logo" src="<%= json_data["organization"]["profile_image_90"] %>">
<%= json_data["organization"]["name"] %>
</span>
</a>
</div>
<% end %>
<% cache "activity-profile-pic-#{json_data['user']['id']}-#{json_data['user']['profile_image_90']}" do %>
<a href="<%= json_data["user"]["path"] %>" class="small-pic-link-wrapper">
<div class="small-pic">
<img src="<%= json_data["user"]["profile_image_90"] %>" alt="link to <%= json_data["user"]["username"] %>'s profile">
</div>
</a>
<% end %>
<div class="content notification-content article-content">
<% cache "activity-published-article-#{json_data['article']['id']}-#{json_data['article']['updated_at']}" do %>
<a href="<%= json_data["user"]["path"] %>">
<%= json_data["user"]["name"] %>
</a>
made a new post<%= ":" unless json_data["organization"] %>
<% if json_data["organization"] %>
under <a href="<%= json_data["organization"]["path"] %>"><%= json_data["organization"]["name"] %></a>:
<% end %>
<div>
<small><%= time_ago_in_words notification.created_at %> ago</small>
</div>
<a href="<%= json_data["article"]["path"] %>">
<div class="notification-new-post">
<div class="notification-new-post-title">
<%= sanitize(json_data["article"]["title"]) %>
</div>
<div class="notification-new-post-tags">
<% json_data["article"]["cached_tag_list_array"].each do |tag| %>
#<%= tag %>
<% end %>
</div>
</div>
</a>
<% end %>
<% cache "activity-published-article-reactions-#{@last_user_reaction}-#{json_data['article']['updated_at']}-#{json_data['article']['id']}" do %>
<div class="comment-actions">
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(notification.mocked_object("article"), current_user, "like") ? "reacted" : "" %>" data-reactable-id="<%= json_data["article"]["id"] %>" data-category="like" data-reactable-type="Article">
<%= image_tag "favorite-heart-outline-button.svg" %>
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-heart.png") %>" />
</button>
<button class="reaction-button readinglist-button <%= Reaction.cached_any_reactions_for?(notification.mocked_object("article"), current_user, "readinglist") ? "reacted" : "" %>" data-reactable-id="<%= json_data["article"]["id"] %>" data-category="readinglist" data-reactable-type="Article">
<span class="reaction-button-text">SAVE</span>
<img class="reacted-emoji reaction-button-reacted-emoji" src="<%= asset_path("readinglist-button.png") %>" />
</button>
</div>
<% end %>
</div>
<% end %>