aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-01-23 23:48:09 -0500
committerRalph Amissah <ralph@amissah.com>2013-01-23 23:48:09 -0500
commitff824c5c3d36f278e3050b171293e04c22b7356e (patch)
treee99afdc3c574e0bc399904610867e9ecd38a755c /lib/sisu/v4
parentv4 v3: xhtml structure error, fix missing </div> (diff)
v4 v3: epub, epub_format, provide full depth epub table of contentssisu_4.0.2
* [request Mikael Böök]
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r--lib/sisu/v4/epub.rb95
-rw-r--r--lib/sisu/v4/epub_format.rb38
2 files changed, 87 insertions, 46 deletions
diff --git a/lib/sisu/v4/epub.rb b/lib/sisu/v4/epub.rb
index d2d5cc6c..1af5ec49 100644
--- a/lib/sisu/v4/epub.rb
+++ b/lib/sisu/v4/epub.rb
@@ -197,7 +197,7 @@ module SiSU_EPUB
@@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] }
md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
@nav_no=0
- @s_a_no,@s_b_no,@s_c_no=0,0,0
+ @s_a_no,@s_b_no,@s_c_no,@lv5_no,@lv6_no=0,0,0,0,0
@@toc[:ncx] << @epub.toc_ncx.open #epub ncx navmap
@@toc[:ncx] << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close
@@toc[:ncx] << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author
@@ -230,67 +230,100 @@ module SiSU_EPUB
toc=case dob_toc.ln
when 1
@s_a_no +=1
- name_s_a='section_a' + @s_a_no.to_s
+ lv_name='section_a' + @s_a_no.to_s
@nav_no+=1
@nav_no2=@nav_no
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1]
- @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4]=true,false,false,false
- @epub.sections(dob_toc,name_s_a)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,name_s_a) if dob_toc
+ @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false,false
+ @epub.sections(dob_toc,lv_name)
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
if @level_a_first_occurrence \
&& @make.build.toc?
@nav_no+=1
@@toc[:ncx] << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc
@level_a_first_occurrence=false
end
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_a)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_a)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_a)
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_1
when 2
@s_b_no +=1
- name_s_b='section_b' + @s_b_no.to_s
+ lv_name='section_b' + @s_b_no.to_s
@nav_no+=1
@nav_no2=@nav_no
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @ncxo[2],@ncxo[3],@ncxo[4]=true,false,false
- @epub.sections(dob_toc,name_s_b)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,name_s_b) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_b)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_b)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_b)
+ @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false
+ @epub.sections(dob_toc,lv_name)
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_2
when 3
@s_c_no +=1
- name_s_c='section_c' + @s_c_no.to_s
+ lv_name='section_c' + @s_c_no.to_s
@nav_no+=1
@nav_no3=@nav_no
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @ncxo[3],@ncxo[4]=true,false
- @epub.sections(dob_toc,name_s_c)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,name_s_c) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_c)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_c)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_c)
+ @ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false
+ @epub.sections(dob_toc,lv_name)
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_3
when 4
@ncx_cls=[]
+ lv_name=dob_toc.name
@nav_no+=1
+ @dob_name=dob.name
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @ncxo[4]=true
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc)
+ @ncxo[4],@ncxo[5],@ncxo[6]=true,false,false
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_4
- when 5; SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_5
- when 6; SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_6
+ when 5
+ @ncx_cls=[]
+ hashtag='#o' + dob_toc.ocn.to_s
+ lv_name=@dob_name
+ @nav_no+=1
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @ncxo[5],@ncxo[6]=true,false
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+ SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_5
+ when 6
+ @ncx_cls=[]
+ hashtag='#o' + dob_toc.ocn.to_s
+ lv_name=@dob_name
+ @nav_no+=1
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @ncxo[6]=true
+ @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+ SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_6
else nil
end
toc.each do |k,d|
@@ -313,10 +346,12 @@ module SiSU_EPUB
end
end
end
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
@@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4]=false,false,false,false
+ @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false
md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image])
@@toc[:seg] << "</div>\n</div>"
@@toc[:scr] << "</div>\n</div>"
diff --git a/lib/sisu/v4/epub_format.rb b/lib/sisu/v4/epub_format.rb
index 60c40dea..84d32000 100644
--- a/lib/sisu/v4/epub_format.rb
+++ b/lib/sisu/v4/epub_format.rb
@@ -1287,10 +1287,10 @@ application/epub+zip
</container>
WOK
end
- def sections(dob,name)
- filename="#{name}#{Sfx[:epub_xhtml]}"
- dir_epub_cont="#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}"
- segfilename="#{dir_epub_cont}/#{filename}"
+ def sections(dob,fn_base)
+ name=fn_base + Sfx[:epub_xhtml]
+ dir_epub_cont=@md.env.processing_path.epub + '/' + Ep[:d_oebps]
+ segfilename=dir_epub_cont + '/' + name
output_epub_cont_seg=File.new(segfilename,'w')
output_epub_cont_seg << %{#{doc_type}
<head>
@@ -1396,8 +1396,9 @@ output_epub_cont_seg.close
</navPoint>
WOK
end
- def navpoint(dob,no,name=nil)
- name=name ? name : dob.name
+ def navpoint(dob,no,fn_base,hashtag=nil)
+ fn=fn_base + Sfx[:epub_xhtml]
+ name=hashtag ? fn + hashtag : fn
id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \
? ''
: "-#{no}"
@@ -1593,7 +1594,7 @@ output_epub_cont_seg.close
end
def manifest_content_sisu_toc
<<-WOK
- <item id="index" href="index.xhtml" media-type="application/xhtml+xml" />
+ <item id="index#{Sfx[:epub_xhtml]}" href="index#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml" />
WOK
end
def manifest_cover_image_information(md)
@@ -1606,10 +1607,11 @@ output_epub_cont_seg.close
else ''
end
end
- def manifest_content(dob,name=nil)
- name=name ? name : dob.name
+ def manifest_content(dob,fn_base,hashtag=nil)
+ fn=fn_base + Sfx[:epub_xhtml]
+ name=hashtag ? fn + hashtag : fn
<<-WOK
- <item id="#{name}" href="#{name}#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml" />
+ <item id="#{name}" href="#{name}" media-type="application/xhtml+xml" />
WOK
end
def manifest_images(imgs)
@@ -1643,11 +1645,12 @@ output_epub_cont_seg.close
end
def spine_sisu_toc
<<-WOK
- <itemref idref="index" linear="yes" />
+ <itemref idref="index#{Sfx[:epub_xhtml]}" linear="yes" />
WOK
end
- def spine(dob,name=nil)
- name=name ? name : dob.name
+ def spine(dob,fn_base,hashtag=nil)
+ fn=fn_base + Sfx[:epub_xhtml]
+ name=hashtag ? fn + hashtag : fn
<<-WOK
<itemref idref="#{name}" linear="yes" />
WOK
@@ -1670,13 +1673,16 @@ output_epub_cont_seg.close
end
def guide_sisu_toc
<<-WOK
- <reference type="index" href="index#{Sfx[:epub_xhtml]}" />
+ <reference type="index#{Sfx[:epub_xhtml]}" href="index#{Sfx[:epub_xhtml]}" />
WOK
end
- def guide(dob,name=nil)
+ def guide(dob,fn_base,hashtag=nil)
+ fn=fn_base + Sfx[:epub_xhtml]
+ name=hashtag ? fn + hashtag : fn
name=name ? name : dob.name
+ guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml])
<<-WOK
- <reference type="text" href="#{name}#{Sfx[:epub_xhtml]}" />
+ <reference type="text" href="#{guide_name}" />
WOK
end
def guide_close