Noosfero/noosfero

View on GitHub
app/views/profile/index.html.erb

Summary

Maintainability
Test Coverage
<h1><%= h profile.name %></h1>

<% if @action %>
  <%= render :partial => 'private_profile' %>
<% else %>
  <% unless profile.description.blank? %>
    <div class='public-profile-description'>
      <%= raw profile.description %>
    </div>
  <% end %>
  <div id='public-profile-search'>
    <%= render :partial => 'shared/profile_search_form' %>
  </div>
<% end %>

<% if @profile.display_to?(user) %>
  <div class='profile'>
    <% plugins_tabs = @plugins.dispatch(:profile_tabs).map do |tab| %>
          <% title = tab.has_key?(:icon) ? font_awesome(tab[:icon], tab[:title]) : tab[:title] %>
          <% {:title => title, :id => tab[:id], :content => instance_exec(&tab[:content]), :start => tab[:start]}  %>
    <% end %>

    <% tabs = plugins_tabs.select { |tab| tab[:start] } %>
    <% if @profile.organization?
         kind = 'organization-profile'
    elsif @profile.person?
      kind = 'person-profile'
    else
      kind = 'profile'
    end %>

    <% if logged_in? %>
      <% tabs << { title: font_awesome(:rss, _('Wall')), id: 'profile-wall', content: (render partial: 'profile_wall') } if @profile.display_to?(user, :wall) %>
      <% tabs << { title: font_awesome(:network, _('Network')), id: 'profile-network', content: (render partial: 'profile_network') } if @profile == user %>
    <% end %>
    <% profile_type = @profile.type == 'Person' ? 'User' : @profile.type %>
    <% information_tab = _('Profile Info') %>
    <% tabs << { title: font_awesome(:info, _(information_tab)), id: kind, content: (render partial: kind.gsub('-', '_')) } %>

    <% tabs += plugins_tabs.select { |tab| !tab[:start] } %>

    <%= render_tabs(tabs) %>
  </div>
<% end %>