From beb28d69dcf076b73dda47096353fd7404565fa8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:14:34 -0400 Subject: v6: docbook, metadata header (docinfo) --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/shared_metadata.rb | 66 ++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v6/xml_docbook5.rb | 9 ++++++ 3 files changed, 76 insertions(+) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 820995f8..bfa4d5e7 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -41,6 +41,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * docbook, * ocn & footnote numbers (as xml comments) + * metadata header (docinfo) %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/shared_metadata.rb b/lib/sisu/v6/shared_metadata.rb index 1fa57fa7..dae28c6c 100644 --- a/lib/sisu/v6/shared_metadata.rb +++ b/lib/sisu/v6/shared_metadata.rb @@ -297,6 +297,57 @@ module SiSU_Metadata end meta end + def metadata_alt + meta=[] + if @display_heading + @tag,@inf=%{Document Metadata},'' + meta << self.meta_para + end + if defined? @md.title.main \ + and @md.title.main=~/\S+/ + @tag='title' + @inf=@md.title.main + meta << self.meta_para + end + if defined? @md.title.sub \ + and @md.title.sub=~/\S+/ + @tag='subtitle' + @inf=@md.title.sub + meta << self.meta_para + end + if defined? @md.creator.author \ + and @md.creator.author=~/\S+/ + @tag='author' + @inf=@md.creator.author + meta << self.meta_para + end + if defined? @md.creator.translator \ + and @md.creator.translator=~/\S+/ + @tag='translator' + @inf=@md.creator.translator + meta << self.meta_para + end + if defined? @md.creator.illustrator \ + and @md.creator.illustrator=~/\S+/ + @tag='illustrator' + @inf=@md.creator.illustrator + meta << self.meta_para + end + if defined? @md.rights.copyright.text \ + and @md.rights.copyright.text=~/\S+/ + @tag='copyright' + @inf=@md.rights.copyright.text # year & holder + @inf=@inf.gsub(/(?:Copyright|\(C\))+\s*/,'') + meta << self.meta_para + end + if defined? @md.rights.license \ + and @md.rights.license=~/\S+/ + @tag='license' + @inf=@md.rights.license + meta << self.meta_para + end + meta + end def processing_tags def make def language @@ -756,6 +807,21 @@ module SiSU_Metadata end self end + def xml_docbook + def meta_para + inf_xml=char_enc(@inf).utf8 + inf_xml=char_enc(inf_xml).br + < +#{Ax[:tab]*2}#{inf_xml} +#{Ax[:tab]} +WOK + end + def metadata + SiSU_Metadata::Summary.new(@md).metadata_alt + end + self + end def xml_sax def meta_para inf_xml=char_enc(@inf).utf8 diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 3f5333b2..75764043 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -70,6 +70,7 @@ module SiSU_XML_Docbook_Book include SiSU_TextUtils require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge + require_relative 'shared_metadata' # shared_metadata.rb class Source def initialize(opt) @opt=opt @@ -189,6 +190,13 @@ module SiSU_XML_Docbook_Book end #def chapterlevel #end + def xml_head + [ + '', + SiSU_Metadata::Summary.new(@md).xml_docbook.metadata, + '' + ].flatten + end def structure_build_collapsed(data) #output_file=@md.file.output_path.xml_docbook_book.dir + '/' + @md.file.base_filename.xml_docbook_book file=SiSU_Env::FileOp.new(@md) @@ -197,6 +205,7 @@ module SiSU_XML_Docbook_Book @chlv=chlv=0 doc_position=:head filename_docbook.puts head + filename_docbook.puts xml_head data.each_with_index do |o,i| if (defined? o.ocn and not o.ocn.nil?) ocn=(@make.build.ocn?) \ -- cgit v1.2.3