Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
796bb651
Commit
796bb651
authored
Nov 14, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicate methods in uploaders
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9179fcec
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
51 deletions
+25
-51
app/uploaders/attachment_uploader.rb
app/uploaders/attachment_uploader.rb
+2
-17
app/uploaders/avatar_uploader.rb
app/uploaders/avatar_uploader.rb
+2
-17
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+2
-17
app/uploaders/uploader_helper.rb
app/uploaders/uploader_helper.rb
+19
-0
No files found.
app/uploaders/attachment_uploader.rb
View file @
796bb651
# encoding: utf-8
class
AttachmentUploader
<
CarrierWave
::
Uploader
::
Base
include
UploaderHelper
storage
:file
def
store_dir
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
def
image?
img_ext
=
%w(png jpg jpeg gif bmp tiff)
if
file
.
respond_to?
(
:extension
)
img_ext
.
include?
(
file
.
extension
.
downcase
)
else
# Not all CarrierWave storages respond to :extension
ext
=
file
.
path
.
split
(
'.'
).
last
.
downcase
img_ext
.
include?
(
ext
)
end
rescue
false
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
end
app/uploaders/avatar_uploader.rb
View file @
796bb651
# encoding: utf-8
class
AvatarUploader
<
CarrierWave
::
Uploader
::
Base
include
UploaderHelper
storage
:file
after
:store
,
:reset_events_cache
...
...
@@ -9,23 +11,6 @@ class AvatarUploader < CarrierWave::Uploader::Base
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
def
image?
img_ext
=
%w(png jpg jpeg gif bmp tiff)
if
file
.
respond_to?
(
:extension
)
img_ext
.
include?
(
file
.
extension
.
downcase
)
else
# Not all CarrierWave storages respond to :extension
ext
=
file
.
path
.
split
(
'.'
).
last
.
downcase
img_ext
.
include?
(
ext
)
end
rescue
false
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
def
reset_events_cache
(
file
)
model
.
reset_events_cache
if
model
.
is_a?
(
User
)
end
...
...
app/uploaders/file_uploader.rb
View file @
796bb651
# encoding: utf-8
class
FileUploader
<
CarrierWave
::
Uploader
::
Base
include
UploaderHelper
storage
:file
attr_accessor
:project
,
:secret
...
...
@@ -28,21 +30,4 @@ class FileUploader < CarrierWave::Uploader::Base
def
secure_url
File
.
join
(
"/uploads"
,
@secret
,
file
.
filename
)
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
def
image?
img_ext
=
%w(png jpg jpeg gif bmp tiff)
if
file
.
respond_to?
(
:extension
)
img_ext
.
include?
(
file
.
extension
.
downcase
)
else
# Not all CarrierWave storages respond to :extension
ext
=
file
.
path
.
split
(
'.'
).
last
.
downcase
img_ext
.
include?
(
ext
)
end
rescue
false
end
end
app/uploaders/uploader_helper.rb
0 → 100644
View file @
796bb651
# Extra methods for uploader
module
UploaderHelper
def
image?
img_ext
=
%w(png jpg jpeg gif bmp tiff)
if
file
.
respond_to?
(
:extension
)
img_ext
.
include?
(
file
.
extension
.
downcase
)
else
# Not all CarrierWave storages respond to :extension
ext
=
file
.
path
.
split
(
'.'
).
last
.
downcase
img_ext
.
include?
(
ext
)
end
rescue
false
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
end
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