NARKOZ/ginatra

View on GitHub
views/stats.erb

Summary

Maintainability
Test Coverage
<% title @repo.name, headline: 'Stats' %>

<div class="row">
  <div class="col-md-12">
    <div class="row">
      <div class="col-md-8">
        <ul class="nav nav-pills">
          <li>
            <a href="<%= prefix_url(@repo.param) %>/<%= params[:ref] %>">Commits</a>
          </li>
          <li>
            <a href="<%= prefix_url(@repo.param) %>/tree/<%= params[:ref] %>">Source</a>
          </li>
          <li class="active">
            <a href="<%= prefix_url(@repo.param) %>/stats/<%= params[:ref] %>">Stats</a>
          </li>
        </ul>

        <ul class="list-unstyled">
          <li>
            <strong>License:</strong>
            <span class="label label-info"><%= @stats.license %></span>
          </li>
          <li>
            <strong>Commits:</strong>
            <%= @stats.commits_count %>
          </li>
          <li>
            <strong>Created at:</strong>
            <%= time_tag @stats.created_at %>
          </li>
        </ul>

        <h3>Contributors (<%= @stats.contributors.size %>)</h3>

        <table class="table table-striped table-bordered table-hover">
          <thead>
            <tr>
              <th>Email</th>
              <th>Author</th>
              <th>Commits</th>
            </tr>
          </thead>
          <tbody>
            <% @stats.contributors.each do |contributor| %>
              <tr>
                <td>
                  <%= gravatar_image_tag contributor.first, size: 20, alt: contributor.last[:author], lazy: true %>
                  <%= secure_mail contributor.first %>
                </td>
                <td><%= contributor.last[:author] %></td>
                <td><%= contributor.last[:commits_count] %></td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>

      <div class="col-md-4">
        <div class="panel panel-default">
          <div class="panel-heading">Branches (<%= @repo.branches.size %>)</div>

          <ul class="list-group">
            <% @repo.branches.each do |branch| %>
              <a class="list-group-item <%= 'active' if branch.name == params[:ref] %>" href="<%= h prefix_url(@repo.param) %>/<%= h branch.name %>">
                <%= h branch.name %>
              </a>
            <% end %>
          </ul>
        </div>

        <div class="panel panel-default">
          <div class="panel-heading">Tags (<%= @repo.tags.count %>)</div>

          <ul class="list-group">
            <% if @repo.tags.any? %>
              <% @repo.tags.each_name do |tag| %>
                <a class="list-group-item" href="<%= h prefix_url(@repo.param) %>/tag/<%= h tag %>">
                  <%= h tag %>
                </a>
              <% end %>
            <% else %>
              <li class="list-group-item">No tags</li>
            <% end %>
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>