notebook/app/views/users/show.html.erb
2018-12-18 18:24:14 -06:00

151 lines
6.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script type="application/ld+json">
<%
set_meta_tags title: @user.name,
description: "#{@user.name}s profile on Notebook.ai",
image_src: @user.image_url(120)
content_jsonld = {
'@id': user_url,
'@type': 'http://schema.org/Person',
'http://schema.org/name': @user.name,
'http://schema.org/description': "#{@user.name}s profile on notebook.ai",
'https://schema.org/image': @user.image_url(120)
}
%>
<%= content_jsonld.to_json.html_safe %> %>
</script>
<div class="row">
<div class="col s12">
<h3>
<% if user_signed_in? && current_user.id == @user.id %>
<span style="float: right; font-size: 50%; margin-top: 0;" class="card">
<%= link_to 'Edit your profile', edit_user_registration_path(current_user), style: 'padding: 0 10px;', class: 'waves-effect' %>
</span>
<% end %>
<%= @user.name %>
<% if @user.username.present? %>
<small class="grey-text">
<%= link_to "@#{@user.username}", thredded_path %>
</small>
<% end %>
</h3>
</div>
</div>
<div class="row">
<div class="col s12 m3 l3">
<div class="card hoverable">
<div class="card-image waves-effect waves-block waves-light">
<%= image_tag @user.image_url(250).html_safe, class: 'activator', style: 'width: 100%' %>
</div>
<% if user_signed_in? && current_user == @user %>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4"><i class="material-icons right">close</i></span>
<p>Profile pictures are powered by <%= link_to 'Gravatar', 'https://gravatar.com/', target: "_blank" %>, using the email you provided in your <%= link_to 'account settings', edit_user_registration_path %>.</p>
<p>For the prettiest profile, please use an avatar at least 250 pixels wide.</p>
</div>
<% end %>
</div>
<% if @content.any? %>
<div class="collection with-header hoverable">
<div class="collection-header blue lighten-1 white-text">
<div style="padding: 5px 10px">
Public pages
</div>
</div>
<% @tabs.each do |tab| %>
<% content_type_class = @user.send(tab).build.class %>
<%= link_to send("#{tab}_user_path"), class: "collection-item #{content_type_class.color}-text" do %>
<%= pluralize @content[tab].length, tab.to_s.singularize %>
<span class="secondary-content">
<i class="material-icons <%= content_type_class.color %>-text"><%= content_type_class.icon %></i>
</span>
<% end %>
<% end %>
</div>
<% end %>
<% if user_signed_in? && current_user != @user %>
<div class="collection with-header hoverable">
<div class="collection-header blue lighten-1 white-text">
<div style="padding: 5px 10px">
Actions
</div>
</div>
<%= link_to Thredded::UrlsHelper.send_private_message_path(current_user: current_user, to: @user), class: 'collection-item' do %>
Send a message
<span class="secondary-content">
<i class="material-icons black-text">forum</i>
</span>
<% end %>
</div>
<% end %>
</div>
<div class="col s12 m9 l9">
<% if @stream.any? %>
<div class="row">
<div class="col s12">
<h5 style="text-align: center" class="grey-text">Recent activity</h5>
<section id="cd-timeline" class="cd-container timeline-container">
<% @stream.each do |entity_id, change_events| %>
<% change_event = change_events.first %>
<% next unless change_event.present? && change_event.content.present? %>
<%
if change_event.content_type == 'Attribute'
content_type_class = change_event.content.entity_type.constantize
content = content_type_class.find_by(id: change_event.content.entity_id)
else
content_type_class = change_event.content_type.constantize
content = content_type_class.find_by(id: change_event.content_id)
end
%>
<% next if content.nil? %>
<% next unless content.readable_by?(user_signed_in? ? current_user : User.new) %>
<div class="cd-timeline-block">
<div class="cd-timeline-img <%= content_type_class.color %>">
<i class="material-icons white-text"><%= content_type_class.icon %></i>
</div>
<div class="cd-timeline-content card hoverable">
<div class="card-content <%= content_type_class.color %> grey-text text-lighten-2">
<%= link_to content.name, content, class: 'white-text' %>
</div>
<% if content.description.present? %>
<div class="card-content">
<%= truncate(content.description, length: 300) %>
</div>
<% end %>
<% if content.respond_to?(:universe_id) && content.universe_id.present? && content.universe_id > 0 %>
<div class="card-content">
<i class="material-icons <%= Universe.color %>-text" style="font-size: 100%; position: relative; top: 2px">
<%= Universe.icon %>
</i>
<%= link_to content.universe.name, content.universe %>
</div>
<% end %>
<div class="card-content grey lighten-3 grey-text text-darken-1">
<i class="material-icons" style="font-size: 100%; position: relative; top: 2px">access_time</i>
<%= change_event.action %>
<%= time_ago_in_words change_event.created_at %> ago
</div>
<span class="cd-date">
<!-- offset text -->
</span>
</div>
</div>
<% end %>
</section>
</div>
</div>
<% else %>
It seems <%= @user.name %> isn't sharing any public activity.
<% end %>
</div>
</div>