use header image from metadata.txt

This commit is contained in:
sejo 2022-01-08 19:29:20 -06:00
parent bca25140b8
commit 6d7003753d
2 changed files with 12 additions and 6 deletions

12
g2e.awk
View File

@ -17,6 +17,10 @@ BEGIN{
value = $2
for(i=3;i<=NF;i++) value = value " " $i
if(key=="cover"){
sub(/^.+\//,"",value) # get basename
}
meta[key] = value
# set index file as an argument to be read
@ -53,8 +57,7 @@ BEGIN{
}
# start writing metadata files
content_header = write_template( "content-header.opf", meta )
content = write_template("content-manifest-header.opf", meta )
content = write_template("content-header.opf", meta )
toc = write_template( "toc-header.ncx", meta )
spinetoc = " <spine toc=\"ncx\">\n"
}
@ -110,18 +113,15 @@ ARGIND==2 && FNR==1{
sub(/^.+\//,"",id) # get basename
properties = ""
if(id~/cover/){
if(id~meta["cover"]){
properties = "properties=\"cover-image\""
content_header = content_header " <meta content=\"" id "\" name=\"cover\">\n"
}
content = content " <item id=\"" id "\" href=\"" dest "\" media-type=\"" mediatype "\" " properties "/>\n"
}
$0 = line
# finalize metadata files
content_header = content_header " </metadata>\n\n"
content = content " </manifest>\n\n" spinetoc " </spine>\n\n</package>"
content = content_header content
print content > epubodir "content.opf"
toc = toc " </navMap>\n</ncx>"

View File

@ -8,3 +8,9 @@
<dc:creator opf:role="aut">{author}</dc:creator>
<dc:description>{description}</dc:description>
<dc:date>{publishDate}</dc:date>
<meta content="{cover}" name="cover"/>
</metadata>
<manifest>
<item id="stylesheet" href="style.css" media-type="text/css"/>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>