diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-06-19 21:14:34 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-06-19 21:14:34 -0400 |
commit | beb28d69dcf076b73dda47096353fd7404565fa8 (patch) | |
tree | ce5156cd607023a87ac84623fe8089facb047e06 /lib | |
parent | v6: docbook, ocn & footnote numbers (as xml comments) (diff) |
v6: docbook, metadata header (docinfo)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v6/shared_metadata.rb | 66 | ||||
-rw-r--r-- | lib/sisu/v6/xml_docbook5.rb | 9 |
2 files changed, 75 insertions, 0 deletions
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=%{<b><u>Document Metadata</u></b>},'' + 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 + <<WOK +#{Ax[:tab]}<#{@tag}> +#{Ax[:tab]*2}#{inf_xml} +#{Ax[:tab]}</#{@tag}> +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 + [ + '<docinfo>', + SiSU_Metadata::Summary.new(@md).xml_docbook.metadata, + '</docinfo>' + ].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?) \ |