Class: Amp::Servers::FancyHTTPServer
- Inherits:
-
HTTPAuthorizedServer
- Object
- Sinatra::Base
- HTTPServer
- HTTPAuthorizedServer
- Amp::Servers::FancyHTTPServer
- Defined in:
- lib/amp/server/fancy_http_server.rb
Class Method Summary collapse
Methods inherited from HTTPAuthorizedServer
#repos, set_authentication, set_permission, set_storage, #users
Class Method Details
.amp_repository(http_path, repo, opts = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/amp/server/fancy_http_server.rb', line 32 def self.amp_repository(http_path, repo, opts={}) super(http_path, repo) http_path.chomp!('/') path_slashed = http_path + "/" get "#{http_path}/changeset/:changeset/?" do |cs| @changeset = repo[cs] haml :changeset, :locals => {:root => http_path, :repo => repo} end [http_path+"/", "#{http_path}/commits/?", "#{http_path}/commits/:page/?"].each do |path| get path do haml :commits, :locals => {:root => http_path, :opts => opts, :repo => repo, :page => params[:page].to_i} end end get "#{http_path}/users/:user" do if users[params[:user]] "You are browsing user #{params[:user]} in a repository located at #{repo.inspect}" else "User #{params[:user].inspect} not found :-(" end end ["#{http_path}/code/:changeset/?*", "#{http_path}/code/?*"].each do |p| get p do path = params[:splat].join path = path.shift('/').chomp('/') # clean it of slashes changeset_node = params[:changeset] || "tip" changeset = repo[changeset_node] info = load_browser_info changeset, path file_list, path, vf_cur, orig_path = info[:file_list], info[:path], info[:vf_cur], info[:orig_path] haml :file, :locals => {:root => http_path, :repo => repo, :file_list => file_list, :path => path, :vf_cur => vf_cur, :orig_path => orig_path, :changeset => changeset} end end get "#{http_path}/diff/:changeset/*" do path = params[:splat].join path = path.shift('/').chomp('/') # clean it of slashes changeset_node = params[:changeset] || "tip" changeset = repo[changeset_node] info = load_browser_info changeset, path file_list, path, vf_cur, orig_path = info[:file_list], info[:path], info[:vf_cur], info[:orig_path] haml :file_diff, :locals => {:root => http_path, :repo => repo, :file_list => file_list, :path => path, :vf_cur => vf_cur, :orig_path => orig_path, :changeset => changeset} end get "#{http_path}/raw/:changeset/*" do changeset_node = params[:changeset] path = params[:splat].join.shift("/").chomp("/") changeset = repo[changeset_node] vf_cur = changeset.get_file path content_type "text/plain" vf_cur.data end get '/stylesheet.css' do content_type 'text/css', :charset => 'utf-8' sass :stylesheet end end |