Add method that returns markdown in file uploader
This commit is contained in:
parent
e64b1e52a2
commit
99ee822857
3 changed files with 6 additions and 2 deletions
|
@ -32,6 +32,10 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
File.join("/uploads", @secret, file.filename)
|
File.join("/uploads", @secret, file.filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_markdown
|
||||||
|
to_h[:markdown]
|
||||||
|
end
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
filename = image? ? self.file.basename : self.file.filename
|
filename = image? ? self.file.basename : self.file.filename
|
||||||
escaped_filename = filename.gsub("]", "\\]")
|
escaped_filename = filename.gsub("]", "\\]")
|
||||||
|
|
|
@ -46,7 +46,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_rewrite?
|
def needs_rewrite?
|
||||||
!(@text =~ @pattern).nil?
|
@text =~ @pattern
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Gitlab
|
||||||
return markdown unless file.try(:exists?)
|
return markdown unless file.try(:exists?)
|
||||||
|
|
||||||
new_uploader.store!(file)
|
new_uploader.store!(file)
|
||||||
new_uploader.to_h[:markdown]
|
new_uploader.to_markdown
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue