created template and template reading
This commit is contained in:
commit
56d84833f6
|
@ -0,0 +1,4 @@
|
|||
clean:
|
||||
rm example-book.gpub
|
||||
gpub:
|
||||
cd example-gpub; zip -r ../example-book.gpub *; cd -
|
|
@ -0,0 +1,3 @@
|
|||
# chapter 1: an example
|
||||
|
||||
hello!
|
|
@ -0,0 +1,3 @@
|
|||
# chapter 2: another example
|
||||
|
||||
hola!
|
|
@ -0,0 +1,3 @@
|
|||
# chapter 3: yet another
|
||||
|
||||
this is chapter 3!
|
|
@ -0,0 +1,9 @@
|
|||
# example book
|
||||
|
||||
hello!
|
||||
|
||||
=> chapter1.gmi chapter 1: an example
|
||||
=> chapter2.gmi chapter 2: another example
|
||||
=> chapter3.gmi chapter 3: yet another
|
||||
|
||||
yay
|
|
@ -0,0 +1,7 @@
|
|||
title: an example book
|
||||
author: sejo
|
||||
gpubVersion: 1.0.0
|
||||
index: book/index.gmi
|
||||
language: en
|
||||
published: 2021
|
||||
version: 1
|
|
@ -0,0 +1,41 @@
|
|||
# awk -f g2e.awk example-gpub/
|
||||
BEGIN{
|
||||
gpubdir = ARGV[1]
|
||||
metadatafile = gpubdir "metadata.txt"
|
||||
|
||||
# read metadata file fields
|
||||
while( getline < metadatafile ){
|
||||
key = $1
|
||||
sub(":","",key)
|
||||
value = $2
|
||||
for(i=3;i<=NF;i++) value = value " " $i
|
||||
|
||||
meta[key] = value
|
||||
|
||||
# set index file as an argument to be read
|
||||
if(key == "index" ){
|
||||
ARGV[1] = (gpubdir value) # overwrite argument 1
|
||||
# store index dirname:
|
||||
indexdirname = value
|
||||
sub(/[^/]+\.gmi$/,"",indexdirname)
|
||||
}
|
||||
}
|
||||
|
||||
# read linked files from index and append as arguments
|
||||
while( getline < (gpubdir meta["index"]) ){
|
||||
if($1~"=>") ARGV[ARGC++] = gpubdir indexdirname $2
|
||||
}
|
||||
}
|
||||
# index file
|
||||
ARGIND==1{
|
||||
|
||||
}
|
||||
# content files
|
||||
ARGIND>1{
|
||||
print $0
|
||||
}
|
||||
END{
|
||||
# for(k in meta) print k, meta[k]
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
|
||||
<rootfiles>
|
||||
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
|
||||
</rootfiles>
|
||||
</container>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
||||
|
||||
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
||||
<dc:title>{title}</dc:title>
|
||||
<dc:language>{language}</dc:language>
|
||||
<dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier>
|
||||
<dc:creator opf:role="aut">{author}</dc:creator>
|
||||
<dc:description>{description}</dc:description>
|
||||
<dc:date>{publishDate}</dc:date>
|
||||
</metadata>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
||||
|
||||
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
||||
<dc:title>{title}</dc:title>
|
||||
<dc:language>{language}</dc:language>
|
||||
<dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier>
|
||||
<dc:creator opf:role="aut">{author}</dc:creator>
|
||||
<dc:description>{description}</dc:description>
|
||||
<dc:date>{publishDate}</dc:date>
|
||||
</metadata>
|
||||
|
||||
<manifest>
|
||||
<item id="chapter1" href="chapter1.xhtml" media-type="application/xhtml+xml"/>
|
||||
<item id="appendix" href="appendix.xhtml" media-type="application/xhtml+xml"/>
|
||||
<item id="stylesheet" href="style.css" media-type="text/css"/>
|
||||
<item id="ch1-pic" href="ch1-pic.png" media-type="image/png"/>
|
||||
<item id="myfont" href="css/myfont.otf" media-type="application/x-font-opentype"/>
|
||||
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
|
||||
</manifest>
|
||||
|
||||
<spine toc="ncx">
|
||||
<itemref idref="chapter1" />
|
||||
<itemref idref="appendix" />
|
||||
</spine>
|
||||
|
||||
</package>
|
|
@ -0,0 +1 @@
|
|||
application/epub+zip
|
Loading…
Reference in New Issue