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

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

12
  # show temporary uploads
13
  get '-/system/temp/:secret/:filename',
14
    to: 'uploads#show',
15
    constraints: { filename: %r{[^/]+} }
16

17
  # Appearance
18
  get "-/system/:model/:mounted_as/:id/:filename",
19
      to:           "uploads#show",
20 21
      constraints:  { model: /appearance/, mounted_as: /logo|header_logo|favicon/, filename: /.+/ },
      as: 'appearance_upload'
22 23 24 25

  # Project markdown uploads
  get ":namespace_id/:project_id/:secret/:filename",
    to:           "projects/uploads#show",
26
    constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: %r{[^/]+} }
27 28

  # create uploads for models, snippets (notes) available for now
29
  post ':model',
30
    to: 'uploads#create',
31
    constraints: { model: /personal_snippet|user/, id: /\d+/ },
32
    as: 'upload'
33 34 35 36 37
end

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