indentlabs/notebook

View on GitHub
app/views/users/profile/_recent_activity.html.erb

Summary

Maintainability
Test Coverage
<%# todo this looks like an unused partial %>
<% if @stream.any? && !@user.blocked_by?(current_user)  %>
  <% @stream.each do |entity| %>
    <% next unless User.new.can_read?(entity) || (user_signed_in? && current_user.can_read?(entity)) %>
    <div class="hoverable card horizontal" style="border: 1px solid <%= entity.class.hex_color %>">
      <div class="card-image <%= entity.class.color %>" style="overflow: hidden">
        <%= image_tag entity.first_public_image(format: :large), style: 'max-width: 280px; object-fit: cover; min-height: 100%' %>
      </div>
      <div class="card-stacked">
        <div class="card-content">
          <% if user_signed_in? && current_user.id == entity.user_id %>
            <span class="right">
              <% if !User.new.can_read?(entity) %>
                <i class="material-icons tooltipped grey-text"
                  data-tooltip="This page is only visible to you and your collaborators."
                  >visibility_off</i>
              <% else %>
                <i class="material-icons tooltipped black-text"
                  data-tooltip="This page is visible to anyone with the link."
                  >visibility</i>
              <% end %>
            </span>
          <% end %>
          <h5 style="margin-top: 0">
            <i class="material-icons <%= entity.class.text_color %> left" style="position: relative; top: 3px">
              <%= entity.class.icon %>
            </i>
            <%= ContentFormatterService.show(text: entity.name, viewing_user: current_user) %>
            <% if entity.description.present? %>
              <small class="grey-text"><%= entity.description %></small>
            <% end %>
          </h5>
          <p>
            <%= link_to @user.name, @user, class: "#{User.text_color}" %>
            updated a<%= 'n' if %(a e i o u).include?(entity.class.name.downcase.first) %>
            <%= entity.class.name.downcase %>
            <% if !entity.is_a?(Universe) && entity.universe.present? %>
              in the
              <%= link_to entity.universe.name, entity.universe, class: "#{Universe.text_color}" %>
              universe
            <% end %>
            <span class="grey-text"><%= time_ago_in_words(entity.updated_at) %> ago</span>.
          </p>
        </div>
        <div class="card-action">
          <%= link_to "View #{entity.class.name}", entity, class: 'blue-text' %>
          <% if user_signed_in? && current_user.can_update?(entity) %>
            <%= link_to "Edit #{entity.class.name}", entity, class: 'green-text' %>
          <% end %>
        </div>
      </div>
    </div>
  <% end %>
<% else %>
  <% if user_signed_in? && @user.blocked_by?(current_user) %>
    <div class="grey-text">
      You've blocked this user.
    </div>
  <% else %>
    <div class="grey-text">
      It seems <%= @user.name %> isn't sharing any public activity.
    </div>
  <% end %>

<% end %>