Exemple #1
0
func loadTemplates(templateDir, aHTMLTmplName, aIncTmplName string) (*template.Template, *template.Template, error) {
	tmplFuncs := tmplfn.Join(tmplfn.TimeMap, tmplfn.PageMap, cait.TmplMap)
	aHTMLTmpl, err := tmplfn.Assemble(tmplFuncs, path.Join(templateDir, aHTMLTmplName), path.Join(templateDir, aIncTmplName))
	if err != nil {
		return nil, nil, fmt.Errorf("Can't parse template %s, %s, %s", aHTMLTmplName, aIncTmplName, err)
	}
	aIncTmpl, err := tmplfn.Assemble(tmplFuncs, path.Join(templateDir, aIncTmplName))
	if err != nil {
		return aHTMLTmpl, nil, fmt.Errorf("Can't parse template %s, %s", aIncTmplName, err)
	}
	return aHTMLTmpl, aIncTmpl, nil
}
Exemple #2
0
	htdocsDir      string
	templatesDir   string
	siteURL        string
	webhookPath    string
	webhookSecret  string
	webhookCommand string
	enableSearch   bool

	advancedPage []byte
	basicPage    []byte

	indexAlias bleve.IndexAlias
	index      bleve.Index

	// Internal package var
	tmplFuncs = tmplfn.Join(tmplfn.TimeMap, tmplfn.PageMap, cait.TmplMap)
)

func mapToSearchQuery(m map[string]interface{}) (*cait.SearchQuery, error) {
	var err error

	// raw is a tempory data structure to sanitize the
	// form request submitted via the query.
	raw := &struct {
		Q         string `json:"q"`
		QExact    string `json:"q_exact"`
		QExcluded string `json:"q_excluded"`
		QRequired string `json:"q_required"`
		Size      int    `json:"size"`
		From      int    `json:"from"`
		AllIDs    bool   `json:"all_ids"`