aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-07-26 20:12:52 -0400
committerRalph Amissah <ralph@amissah.com>2011-07-26 20:12:52 -0400
commita44bbf20b1f06c938ae0579a7771005995273c0c (patch)
treed3f2288e82f053eb6e74312085f7a15fe36f79ab /lib
parentv3: texpdf, XeTeX language settings (setmainlanguage setotherlanguage) (diff)
v3: epub, opf fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v3/epub_format.rb90
-rw-r--r--lib/sisu/v3/epub_segments.rb6
2 files changed, 85 insertions, 11 deletions
diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb
index e75ad112..9f169f5e 100644
--- a/lib/sisu/v3/epub_format.rb
+++ b/lib/sisu/v3/epub_format.rb
@@ -1037,16 +1037,90 @@ WOK
def metadata #metadata dc
author=if defined? @md.creator.author \
and @md.creator.author =~/\S+/
- x=@md.creator.author.gsub!(/</,'&lt;'); @md.creator.author.gsub!(/>/,'&gt;')
- @md.creator.author.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
- %{\n <dc:creator opf:file-as="#{x}" opf:role="aut">#{x}</dc:creator>}
+ m=''
+ @md.creator.author_detail.each do |x|
+ surname=x[:the] \
+ ? x[:the] \
+ : ''
+ other_names=x[:others] \
+ ? ', ' + x[:others] \
+ : ''
+ m=(m.empty?) \
+ ? (surname + other_names) \
+ : (m + '; ' + surname + ', ' + other_names)
+ m.gsub!(/</,'&lt;'); m.gsub!(/>/,'&gt;')
+ m.gsub!(/&lt;br(?: \/)?&gt;/,';')
+ end
+ x=@md.creator.author.dup
+ x.gsub!(/</,'&lt;'); x.gsub!(/>/,'&gt;')
+ x.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="aut">#{x}</dc:creator>}
+ else ''
+ end
+ translator=if defined? @md.creator.translator \
+ and @md.creator.translator =~/\S+/
+ m=''
+ @md.creator.translator_detail.each do |x|
+ surname=x[:the] \
+ ? x[:the] \
+ : ''
+ other_names=x[:others] \
+ ? ', ' + x[:others] \
+ : ''
+ m=(m.empty?) \
+ ? (surname + other_names) \
+ : (m + '; ' + surname + ', ' + other_names)
+ m.gsub!(/</,'&lt;'); m.gsub!(/>/,'&gt;')
+ m.gsub!(/&lt;br(?: \/)?&gt;/,';')
+ end
+ x=@md.creator.translator.dup
+ x.gsub!(/</,'&lt;'); x.gsub!(/>/,'&gt;')
+ x.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="trl">#{x}</dc:creator>}
else ''
end
illustrator=if defined? @md.creator.illustrator \
and @md.creator.illustrator =~/\S+/
- x=@md.creator.illustrator.gsub!(/</,'&lt;'); @md.creator.illustrator.gsub!(/>/,'&gt;')
- @md.creator.illustrator.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
- %{\n <dc:creator opf:file-as="#{x}" opf:role="ill">#{x}</dc:creator>}
+ m=''
+ @md.creator.illustrator_detail.each do |x|
+ surname=x[:the] \
+ ? x[:the] \
+ : ''
+ other_names=x[:others] \
+ ? ', ' + x[:others] \
+ : ''
+ m=(m.empty?) \
+ ? (surname + other_names) \
+ : (m + '; ' + surname + ', ' + other_names)
+ m.gsub!(/</,'&lt;'); m.gsub!(/>/,'&gt;')
+ m.gsub!(/&lt;br(?: \/)?&gt;/,';')
+ end
+ x=@md.creator.illustrator.dup
+ x.gsub!(/</,'&lt;'); x.gsub!(/>/,'&gt;')
+ x.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="ill">#{x}</dc:creator>}
+ else ''
+ end
+ date_published=if defined? @md.date.published \
+ and @md.date.published =~/\S+/
+ x=@md.date.published.dup
+ x.gsub!(/</,'&lt;'); x.gsub!(/>/,'&gt;')
+ x.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
+ %{\n <dc:date opf:event="published">#{x}</dc:date>}
+ else ''
+ end
+ subject=if defined? @md.classify.subject \
+ and @md.classify.subject =~/\S+/
+ x=@md.classify.subject.dup
+ x.gsub!(/</,'&lt;'); x.gsub!(/>/,'&gt;')
+ x.gsub!(/&lt;br(?: \/)?&gt;/,'<br />')
+ %{\n <dc:subject>#{x}</dc:subject>}
+ else ''
+ end
+ language=if defined? @md.opt.lng \
+ and @md.opt.lng =~/\S+/
+ language=@md.opt.lng.gsub(/<br>/,'<br />')
+ %{\n <dc:language>#{language}</dc:language>}
else ''
end
rights=if defined? @md.rights.all \
@@ -1058,10 +1132,8 @@ WOK
<<WOK
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>#{@md.title.full}</dc:title>
- #{author}#{illustrator}
- <dc:language>en-US</dc:language>
+ #{author}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights}
<dc:identifier id="bookid">...</dc:identifier>
- #{rights}
<dc:identifier id="EPB-UUID">urn:uuid:#{@md.dgst[1]}</dc:identifier>
</metadata>
WOK
diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb
index ed8c8d39..7bddf917 100644
--- a/lib/sisu/v3/epub_segments.rb
+++ b/lib/sisu/v3/epub_segments.rb
@@ -395,7 +395,8 @@ WOK
if @md.flag_separate_endnotes # may need to revisit, check
dob.obj.gsub!(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type
end
- if dob.is =~/heading|para/ and (not dob.ocn or dob.ocn.to_s.empty?)
+ if dob.is =~/heading|para/ \
+ and (not dob.ocn or dob.ocn.to_s.empty?)
format_seg=SiSU_EPUB_Format::Format_seg.new(@md,dob)
end
if (dob.is=='heading' or dob.is=='heading_insert' or dob.is=='para') \
@@ -414,7 +415,8 @@ WOK
end
def tail
format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md)
- if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn]
+ if @md.flag_auto_endnotes \
+ and @@seg_endnotes[@@get_hash_fn]
@@seg[:tail] << %{\n<div class="content">\n<div class="endnote">\n}
if @@seg_endnotes[@@get_hash_fn].flatten.length > 0
@@seg[:tail] << format_head_seg.endnote_mark