module IsoDoc module Itu class PresentationXMLConvert < IsoDoc::PresentationXMLConvert def contribution_table_insert_pt(docxml) docxml.at(ns("//preface")) || docxml.at(ns("//sections")) .add_previous_sibling(" ").first docxml.at(ns("//preface")).children.first.before(" ").previous end def contribution_table(_doc) @doctype == "contribution" or return bureau = bold_and_upcase(@meta.get[:bureau_full]) <<~TABLE #{contribution_table_contacts}

#{@i18n.international_telecommunication_union.upcase}

#{bureau}

#{@i18n.studyperiod.sub('%', @meta.get[:study_group_period]).upcase}

#{@meta.get[:docnumber]}

#{@meta.get[:group].upcase}

#{@i18n.l10n("#{@i18n.original}: #{@i18n.current_language}")}

#{colon_i18n(@i18n.questions)}#{@meta.get[:questions]} #{@i18n.l10n("#{@meta.get[:meeting_place]}, #{@meta.get[:meeting_date]}")}
#{@i18n.get['doctype_dict']['contribution'].upcase}
#{colon_i18n(@i18n.document_source)}#{@meta.get[:source]}
#{colon_i18n(@i18n.title)}#{@meta.get[:doctitle_en]}
TABLE end def colon_i18n(text) @i18n.l10n("#{text}:") end def bold_and_upcase(xml) x = Nokogiri::XML("#{xml}") x.traverse do |e| e.text? or next e.replace("#{e.text.upcase}") end x.root.children.to_xml end def contribution_table_contacts n = (0..@meta.get[:authors]&.size).each_with_object([]) do |i, ret| ret << contribution_table_contact(i) end n.map do |x| lbl = colon_i18n(@i18n.contact) "#{lbl}#{x}" end.join("\n") end def contribution_table_contact(idx) @meta.get[:emails][idx] and e = "
#{@i18n.email}#{@meta.get[:emails][idx]}" <<~CELL #{@meta.get[:authors][idx]}
#{@meta.get[:affiliations][idx]}
#{@meta.get[:addresses][idx]} #{@i18n.tel_abbrev}#{@meta.get[:phones][idx]}#{e} CELL end def extract_clause_data(clause, type) x = clause.at(ns("./clause[@type = '#{type}']")) or return ret = x.dup ret.at(ns("./title"))&.remove ret.children.to_xml end def contribution_justification_contact(idx) @meta.get[:emails][idx] and e = ", #{@i18n.email}#{@meta.get[:emails][idx]}" <<~CELL #{@meta.get[:authors][idx]}
#{@meta.get[:affiliations][idx]}
#{@meta.get[:addresses][idx]}#{e} CELL end def contrib_justification_contacts (0..@meta.get[:authors]&.size).each_with_object([]) do |i, ret| ret << contribution_justification_contact(i) end end def contribution_justification_title(_doc) n = @meta.get[:docnumber] if @meta.get[:subdoctype] == "recommendation" "A.1 justification for proposed draft new Recommendation #{n}" else s = @meta.get[:subdoctype] "A.13 justification for proposed draft new #{s} "\ "#{n} “#{@meta.get[:doctitle_en]}”" end end def contribution_justification_auths auths = contrib_justification_contacts auths_tail = auths[1..auths.size].map do |x| "#{x}" end.join("\n") [auths, auths_tail] end def contribution_justification(doc) @doctype == "contribution" or return annex = doc.at(ns("//annex[@type = 'justification']")) or return auths, auths_tail = contribution_justification_auths annex.children = <<~TABLE #{contribution_justification_title(doc)} #{auths_tail} TABLE end end end end