-
Notifications
You must be signed in to change notification settings - Fork 2
/
apple.go
49 lines (42 loc) · 1.29 KB
/
apple.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"log"
"os"
"github.com/bmaupin/go-epub"
)
func genetateAppleFile(bookProjectDir, bookVersion, coverImagePath string) string {
var e *epub.Epub
var outFilename string
var indexArticleTitle string
var bookWebsite string
var engVersion bool
projectName := confirmBookProjectName(bookProjectDir)
switch projectName {
default:
log.Fatal("unknow book porject: ", projectName)
case "Go101":
e = epub.NewEpub("Go 101")
e.SetAuthor("Tapir Liu")
indexArticleTitle = "Contents"
bookWebsite = "https://go101.org"
engVersion = true
outFilename = "Go101-" + bookVersion + ".apple.epub"
case "Golang101":
e = epub.NewEpub("Go语言101")
e.SetAuthor("老貘")
indexArticleTitle = "目录"
bookWebsite = "https://gfw.go101.org"
engVersion = false
outFilename = "Golang101-" + bookVersion + ".apple.epub"
}
cssFilename := "all.css"
tempCssFile := mustCreateTempFile("all*.css", []byte(AppleCSS))
defer os.Remove(tempCssFile)
cssPath, err := e.AddCSS(tempCssFile, cssFilename)
if err != nil {
log.Fatalln("add css", cssFilename, "failed:", err)
}
writeEpub_Go101(outFilename, e, -1, bookWebsite, projectName, indexArticleTitle, bookProjectDir, coverImagePath, cssPath, "apple", engVersion)
log.Println("Create", outFilename, "done!")
return outFilename
}