Skip to content

Instantly share code, notes, and snippets.

@martinos
Created October 28, 2010 21:41
Show Gist options
  • Select an option

  • Save martinos/652387 to your computer and use it in GitHub Desktop.

Select an option

Save martinos/652387 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'grit'
require 'ruby-debug'
include Grit
class GitFilePublisher < Sinatra::Base
def initialize(repo_path, *args)
@repo = Repo.new repo_path
super(args)
end
get '/*/*' do
sha, filename = params[:splat]
blob = @repo.blob(sha)
data = blob.data
content_type = blob.mime_type
# We tell http that it is an attachment of name nas
attachment filename
content_type( content_type )
data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment