Permalink
Browse files

Support pats as higher level of chapters

  • Loading branch information...
1 parent e61b659 commit b1dc812d4645d617c9e56ce8d2c06468f78a3342 @mizzy committed Jan 13, 2012
Showing with 62 additions and 34 deletions.
  1. +17 −10 index.tx
  2. +17 −8 ncx.tx
  3. +18 −10 opf.tx
  4. +10 −6 webiblo.pl
View
@@ -8,19 +8,26 @@
<h1>[% title %]</h1>
<ul>
- [% FOREACH chapter IN chapters -%]
- <li><a href="[% chapter.href %]">[% chapter.title %]</a></li>
- <ul>
- [% FOREACH section IN chapter.sections -%]
- <li><a href="[% section.href %]">[% section.title %]</li>
+ [% FOREACH part IN parts -%]
+ [% IF part.title -%]
+ <li><a href="[% part.href %]">[% part.title %]</a></li>
+ [% END -%]
+ <ul>
+ [% FOREACH chapter IN part.chapters -%]
+ <li><a href="[% chapter.href %]">[% chapter.title %]</a></li>
<ul>
- [% FOREACH subsection IN section.subsections -%]
- <li><a href="[% subsection.href %]">[% subsection.title %]</li>
- [% END %]
- </ul>
+ [% FOREACH section IN chapter.sections -%]
+ <li><a href="[% section.href %]">[% section.title %]</li>
+ <ul>
+ [% FOREACH subsection IN section.subsections -%]
+ <li><a href="[% subsection.href %]">[% subsection.title %]</li>
+ [% END %]
+ </ul>
+ [% END -%]
+ </ul>
[% END -%]
</ul>
- [% END -%]
+[% END -%]
</ul>
</body>
View
25 ncx.tx
@@ -7,18 +7,27 @@
<navLabel><text>[% title %] - Table of Contents</text></navLabel><content src="index.html"/>
</navPoint>
[% num = 1 -%]
-[% FOREACH chapter IN chapters -%]
- [% IF chapter.href -%]
- <navPoint id="item[% num %]" playOrder="[% num %]">
- <navLabel><text>[% chapter.title %]</text></navLabel><content src="[% chapter.href %]"/>
- </navPoint>
+
+[% FOREACH part IN parts -%]
+ [% IF part.href -%]
+ <navPoint id="item[% num %]" playOrder="[% num %]">
+ <navLabel><text>[% part.title %]</text></navLabel><content src="[% part.href %]"/>
+ </navPoint>
[% num = num + 1 -%]
[% END -%]
- [% FOREACH section IN chapter.sections -%]
+ [% FOREACH chapter IN part.chapters -%]
+ [% IF chapter.href -%]
+ <navPoint id="item[% num %]" playOrder="[% num %]">
+ <navLabel><text>[% chapter.title %]</text></navLabel><content src="[% chapter.href %]"/>
+ </navPoint>
+ [% num = num + 1 -%]
+ [% END -%]
+ [% FOREACH section IN chapter.sections -%]
<navPoint id="item[% num %]" playOrder="[% num %]">
- <navLabel><text>[% section.title %]</text></navLabel><content src="[% section.href %]"/>
+ <navLabel><text>[% section.title %]</text></navLabel><content src="[% section.href %]"/>
</navPoint>
- [% num = num + 1 -%]
+ [% num = num + 1 -%]
+ [% END -%]
[% END -%]
[% END -%]
</navMap>
View
28 opf.tx
@@ -20,23 +20,31 @@
<item id="index" media-type="text/x-oeb1-document" href="index.html"></item>
<item id="toc" media-type="application/x-dtbncx+xml" href="toc.ncx"></item>
[% num = 1 -%]
-[% FOREACH chapter IN chapters -%]
- [% IF chapter.file -%]
- <item id="item[% num %]" media-type="text/x-oeb1-document" href="[% chapter.file %]"></item>
+[% FOREACH part IN parts -%]
+ [% IF part.file -%]
+ <item id="item[% num %]" media-type="text/x-oeb1-document" href="[% part.file %]"></item>
[% num = num + 1 -%]
[% END -%]
- [% FOREACH section IN chapter.sections -%]
- <item id="item[% num %]" media-type="text/x-oeb1-document" href="[% section.file %]"></item>
- [% num = num + 1 -%]
+ [% FOREACH chapter IN part.chapters -%]
+ [% IF chapter.file -%]
+ <item id="item[% num %]" media-type="text/x-oeb1-document" href="[% chapter.file %]"></item>
+ [% num = num + 1 -%]
+ [% END -%]
+ [% FOREACH section IN chapter.sections -%]
+ <item id="item[% num %]" media-type="text/x-oeb1-document" href="[% section.file %]"></item>
+ [% num = num + 1 -%]
+ [% END -%]
[% END -%]
[% END -%]
</manifest>
<spine toc="toc">
[% num = 1 -%]
-[% FOREACH chapter IN chapters -%]
- [% FOREACH section IN chapter.sections -%]
- <itemref idref="item[% num %]" />
- [% num = num + 1 -%]
+[% FOREACH part IN parts -%]
+ [% FOREACH chapter IN part.chapters -%]
+ [% FOREACH section IN chapter.sections -%]
+ <itemref idref="item[% num %]" />
+ [% num = num + 1 -%]
+ [% END -%]
[% END -%]
[% END -%]
</spine>
View
@@ -37,12 +37,16 @@
close $out;
}
-for my $chapter ( @{ $book->{chapters} } ) {
- get_content($chapter);
- for my $section ( @{ $chapter->{sections} } ) {
- get_content($section);
- for my $subsection ( @{ $section->{subsections} } ) {
- get_content($subsection);
+$book->{parts}->[0]->{chapters} = $book->{chapters} unless $book->{parts};
+
+for my $part ( @{ $book->{parts} } ) {
+ for my $chapter ( @{ $part->{chapters} } ) {
+ get_content($chapter);
+ for my $section ( @{ $chapter->{sections} } ) {
+ get_content($section);
+ for my $subsection ( @{ $section->{subsections} } ) {
+ get_content($subsection);
+ }
}
}
}

0 comments on commit b1dc812

Please sign in to comment.