diff --git a/generate-epub.retro b/generate-epub.retro index 0bf7589..996db3d 100755 --- a/generate-epub.retro +++ b/generate-epub.retro @@ -26,6 +26,8 @@ Begin by defining some helper functions for writing to a file. ~~~ +'tools/book-chapters.retro include + 'FID var :file:s:put [ @FID file:write ] s:for-each ; :file:nl ASCII:CR @FID file:write ; @@ -69,31 +71,40 @@ Then create `META-INF/container.xml`. Create `content.opf`. This will need to lest all of the files that are used in the book. -Todo: +Manifest: -- verify the required fields and metadata -- write this to a file +'____ file:s:put file:nl - - - - RETRO Forth : User Manual - ...bookid... - +Spine: - - - +'____ file:s:put file:nl - - - +~~~ +'STEP:_Generate_`content.opf` s:put nl +'epub/content.opf file:open-for-writing !FID - - +' file:s:put file:nl +' file:s:put file:nl +'__ file:s:put file:nl +'____RETRO_Forth_:_User_Manual file:s:put file:nl +'____...bookid... file:s:put file:nl +'__ file:s:put file:nl - +'__ file:s:put file:nl +#0 TOC [ over swap '____ s:format file:s:put file:nl n:inc ] a:for-each +drop +'__ file:s:put file:nl +'__ file:s:put file:nl +(spine) +'__ file:s:put file:nl + +'__ file:s:put file:nl +'__ file:s:put file:nl + +' file:s:put file:nl +@FID file:close +~~~ # Generate the Chapters @@ -102,16 +113,25 @@ Todo: 'retro_tools/book-chapters-to-xhtml.retro unix:system ~~~ -Assemble the pieces +# Assemble the pieces ~~~ 'STEP:_Relocate_files s:put nl 'epub unix:chdir +'cp_-r_../chapters_. unix:system +~~~ + +# Zip Everything + +~~~ +'STEP:_Create_epub s:put nl +'zip_-0Xq_../book.epub_mimetype unix:system +'zip_-Xr9Dq_../book.epub_content.opf unix:system +'zip_-Xr9Dq_../book.epub_chapters unix:system '.. unix:chdir ~~~ -zip -0Xq /tmp/book.epub mimetype -zip -Xr9Dq /tmp/book.epub * +# Clean Up Cleanup is the final step. Remove the temporary epub directory