<p>
<small>If you did not need any credentials to get to this page</small>
  <pre><code>gem sources -a <%= url "/" %></code></pre>
<small>If you needed some credentials to get to this page</small>
  <pre><code>gem sources -a <%= url.to_s.gsub('://','://username:password@') %></code></pre>
<% if @allow_upload %>
<small>and then ...</small>
  <pre><code>gem install geminabox<br />gem inabox [gemfile]</code></pre>
<% end %>
</p>

<% if @gems.any? %>
  <% if @allow_upload %><a href="<%= url("/upload") %>">Upload Another Gem</a><% end %>

  <div id="alpha_index"><%= ("a".."z").map{|i| @index_gems.include?(i) ? "<a href='#jump_#{i}'>#{i}</a>" : i }.join(" - ") %></div>

  <ul class="gemlist">

    <% @gems.by_name do |name, versions| %>
      <li <%= %{id="jump_#{name[0..0].downcase}"} if @index_gems.delete(name[0..0].downcase) %> class="gem-version">
        <h2><%= name %> (<%= versions.count == 1 ? versions.first.number : "#{versions.oldest.number} - #{versions.newest.number}" %>)</h2>
        <% versions.each.reverse_each.first(5).each do |version| %>
          <p>
            <code>gem install <%= version.name %> <%= "--prerelease" if version.number.to_s.match(/[a-z]/i) %> -v "<%= version.number %>"</code>
            <% unless version.platform =~ /^ruby/i %>
              <small class="platform"><%= version.platform %></small>
            <% end %>
          </p>
          <form class="delete-form" method="post" action="<%= url("/gems/#{version.gemfile_name}.gem") %>">
            <a class="download" href="<%= url("/gems/#{version.gemfile_name}.gem") %>">download</a>
            <% if @allow_delete %>
            <input type="hidden" name="_method" value="DELETE" />
            <button type="submit">delete</button>
            <% end %>
          </form>
        <% end %>

        <% if versions.count > 5 %>
          <a href="<%= url("/gems/#{name}") %>" id="more_link">Older versions...</a>
        <% end %>

        <div class="details">
          <p>
            <% newest_gem = versions.newest %>
            <% if spec = spec_for(name, newest_gem.number, newest_gem.platform) %>
              <%= spec.description %>
              <br/>
              <span class="author">– <%= spec.authors.map do |author|
                "<a href='#{href(spec.homepage)}'>#{author}</a>"
              end.join(', ') %></span>
            <% end %>
          </p>
        </div>

      </li>
    <% end %>
  </ul>
<% end %>

<% if @allow_upload %><a href="<%= url("/upload") %>">Upload Another Gem</a><% end %>
