/* Copyright 2013 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package importer import ( "bytes" "fmt" "html/template" "net/http" "strings" "time" ) func execTemplate(w http.ResponseWriter, r *http.Request, data interface{}) { tmplName := strings.TrimPrefix(fmt.Sprintf("%T", data), "importer.") var buf bytes.Buffer err := tmpl.ExecuteTemplate(&buf, tmplName, data) if err != nil { http.Error(w, fmt.Sprintf("Error executing template %q: %v", tmplName, err), 500) return } w.Write(buf.Bytes()) } type importersRootPage struct { Title string Body importersRootBody } type importersRootBody struct { BasePath string Importers []*importer } type importerPage struct { Title string Body importerBody } type importerBody struct { BasePath string Importer *importer SetupHelp template.HTML } type acctPage struct { Title string Body acctBody } type acctBody struct { Acct *importerAcct AcctType string Running bool LastStatus string StartedAgo time.Duration // or zero if !Running LastAgo time.Duration // non-zero if previous run && !Running LastError string } var tmpl = template.Must(template.New("root").Parse(` {{define "pageTop"}}
[<< Back]
[<< Back]