-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplates.go
106 lines (103 loc) · 3.19 KB
/
templates.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
package periodize
const opfTemplateString = `<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="{{.UniqueID}}">
<metadata>
<meta content="cover-image" name="cover"/>
<dc-metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>{{.Title}}</dc:title>
<dc:language>en-us</dc:language>
<dc:creator>{{.Creator}}</dc:creator>
<dc:publisher>{{.Publisher}}</dc:publisher>
<dc:subject>{{.Subject}}</dc:subject>
<dc:date>{{.Date}}</dc:date>
<dc:description>{{.Description}}</dc:description>
</dc-metadata>
<x-metadata>
<output content-type="application/x-mobipocket-subscription-magazine" encoding="utf-8"/>
</x-metadata>
</metadata>
<manifest>
<item href="cover-image.gif" media-type="image/gif" id="cover-image"/>
<item href="contents.html" media-type="application/xhtml+xml" id="contents"/>
<item href="nav-contents.ncx" media-type="application/x-dtbncx+xml" id="nav-contents"/>
{{range .Sections}}
{{range .Articles}}
<item href="{{.Href}}" media-type="application/xhtml+xml" id="{{.PlayOrder}}"/>
{{end}}
{{end}}
</manifest>
<spine toc="nav-contents">
<itemref idref="contents"/>
{{range .Sections}}
{{range .Articles}}
<itemref idref="{{.PlayOrder}}"/>
{{end}}
{{end}}
</spine>
<guide>
<reference href="contents.html" type="toc" title="Table of Contents"/>
</guide>
</package>
`
const contentsTemplateString = `<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Table of Contents</title>
</head>
<body>
<h1>Contents</h1>
{{range .Sections}}
<h4>{{.Title}}</h4>
<ul>
{{range .Articles}}
<li>
<a href="{{.Href}}">{{.Title}}</a>
</li>
{{end}}
</ul>
{{end}}
</body>
</html>
`
const navTemplateString = `<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns:mbp="http://mobipocket.com/ns/mbp" xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en-US">
<head>
<meta content="Template" name="dtb:uid"/>
<meta content="2" name="dtb:depth"/>
<meta content="0" name="dtb:totalPageCount"/>
<meta content="0" name="dtb:maxPageNumber"/>
</head>
<docTitle>
<text>ncx:Title</text>
</docTitle>
<docAuthor>
<text>ncs:Author</text>
</docAuthor>
<navMap>
<navPoint playOrder="0" class="periodical" id="periodical">
<mbp:meta-img src="masthead.gif" name="mastheadImage"/>
<navLabel>
<text>Table of Contents</text>
</navLabel>
<content src="contents.html"/>
{{range .Sections}}
<navPoint playOrder="{{.PlayOrder}}" class="section" id="{{.SectionID}}">
<navLabel>
<text>{{.Title}}</text>
</navLabel>
<content src="{{.Href}}"/>
{{range .Articles}}
<navPoint playOrder="{{.PlayOrder}}" class="article" id="{{.PlayOrder}}">
<navLabel>
<text>{{.Title}}</text>
</navLabel>
<content src="{{.Href}}"/>
<mbp:meta name="description">{{.Title}}</mbp:meta>
<mbp:meta name="author">{{.Author}}</mbp:meta>
</navPoint>
{{end}}
</navPoint>
{{end}}
</navPoint>
</navMap>
</ncx>
`