diff --git a/bookbuilder.nim b/bookbuilder.nim
deleted file mode 100755
index 46ff5d0..0000000
--- a/bookbuilder.nim
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/usr/bin/env nimcr
-
-import os, osproc, rdstdin, times
-import std/[algorithm, enumerate, exitProcs, marshal, json, sequtils, streams, strutils, sugar, terminal, with]
-
-type BuilderError = object of CatchableError
-
-type Book = object
- author: string
- source: string
- tag: string
- title: string
- year: int
- lastWriteTime: string
- category: int
-
-func `<`(x, y: Book): bool {.raises: [].} =
- if x.category != y.category: return x.category < y.category
- x.year > y.year
-
-type BookBuilder = object
- books: seq[Book]
- categories: seq[string]
-
-func sourceFile(book: Book): string {.raises: [].} =
- "src" / book.tag.addFileExt "md"
-
-proc createBuilder(): BookBuilder {.raises: [BuilderError].} =
- try:
- let fileContents = "books.json".readFile
- to[BookBuilder](fileContents)
- except Exception:
- raise newException(BuilderError, getCurrentExceptionMsg())
-
-func addBook(builder: var BookBuilder, book: Book) {.raises: [].} =
- builder.books.add book
-
-proc save(builder: var BookBuilder) {.raises: [BuilderError].} =
- try:
- builder.books.sort()
- "books.json".writeFile $$builder
- except Exception:
- raise newException(BuilderError, getCurrentExceptionMsg())
-
-proc executeCommand(command: string) {.raises: [BuilderError].} =
- var res: tuple[output: string, exitCode: int]
- try:
- res = execCmdEx(command)
- except Exception:
- raise newException(BuilderError, getCurrentExceptionMsg())
- if res.exitCode != 0: raise newException(BuilderError, "Command \n" & command & "\n exited with code " & $res.exitCode & " and output \n" & res.output)
-
-proc make(book: var Book) {.raises: [BuilderError].}=
- let dir = "books" / book.tag
- let readDir = dir / "read"
- try:
- dir.createDir
- readDir.createDir
- except Exception:
- raise newException(BuilderError, getCurrentExceptionMsg())
- let indexFile = dir / "index.html"
- let commonCommand = "/usr/local/bin/pandoc --wrap=auto --table-of-contents --standalone --reference-location=block --section-divs --from=markdown+smart+auto_identifiers --metadata=author:" & book.author.quoteShell & " --metadata=title:" & book.title.quoteShell & " --metadata=date:" & quoteShell($book.year) & " " & book.sourceFile.quoteShell
- let pdfFile = dir / book.tag.addFileExt("pdf")
- let htmlFile = readDir / "index.html"
- let epubFile = dir / book.tag.addFileExt("epub")
- let mobiFile = dir / book.tag.addFileExt("mobi")
- executeCommand(commonCommand & " --to=pdf --pdf-engine=xelatex --output=" & pdfFile)
- executeCommand(commonCommand & " --to=html --template=templates/pandoc.html --output=" & htmlFile)
- executeCommand(commonCommand & " --to=epub --template=templates/pandoc.epub --output=" & epubFile)
- executeCommand("/usr/local/bin/ebook-convert " & epubFile & " " & mobiFile)
- try:
- var s = indexFile.openFileStream fmWrite
- with s:
- write ""
- write "
"
- write book.title
- write ""
- write ""
- write ""
- write ""
- write ""
- write book.title
- write "
"
- write "Written by "
- write book.author
- write " in "
- write ($book.year)
- write "
"
- write "Read it online
"
- write "Download a PDF
"
- write "Download an EPUB
"
- write "Download a MOBI
"
- if book.source != "":
- with s:
- write "
"
- write "Created from the page scans here."
- with s:
- write "

This work ("
- write book.title
- write ", by "
- write book.author
- write "), identified by Caden Haustein, is free of known Copyright restrictions.
"
- write ""
- write ""
- write "