display the size of the attachment in the preview

instead of adding it during post processing
This commit is contained in:
Régis Hanol
2013-07-14 12:28:24 +02:00
parent 6f2ce93ab2
commit 3397c2235f
21 changed files with 197 additions and 25 deletions

View File

@ -25,14 +25,10 @@ class CookedPostProcessor
attachments.each do |attachment|
href = attachment['href']
attachment['href'] = relative_to_absolute(href)
# update reverse index
if upload = Upload.get_from_url(href)
# update reverse index
associate_to_post(upload)
# append the size
append_human_size!(attachment, upload)
end
# mark as dirty
@dirty = true
end
end
@ -234,13 +230,6 @@ class CookedPostProcessor
end
end
def append_human_size!(attachment, upload)
size = Nokogiri::XML::Node.new("span", @doc)
size["class"] = "size"
size.content = "(#{number_to_human_size(upload.filesize)})"
attachment.add_next_sibling(size)
end
def dirty?
@dirty
end