lib/isodoc/function/utils.rb in isodoc-1.0.15 vs lib/isodoc/function/utils.rb in isodoc-1.0.16
- old
+ new
@@ -138,27 +138,16 @@
v
end
def populate_template(docxml, _format)
meta = @meta.get.merge(@labels || {})
- docxml = docxml.
- gsub(/\[TERMREF\]\s*/, l10n("[#{@source_lbl}: ")).
- gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@modified_lbl} [/TERMREF]")).
- gsub(/\s*\[\/TERMREF\]\s*/, l10n("]")).
- gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} — "))
template = liquid(docxml)
template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h).
gsub('<', '<').gsub('>', '>').gsub('&', '&')
end
def save_dataimage(uri, relative_dir = true)
%r{^data:image/(?<imgtype>[^;]+);base64,(?<imgdata>.+)$} =~ uri
- #uuid = UUIDTools::UUID.random_create.to_s
- #fname = "#{uuid}.#{imgtype}"
- #new_file = File.join(tmpimagedir, fname)
- #@files_to_delete << new_file
- #File.open(new_file, "wb") { |f| f.write(Base64.strict_decode64(imgdata)) }
- #File.join(relative_dir ? rel_tmpimagedir : tmpimagedir, fname)
imgtype = "png" unless /^[a-z0-9]+$/.match imgtype
Tempfile.open(["image", ".#{imgtype}"]) do |f|
f.binmode
f.write(Base64.strict_decode64(imgdata))
@tempfile_cache << f #persist to the end