BigW Consortium Gitlab

uploads.rb 1.25 KB
Newer Older
1 2 3 4 5 6
scope path: :uploads do
  # Note attachments and User/Group/Project avatars
  get ":model/:mounted_as/:id/:filename",
      to:           "uploads#show",
      constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }

7 8 9 10 11
  # show uploads for models, snippets (notes) available for now
  get ':model/:id/:secret/:filename',
    to: 'uploads#show',
    constraints: { model: /personal_snippet/, id: /\d+/, filename: /[^\/]+/ }

12 13 14 15 16 17 18 19 20
  # Appearance
  get ":model/:mounted_as/:id/:filename",
      to:           "uploads#show",
      constraints:  { model: /appearance/, mounted_as: /logo|header_logo/, filename: /.+/ }

  # Project markdown uploads
  get ":namespace_id/:project_id/:secret/:filename",
    to:           "projects/uploads#show",
    constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
21 22 23 24 25 26

  # create uploads for models, snippets (notes) available for now
  post ':model/:id/',
    to: 'uploads#create',
    constraints: { model: /personal_snippet/, id: /\d+/ },
    as: 'upload'
27 28 29 30 31 32
end

# Redirect old note attachments path to new uploads path.
get "files/note/:id/:filename",
  to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
  constraints:  { filename: /[^\/]+/ }