-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.go
156 lines (137 loc) · 5.74 KB
/
schema.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package comicinfo
var xmlHeader = []byte(`<?xml version="1.0" encoding="UTF-8"?>`)
// ComicInfo ...
type ComicInfo struct {
Title string `xml:"Title,omitempty"`
Series string `xml:"Series,omitempty"`
Number string `xml:"Number,omitempty"`
Count int `xml:"Count,omitempty"`
Volume int `xml:"Volume,omitempty"`
AlternateSeries string `xml:"AlternateSeries,omitempty"`
AlternateNumber string `xml:"AlternateNumber,omitempty"`
AlternateCount int `xml:"AlternateCount,omitempty"`
Summary string `xml:"Summary,omitempty"`
Notes string `xml:"Notes,omitempty"`
Year int `xml:"Year,omitempty"`
Month int `xml:"Month,omitempty"`
Day int `xml:"Day,omitempty"`
Writer string `xml:"Writer,omitempty"`
Penciller string `xml:"Penciller,omitempty"`
Inker string `xml:"Inker,omitempty"`
Colorist string `xml:"Colorist,omitempty"`
Letterer string `xml:"Letterer,omitempty"`
CoverArtist string `xml:"CoverArtist,omitempty"`
Editor string `xml:"Editor,omitempty"`
Publisher string `xml:"Publisher,omitempty"`
Imprint string `xml:"Imprint,omitempty"`
Genre string `xml:"Genre,omitempty"`
Web string `xml:"Web,omitempty"`
PageCount int `xml:"PageCount,omitempty"`
LanguageISO string `xml:"LanguageISO,omitempty"`
Format string `xml:"Format,omitempty"`
BlackAndWhite YesNo `xml:"BlackAndWhite,omitempty"`
Manga Manga `xml:"Manga,omitempty"`
Characters string `xml:"Characters,omitempty"`
Teams string `xml:"Teams,omitempty"`
Locations string `xml:"Locations,omitempty"`
ScanInformation string `xml:"ScanInformation,omitempty"`
StoryArc string `xml:"StoryArc,omitempty"`
SeriesGroup string `xml:"SeriesGroup,omitempty"`
AgeRating AgeRating `xml:"AgeRating,omitempty"`
Pages Pages `xml:"Pages,omitempty"`
CommunityRating Rating `xml:"CommunityRating,omitempty"`
MainCharacterOrTeam string `xml:"MainCharacterOrTeam,omitempty"`
Review string `xml:"Review,omitempty"`
// Internal
XmlnsXsd string `xml:"xmlns:xsd,attr"`
XmlNsXsi string `xml:"xmlns:xsi,attr"`
// XsiSchemaLocation string `xml:"xsi:schemaLocation,attr,omitempty"`
}
func (ci *ComicInfo) SetXMLAttributes() {
ci.XmlnsXsd = "http://www.w3.org/2001/XMLSchema"
ci.XmlNsXsi = "http://www.w3.org/2001/XMLSchema-instance"
}
// New provides a new ComicInfo struct with the XML attributes set
func NewComicInfo() *ComicInfo {
ci := ComicInfo{}
ci.SetXMLAttributes()
return &ci
}
// YesNo defines the YesNo type
type YesNo string
var (
YesNoUnknown YesNo = "Unknown"
Yes YesNo = "Yes"
No YesNo = "No"
)
// Manga defines the Manga type
type Manga string
var (
MangaUnknown Manga = "Unknown"
MangaYes Manga = "Yes"
MangaNo Manga = "No"
MangeYesAndRightToLeft Manga = "YesAndRightToLeft"
)
// Rating defines the Rating type
type Rating float64
// AgeRating defines the AgeRating type
type AgeRating string
var (
AgeRatingUnknown AgeRating = "Unknown"
AgeRatingAdultsOnlyPlus18 AgeRating = "Adults Only 18+"
AgeRatingEarlyChildhood AgeRating = "Early Childhood"
AgeRatingEveryone AgeRating = "Everyone"
AgeRatingEveryone10Plus AgeRating = "Everyone 10+"
AgeRatingG AgeRating = "G"
AgeRatingKidsToAdults AgeRating = "Kids to Adults"
AgeRatingM AgeRating = "M"
AgeRatingMAPlus15 AgeRating = "MA15+"
AgeRatingMaturePlus17 AgeRating = "Mature 17+"
AgeRatingPG AgeRating = "PG"
AgeRatingRPlus18 AgeRating = "R18+"
AgeRatingPending AgeRating = "Rating Pending"
AgeRatingTeen AgeRating = "Teen"
AgeRatingXPlus18 AgeRating = "X18+"
)
// Pages defines the Pages type (slice of ComicPageInfo for proper XML marshalling)
type Pages struct {
Pages []ComicPageInfo `xml:"Page,omitempty"`
}
func (p *Pages) Append(page ComicPageInfo) {
p.Pages = append(p.Pages, page)
}
func (p *Pages) Len() int {
return len(p.Pages)
}
// ComicPageInfo defines the ComicPageInfo type
type ComicPageInfo struct {
Image int `xml:"Image,attr"`
Type ComicPageType `xml:"Type,omitempty,attr"`
DoublePage bool `xml:"DoublePage,omitempty,attr"`
ImageSize int64 `xml:"ImageSize,omitempty,attr"`
Key string `xml:"Key,omitempty,attr"`
Bookmark string `xml:"Bookmark,omitempty,attr"`
ImageWidth int `xml:"ImageWidth,omitempty,attr"`
ImageHeight int `xml:"ImageHeight,omitempty,attr"`
}
// NewComicPageInfo provides a new ComicPageInfo struct with the XML attributes set
func NewComicPageInfo() ComicPageInfo {
return ComicPageInfo{
Type: ComicPageTypeStory,
}
}
// ComicPageType defines the ComicPageType type
type ComicPageType string
var (
ComicPageTypeFrontCover ComicPageType = "FrontCover"
ComicPageTypeInnerCover ComicPageType = "InnerCover"
ComicPageTypeRoundup ComicPageType = "Roundup"
ComicPageTypeStory ComicPageType = "Story"
ComicPageTypeAdvertisement ComicPageType = "Advertisement"
ComicPageTypeEditorial ComicPageType = "Editorial"
ComicPageTypeLetters ComicPageType = "Letters"
ComicPageTypePreview ComicPageType = "Preview"
ComicPageTypeBackCover ComicPageType = "BackCover"
ComicPageTypeOther ComicPageType = "Other"
ComicPageTypeDeleted ComicPageType = "Deleted"
)