13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/booklab/sml/rules/file.rb', line 13
def self.to_html(node, opts = {})
attrs = attributes(node)
attrs[:name] ||= ""
return attrs[:name] if attrs[:src].blank?
humanize_size = number_to_human_size(attrs[:size] || 0)
out = <<~HTML
<a class="attachment-file" title="#{attrs[:name]}" target="_blank" href="#{attrs[:src]}">
<span class="icon-box"><i class="fas fa-file"></i></span>
<span class="filename">#{escape_html(attrs[:name])}</span>
<span class="filesize">#{escape_html(humanize_size)}</span>
</a>
HTML
out
end
|