Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow sub-paths

This adds support to allow hosting within an existing
site: http://example.com/geminabox/

Based on the work on issue #8 by chrischillibean
  • Loading branch information...
commit 27f6b084a949888979aba5f96e540475412569bb 1 parent d11cd1c
Tom Lea cwninja authored
4 Gemfile.lock
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- geminabox (0.3.3)
+ geminabox (0.4.0)
builder
sinatra
@@ -9,7 +9,7 @@ GEM
remote: http://rubygems.org/
specs:
builder (3.0.0)
- rack (1.3.4)
+ rack (1.3.5)
rack-protection (1.1.4)
rack
sinatra (1.3.1)
2  geminabox.gemspec
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'geminabox'
- s.version = '0.3.3'
+ s.version = '0.4.0'
s.summary = 'Really simple rubygem hosting'
s.description = 'A sinatra based gem hosting app, with client side gem push style functionality.'
s.author = 'Tom Lea'
18 lib/geminabox.rb
View
@@ -49,13 +49,13 @@ def fixup_bundler_rubygems!
get '/reindex' do
reindex
- redirect "/"
+ redirect url("/")
end
delete '/gems/*.gem' do
File.delete file_path if File.exists? file_path
reindex
- redirect "/"
+ redirect url("/")
end
post '/upload' do
@@ -89,7 +89,7 @@ def fixup_bundler_rubygems!
end
end
reindex
- redirect "/"
+ redirect url("/")
end
private
@@ -135,17 +135,5 @@ def spec_for(gem_name, version)
spec_file = File.join(options.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
end
-
- def url_for(path)
- url = request.scheme + "://"
- url << request.host
-
- if request.scheme == "https" && request.port != 443 ||
- request.scheme == "http" && request.port != 80
- url << ":#{request.port}"
- end
-
- url << path
- end
end
end
2  lib/rubygems/commands/inabox_command.rb
View
@@ -63,7 +63,7 @@ def send_gem
request_body, request_headers = Multipart::MultipartPost.new.prepare_query("file" => file)
proxy.start(url.host, url.port) {|con|
- req = Net::HTTP::Post.new('/upload', request_headers)
+ req = Net::HTTP::Post.new(url.path+'/upload', request_headers)
req.basic_auth(url.user, url.password) if url.user
handle_response(con.request(req, request_body))
}
26 public/master.css
View
@@ -83,11 +83,12 @@ ul.gemlist li strong {
ul.gemlist li .delete-form {
position: relative;
- overflow: hidden;
margin: 2px 0;
}
-ul.gemlist li .delete-form button {
- visibility: hidden;
+ul.gemlist li button,
+ul.gemlist li a.download
+{
+ display: none;
position: absolute;
right: 0;
bottom: 0;
@@ -96,9 +97,22 @@ ul.gemlist li .delete-form button {
border: 0;
color: #fff;
margin: 0;
+ font-size: 8pt;
+ padding: 3px;
+ cursor: pointer;
+}
+
+ul.gemlist li a.download {
+ background: #5c5;
+ border-radius: .5em 0 0 .5em; -moz-border-radius: .5em 0 0 .5em; -webkit-border-radius: 0 .5em .5em 0;
+ left: 0;
+ right: auto;
}
-ul.gemlist li .delete-form:hover button {
- visibility: visible;
+
+ul.gemlist li:hover button,
+ul.gemlist li:hover a.download {
+ margin: 0;
+ display: block;
}
.details {
@@ -118,7 +132,7 @@ ul.gemlist li .delete-form:hover button {
}
-.gem-version form p {
+.gem-version p {
margin: 0;
padding: 1px 0;
border: 0;
19 views/index.erb
View
@@ -1,5 +1,5 @@
<% if @gems.any? %>
- <a href="upload">Upload Another Gem</a>
+ <a href="<%= url("/upload") %>">Upload Another Gem</a>
<div id="alpha_index"><%= ("a".."z").map{|i| @index_gems.include?(i) ? "<a href='#jump_#{i}'>#{i}</a>" : i }.join(" - ") %></div>
@@ -9,13 +9,14 @@
<li <%= %{id="jump_#{name[0..0]}"} if @index_gems.delete(name[0..0]) %> class="gem-version">
<h2><%= name %> (<%= versions.count == 1 ? versions.first.number : "#{versions.first.number} - #{versions.first.number}" %>)</h2>
<% versions.each do |version| %>
- <form class="delete-form" method="post" action="/gems/<%= version.gemfile_name %>.gem">
- <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>
+ <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>
@@ -38,4 +39,4 @@
</ul>
<% end %>
-<a href="upload">Upload Another Gem</a>
+<a href="<%= url("/upload") %>">Upload Another Gem</a>
10 views/layout.erb
View
@@ -2,19 +2,19 @@
<html>
<head>
<title>Gem in a Box</title>
- <link rel="stylesheet" href="/master.css" type="text/css" media="screen">
- <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom Feed">
+ <link rel="stylesheet" href="<%= url "/master.css" %>" type="text/css" media="screen">
+ <link href="<%= url "/atom.xml" %>" type="application/atom+xml" rel="alternate" title="Atom Feed">
</head>
<body>
<div id="content">
<h1>Gem in a Box</h1>
<p>
- <pre><code>gem sources -a <%= url_for "/" %></code></pre>
+ <pre><code>gem sources -a <%= url "/" %></code></pre>
<pre><code>gem install geminabox<br />gem inabox [gemfile]</code></pre>
</p>
<%= yield %>
</div>
- <script type="text/javascript" src="/jquery.js"></script>
- <script type="text/javascript" src="/master.js"></script>
+ <script type="text/javascript" src="<%= url "/jquery.js" %>"></script>
+ <script type="text/javascript" src="<%= url "/master.js" %>"></script>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.