Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
125d61599a06
Commit
fa3cc1dd
authored
Feb 16, 2013
by
Dmitriy Zaporozhets
Browse files
Merge branch 'features/attachment_server' of /home/git/repositories/gitlab/gitlabhq
parents
4cf284325b86
d285dbb87c2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/controllers/files_controller.rb
0 → 100644
View file @
125d6159
class
FilesController
<
ApplicationController
def
download
note
=
Note
.
find
(
params
[
:id
])
if
can?
(
current_user
,
:read_project
,
note
.
project
)
uploader
=
note
.
attachment
send_file
uploader
.
file
.
path
,
disposition:
'attachment'
else
not_found!
end
end
end
app/uploaders/attachment_uploader.rb
View file @
125d6159
...
...
@@ -19,4 +19,12 @@ def image?
rescue
false
end
def
secure_url
if
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
"/files/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
model
.
id
}
/
#{
file
.
filename
}
"
else
url
end
end
end
app/views/events/event/_note.html.haml
View file @
125d6159
...
...
@@ -26,7 +26,7 @@
=
markdown
truncate
(
event
.
target
.
note
,
length:
70
)
-
note
=
event
.
target
-
if
note
.
attachment
.
url
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
...
...
app/views/notes/_note.html.haml
View file @
125d6159
...
...
@@ -31,7 +31,7 @@
-
if
note
.
attachment
.
image?
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
.attachment.pull-right
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
do
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
do
%i
.icon-paper-clip
=
note
.
attachment_identifier
.clear
config/routes.rb
View file @
125d6159
...
...
@@ -45,6 +45,11 @@
root
to:
"projects#index"
end
#
# Attachments serving
#
get
'files/:type/:id/:filename'
=>
'files#download'
,
constraints:
{
id:
/\d+/
,
type:
/[a-z]+/
,
filename:
/[a-zA-Z.0-9_\-\+]+/
}
#
# Admin Area
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment