Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #75 from jballanc/index-fixup

Clean up and simplify the gem index
  • Loading branch information...
commit 80f9fd9a1998b8f7cde30cf7f28ac1aa41c70c4d 2 parents 59d573d + 30fb4d0
@cwninja cwninja authored
View
7 lib/geminabox.rb
@@ -75,6 +75,13 @@ def fixup_bundler_rubygems!
redirect url("/")
end
+ get '/gems/:gemname' do
+ gems = Hash[load_gems.by_name]
+ @gem = gems[params[:gemname]]
+ halt 404 unless @gem
+ erb :gem
+ end
+
delete '/gems/*.gem' do
File.delete file_path if File.exists? file_path
reindex(:force_rebuild)
View
8 public/master.css
@@ -24,6 +24,12 @@ a:hover {
color: #00f;
}
+a#more_link {
+ font-size: 0.7em;
+ line-height: 1.2;
+ vertical-align: bottom;
+}
+
form {
margin: 0;
}
@@ -146,4 +152,4 @@ ul.gemlist li:hover a.download {
.gem-version small.platform {
padding: 0 0 0 15px;
-}
+}
View
37 views/gem.erb
@@ -0,0 +1,37 @@
+<p>
+<a href="/">Back to Gem Index</a>
+</p>
+
+<ul class="gemlist">
+ <% @gem.by_name do |name, versions| %>
+ <li class="gem-version">
+ <h2><%= name %> (<%= versions.count == 1 ? versions.first.number : "#{versions.oldest.number} - #{versions.newest.number}" %>)</h2>
+ <% versions.each.reverse_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>
+ <input type="hidden" name="_method" value="DELETE" />
+ <button type="submit">delete</button>
+ </form>
+ <% end %>
+
+ <div class="details">
+ <p>
+ <% if spec = spec_for(name, versions.newest.number) %>
+ <%= spec.description %>
+ <br/>
+ <span class="author">– <%= spec.authors.map do |author|
+ "<a href='#{spec.homepage}'>#{author}</a>"
+ end.join(', ') %></span>
+ <% end %>
+ </p>
+ </div>
+
+ </li>
+ <% end %>
+</ul>
View
15 views/index.erb
@@ -1,3 +1,12 @@
+<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>
+<small>and then ...</small>
+ <pre><code>gem install geminabox<br />gem inabox [gemfile]</code></pre>
+</p>
+
<% if @gems.any? %>
<a href="<%= url("/upload") %>">Upload Another Gem</a>
@@ -8,7 +17,7 @@
<% @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 do |version| %>
+ <% 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 %>
@@ -22,6 +31,10 @@
</form>
<% end %>
+ <% if versions.count > 5 %>
+ <a href="<%= url("/gems/#{name}") %>" id="more_link">Older versions...</a>
+ <% end %>
+
<div class="details">
<p>
<% if spec = spec_for(name, versions.newest.number) %>
View
8 views/layout.erb
@@ -8,14 +8,6 @@
<body>
<div id="content">
<h1>Gem in a Box</h1>
- <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>
- <small>and then ...</small>
- <pre><code>gem install geminabox<br />gem inabox [gemfile]</code></pre>
- </p>
<%= yield %>
</div>
<script type="text/javascript" src="<%= url "/jquery.js" %>"></script>
View
3  views/upload.erb
@@ -1,3 +1,6 @@
+<p>
+<small>Choose a gem file to upload ...</small>
+</p>
<%= @error %>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="file">
Please sign in to comment.
Something went wrong with that request. Please try again.