lib/isodoc/gb/gbconvert.rb in metanorma-gb-1.3.7 vs lib/isodoc/gb/gbconvert.rb in metanorma-gb-1.3.8
- old
+ new
@@ -10,26 +10,26 @@
class Common < IsoDoc::Common
attr_accessor :meta
def initialize(options)
@meta = options[:meta]
- @standardlogoimg = options[:standardlogoimg]
- @standardclassimg = options[:standardclassimg]
- @standardissuerimg = options[:standardissuerimg]
+ @standardlogoimg = options[:standardlogoimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
+ @standardclassimg = options[:standardclassimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
+ @standardissuerimg = options[:standardissuerimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
end
def fileloc(loc)
- File.join(File.dirname(__FILE__), loc)
+ File.expand_path(File.join(File.dirname(__FILE__), loc))
end
def format_agency(agency, format, localdir)
- return "<img class='logo' src='#{localdir}/#{@standardissuerimg}' alt='#{agency.join(",")}'></img>" if @standardissuerimg
+ return "<img class='logo' src='#{@standardissuerimg}' alt='#{agency.join(",")}'></img>" if @standardissuerimg
return agency unless agency.is_a?(Array)
if agency == ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"]
- logo = "#{localdir}/gb-issuer-default.gif"
- FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo
- return "<img class='logo' src='#{logo}' alt='#{agency.join(",")}'></img>"
+ logo = "gb-issuer-default.gif"
+ #FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo
+ return "<img class='logo' src='#{fileloc(File.join('html/gb-logos', logo))}' alt='#{agency.join(",")}'></img>"
end
format_agency1(agency, format)
end
def format_agency1(agency, format)
@@ -45,11 +45,11 @@
return format_logo1(logo, prefix, scope, localdir) if @standardlogoimg
return "" if %w(enterprise social-group).include? scope
if logo.nil?
"<span style='font-size:36pt;font-weight:bold'>#{prefix}</span>"
else
- format_logo1("#{localdir}/#{logo}", prefix, scope, localdir)
+ format_logo1(logo, prefix, scope, localdir)
end
end
def local_logo_suffix(scope)
return "" if scope != "local"
@@ -58,15 +58,15 @@
end
def format_logo1(logo, prefix, scope, localdir)
local = local_logo_suffix(scope)
- return "<img class='logo' width='113' height='56' src='#{localdir}/#{@standardlogoimg}' alt='#{prefix}'></img>"\
+ return "<img class='logo' width='113' height='56' src='#{@standardlogoimg}' alt='#{prefix}'></img>"\
"#{local}" if @standardlogoimg
logo += ".gif"
- FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo
+ #FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo
#@files_to_delete << logo
- "<img class='logo' width='113' height='56' src='#{logo}' alt='#{prefix}'></img>"\
+ "<img class='logo' width='113' height='56' src='#{fileloc(File.join('html/gb-logos', logo))}' alt='#{prefix}'></img>"\
"#{local}"
end
end
end
end