frontend

package
v0.0.0-...-73de0e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

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["search"] = template.Must(
		template.New("base.html").
			Funcs(funcMap).
			ParseFiles(
				"templates/base.html",
				"templates/main.css",
				"templates/search.html",
			),
	)
}

ParseTemplates parses our html templates.

Functions

This section is empty.

Types

type Context

type Context struct {
	Q         string          `json:"query"`
	L         string          `json:"-"`
	R         string          `json:"-"`
	N         string          `json:"-"`
	Preferred []language.Tag  `json:"-"`
	Region    language.Region `json:"-"`
	Number    int             `json:"-"`
	Page      int             `json:"-"`
}

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 Document

type Document struct {
	Languages []language.Tag
	language.Matcher
}

Document has the languages we support

type Frontend

type Frontend struct {
	Document
	*bangs.Bangs
	Suggest suggest.Suggester
	Search  search.Fetcher
	Wikipedia
	Vote vote.Voter
}

Frontend holds settings for our languages supported, backend, etc. better name???

func (*Frontend) Router

func (f *Frontend) Router(cfg config.Provider) *mux.Router

Router sets up the routes & handlers

type Results

type Results struct {
	Alternative string           `json:"alternative"`
	Instant     instant.Solution `json:"instant"`
	Search      *search.Results  `json:"search"`
	Wikipedia   *wikipedia.Item  `json:"wikipedia"`
}

Results is the results from search, instant, wikipedia, etc

type Wikipedia

type Wikipedia struct {
	language.Matcher
	wikipedia.Fetcher
}

Wikipedia holds our settings for wikipedia/wikidata Note: language matcher here may be different than that for document due to available languages Wikipedia supports

Directories

Path Synopsis
Command frontend demonstrates how to run the web app
Command frontend demonstrates how to run the web app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL