forked from hound-search/hound
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.go
66 lines (52 loc) · 1.4 KB
/
content.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
package ui
import "io"
// Current versions of some dependencies.
const (
ReactVersion = "0.12.2"
JQueryVersion = "2.1.3"
)
var contents map[string]*content
// This interface abstracts the Execute method on template which is
// structurally similar in both html/template and text/template.
// We need to use an interface instead of a direct template field
// because then we will need two different fields for html template
// and text template.
type renderer interface {
Execute(w io.Writer, data interface{}) error
}
type content struct {
// The uri for accessing this asset
uri string
// The filename of the template relative to the asset directory
template string
// The JavaScript sources used in this HTML page
sources []string
// The parsed template - can be of html/template or text/template type
tpl renderer
// This is used to determine if a template is to be parsed as text or html
tplType string
}
func init() {
// The following are HTML assets that are rendered via
// template.
contents = map[string]*content{
"/": &content{
template: "index.tpl.html",
sources: []string{
"js/hound.js",
},
tplType: "html",
},
"/open_search.xml": &content{
template: "open_search.tpl.xml",
tplType: "xml",
},
"/excluded_files.html": &content{
template: "excluded_files.tpl.html",
sources: []string{
"js/excluded_files.js",
},
tplType: "html",
},
}
}