zlx/API-mock-server

View on GitHub
lib/api-mock-server/views/api_list.erb

Summary

Maintainability
Test Coverage
<div class="bs-sidebar hidden-print affix" role="complementary">
  <ul class="nav bs-sidenav">
    <% @categories.each do |category| %>
      <li class="<%= current.try(:category) == category ? 'active' : '' %>">
        <% routes = category == "未分类" ? 
          ApiMockServer::Endpoint.where(:category.exists => false).distinct(:pattern) : 
          ApiMockServer::Endpoint.where(:category => category).distinct(:pattern) %>
        <a href="/admin/batch_show?pattern=<%= routes.first %>"><%= category %></a>
        <ul class='nav'>
          <% routes.each do |route| %>
            <li class="<%= current.try(:pattern) == route ? 'active' : '' %>">
              <a href='/admin/batch_show?pattern=<%= route %>'>
                <strong><%= route %></strong>
              </a>
            </li>
          <% end %>
        </ul>
      </li>
    <% end %>
  </ul>
  <a href="/admin/new" class='btn btn-primary btn-lg'>创建新 API</a>
</div>