Documentation ¶
Overview ¶
Package frontend provides the routing and middleware for the web app
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ParseTemplates = func() { templates = make(map[string]*template.Template) templates["about"] = template.Must( template.New("base.html"). Funcs(funcMap). ParseFiles( "templates/base.html", "templates/search_form.html", "templates/about.html", ), ) var err error t := template.New("tmp") t, err = t.Parse(`{{template "answer" .}}`) if err != nil { panic(err) } templates["answer"] = template.Must( t.Funcs(funcMap). ParseFiles( "templates/wikipedia.html", "templates/answer.html", ), ) templates["maps"] = template.Must( template.New("maps.html"). Funcs(funcMap). ParseFiles( "templates/maps.html", ), ) templates["opensearch"] = template.Must( template.New("opensearch.xml"). ParseFiles( "templates/opensearch.xml", ), ) templates["proxy_header"] = template.Must( template.New("base.html"). Funcs(funcMap). ParseFiles( "templates/base.html", "templates/search_form.html", "templates/proxy_header.html", ), ) templates["proxy"] = template.Must( template.New("base.html"). Funcs(funcMap). ParseFiles( "templates/base.html", "templates/search_form.html", "templates/proxy.html", ), ) templates["search"] = template.Must( template.New("base.html"). Funcs(funcMap). ParseFiles( "templates/base.html", "templates/answer.html", "templates/search_form.html", "templates/search.html", "templates/wikipedia.html", ), ) }
ParseTemplates parses our html templates.
Functions ¶
This section is empty.
Types ¶
type AnswerResponse ¶
type AnswerResponse struct { HTML string `json:"html"` CSS []string `json:"css"` JavaScript []string `json:"javascript"` }
AnswerResponse is an instant answer response
type Context ¶
type Context struct { Q string `json:"query"` L string `json:"-"` D string `json:"-"` F search.Filter `json:"-"` POST bool `json:"-"` R string `json:"-"` S string `json:"-"` N string `json:"-"` T string `json:"-"` Ref string `json:"-"` Safe bool `json:"-"` DefaultBangs []DefaultBang `json:"-"` Preferred []language.Tag `json:"-"` Region language.Region `json:"-"` Number int `json:"-"` Page int `json:"-"` Theme string `json:"-"` // contains filtered or unexported fields }
Context holds a user's request context so we can pass it to our template's form. Query, Language, and Region are the RAW query string variables.
type DefaultBang ¶
DefaultBang is the user's preffered !bang
type Frontend ¶
type Frontend struct { Brand Document *bangs.Bangs Cache struct { cache.Cacher Instant time.Duration Search time.Duration } Images struct { img.Fetcher *http.Client } *instant.Instant MapBoxKey string Onion string ProxyClient *http.Client Suggest suggest.Suggester Search search.Fetcher Wikipedia GitHub }
Frontend holds settings for branding, cache, search backend, etc.
type Instant ¶
Instant is a wrapper to facilitate custom unmarshalling
func (*Instant) UnmarshalJSON ¶
UnmarshalJSON unmarshals an instant answer to the correct data structure
Source Files ¶
Click to show internal directories.
Click to hide internal directories.