Guest User

Untitled

a guest
May 27th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. module Gitorious
  2. module RepositoryRoutes
  3. class Resource < ActionDispatch::Routing::Mapper::Resource
  4. attr_accessor :prefix
  5. def id_segment
  6. prefix.to_s + super
  7. end
  8. end
  9.  
  10. def resources_without_collection(name, prefix = nil, options = {}, &block)
  11. if @scope[:scope_level] == :resources
  12. nested do
  13. resources_without_collection(name, nil, options, &block)
  14. end
  15. return
  16. end
  17.  
  18. resource = Gitorious::RepositoryRoutes::Resource.new(name, options)
  19. resource.prefix = prefix
  20.  
  21. scope(:controller => resource.controller) do
  22. with_scope_level(:resources, resource) do
  23. yield if block_given?
  24.  
  25. with_scope_level(:member) do
  26. scope("#{prefix}:id") do
  27. scope(resource.options) do
  28. get :show
  29. put :update
  30. delete :destroy
  31. get :edit, :as => resource.singular
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end
  38.  
  39. def repositories
  40. resources_without_collection :repositories do
  41. member do
  42. get :clone
  43. post :create_clone
  44. get :writable_by
  45. get :config
  46. get :confirm_delete
  47. get :committers
  48. get :search_clones
  49.  
  50. match "trees" => "trees#index", :as => :trees
  51. match "trees/*branch_and_path" => "trees#show", :as => :tree
  52. match "trees/*branch_and_path.:format" => "trees#show", :as => :formatted_tree
  53. match "archive-tarball/*branch" => "trees#archive", :as => :archive_tar, :defaults => {:archive_forat => "tar.gz"}
  54. match "archive-zip/*branch" => "trees#archive", :as => :archive_zip, :defaults => {:archive_format => "zip"}
  55.  
  56. # # repo.formatted_commits_feed "commits/*branch/feed.:format",
  57. # # :controller => "commits", :action => "feed", :conditions => {:feed => :get}
  58. match "commits/*branch/feed.:format" => "commits#feed", :as => :formatted_commits_feed
  59. match "commits" => "commits#index", :as => :commits
  60. match "commits/*branch" => "commits#index", :as => :commits_in_ref
  61. match "commit/:id(.:format)" => "commits#show", :as => :commit
  62.  
  63. match "comments/commit/:sha" => "comments#commit", :as => :commit_comment, :via => :get
  64. match "comments/preview" => "comments#preview", :as => :comments_preview
  65.  
  66.  
  67. match "blobs/raw/*branch_and_path" => "blobs#raw", :as => :raw_blob
  68. match "blobs/history/*branch_and_path" => "blobs#history", :as => :blob_history
  69. match "blobs/*branch_and_path" => "blobs#show", :as => :blob
  70. end
  71.  
  72. resources :comments
  73.  
  74. resources :merge_requests do
  75. member do
  76. get :terms_accepted
  77. get :version
  78. get :commit_status
  79. end
  80.  
  81. collection do
  82. post :create
  83. post :commit_list
  84. post :target_branches
  85. end
  86.  
  87. resources :comments do
  88. post :preview, :on => :collection
  89. end
  90.  
  91. resources :merge_request_versions do
  92. resources :comments do
  93. post :preview, :on => :collection
  94. end
  95. end
  96. end
  97.  
  98. resources :committerships do
  99. collection do
  100. get :auto_complete_for_group_name
  101. get :auto_complete_for_user_login
  102. end
  103. end
  104. end
  105. end
  106. end
  107. end
Add Comment
Please, Sign In to add comment