Sha256: d80252ae03512e6bff5f2c3b54fb7125f1e69aaa4e7e9099dbbbb963e1b8ba81
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module Redmineup module Liquid class AttachmentDrop < ::Liquid::Drop delegate :id, :filename, :title, :description, :filesize, :content_type, :digest, :downloads, :created_on, :token, :visible?, :image?, :thumbnailable?, :is_text?, :readable?, to: :@attachment def initialize(attachment) @attachment = attachment end def url(options = {}) Rails.application.routes.url_helpers.download_named_attachment_url(@attachment, { filename: filename, host: Setting.host_name, protocol: Setting.protocol }.merge(options)) end def link link_to((@attachment.description.blank? ? @attachment.filename : @attachment.description), url) end def author @author ||= UserDrop.new @attachment.author end def read @content ||= if @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte File.new(@attachment.diskfile, "rb").read end @content end end end end
Version data entries
4 entries across 4 versions & 1 rubygems