-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbook.go
More file actions
56 lines (48 loc) · 1022 Bytes
/
book.go
File metadata and controls
56 lines (48 loc) · 1022 Bytes
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
50
51
52
53
54
55
56
package pamphlet
import (
"errors"
)
const (
HTMLMimetype = "application/xhtml+xml"
SVGMimetype = "image/svg+xml"
)
type Book struct {
Title string
Author string
Language string
Identifier string
Publisher string
Description string
Subject string
Date string
Chapters []Chapter
ManifestItems []ManifestItem
}
type Chapter struct {
ZipFile
// ID is the idref attribute in the spine tag
ID string
Title string
Href string
MediaType string
HasToc bool
// order of the chapter in the book, based on the toc file's playerOrder attribute
Order int
}
func (c *Chapter) GetContent() (string, error) {
if c.MediaType != HTMLMimetype && c.MediaType != SVGMimetype {
return "", errors.New("unsupported media type")
}
content, err := c.GetRawContent()
if err != nil {
return "", err
}
return string(content), nil
}
type ManifestItem struct {
ZipFile
ID string
Href string
RealPath string
MediaType string
}