Documentation
¶
Index ¶
- func Register(name string, priority int, fn NewCardFunc)
- type CalcCard
- func (cc *CalcCard) Content() template.HTML
- func (cc *CalcCard) Footer() template.HTML
- func (cc *CalcCard) Head() template.HTML
- func (cc *CalcCard) Matches() bool
- func (cc *CalcCard) Returned() bool
- func (cc *CalcCard) RunQuery() error
- func (cc *CalcCard) StripKey() string
- func (cc *CalcCard) Title() string
- type Card
- type DDGCard
- func (ddg *DDGCard) Content() template.HTML
- func (ddg *DDGCard) Footer() template.HTML
- func (ddg *DDGCard) Head() template.HTML
- func (ddg *DDGCard) Matches() bool
- func (ddg *DDGCard) Returned() bool
- func (ddg *DDGCard) RunQuery() error
- func (ddg *DDGCard) StripKey() string
- func (ddg *DDGCard) Title() string
- type DDGInstAns
- type MetaweatherCard
- func (mc *MetaweatherCard) Content() template.HTML
- func (mc *MetaweatherCard) Footer() template.HTML
- func (mc *MetaweatherCard) Head() template.HTML
- func (mc *MetaweatherCard) Matches() bool
- func (mc *MetaweatherCard) Returned() bool
- func (mc *MetaweatherCard) RunQuery() error
- func (mc *MetaweatherCard) StripKey() string
- func (mc *MetaweatherCard) Title() string
- type MetaweatherLocation
- type MetaweatherResponse
- type NewCardFunc
- type PlotCard
- func (pc *PlotCard) Content() template.HTML
- func (pc *PlotCard) Footer() template.HTML
- func (pc *PlotCard) Head() template.HTML
- func (pc *PlotCard) Matches() bool
- func (pc *PlotCard) Returned() bool
- func (pc *PlotCard) RunQuery() error
- func (pc *PlotCard) StripKey() string
- func (pc *PlotCard) Title() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, priority int, fn NewCardFunc)
Register adds a new card to the library
Types ¶
type CalcCard ¶
type CalcCard struct {
// contains filtered or unexported fields
}
CalcCard represents a calculation card
func (*CalcCard) Content ¶
Content returns the solveRenderScript with the given input
func (*CalcCard) Footer ¶
Footer returns empty string because CalcCard has no footer
func (*CalcCard) Head ¶
Head returns the extra head tags required for CalcCard
func (*CalcCard) Matches ¶
Matches determines whether a query matches the requirements fot CalcCard and determines which function to run with what arguments
func (*CalcCard) Returned ¶
Returned always returns true since CalcCard is a frontend card and it is thus impossible to determine whether the query gets an answer
func (*CalcCard) RunQuery ¶
RunQuery returns nil as CalcCard is a frontend card
func (*CalcCard) StripKey ¶
StripKey removes all key words related to CalcCard
type Card ¶
type Card interface { // RunQuery runs any HTTP or other requests RunQuery() error // Returned returns whether the query // returned any information Returned() bool // Matches returns whether the query matches // for the card Matches() bool // StripKey removes the key words and returns // the updated query StripKey() string // Title returns the card title Title() string // Content returns the contents of the card Content() template.HTML Footer() template.HTML // Head returns any extras to include in <head> Head() template.HTML }
Card represents a search result card
func GetCard ¶
GetCard returns a matching registered card
func NewCalcCard ¶
NewCalcCard is a NewCardFunc that creates a new CalcCard
func NewDDGCard ¶
NewDDGCard is a NewCardFunc that creates a new DDGCard
func NewMetaweatherCard ¶
NewMetaweatherCard is a NewCardFunc that creates a new MetaweatherCard
type DDGCard ¶
type DDGCard struct {
// contains filtered or unexported fields
}
DDGCard represents a DuckDuckGo Instant Answer API card
func (*DDGCard) Content ¶
Content returns the instant answer abstract with DuckDuckGo attibution
func (*DDGCard) Footer ¶
Footer returns a footer containing URL and name of source gotten from instant answer API
func (*DDGCard) Head ¶
Head returns an empty string as no extra tags are reuired for DDGCard
func (*DDGCard) Matches ¶
Matches always returns true as there are no keys
func (*DDGCard) Returned ¶
Returned checks if abstract is empty. If it is, query returned no result.
func (*DDGCard) RunQuery ¶
RunQuery requests the query from the instant answer API
func (*DDGCard) StripKey ¶
StripKey returns the query as there are no keys
type DDGInstAns ¶
type DDGInstAns struct { Abstract string AbstractText string AbstractSource string AbstractURL string Image string Heading string Answer string AnswerType string }
DDGInstAns represents a DuckDuckGo Instant Answer API response
type MetaweatherCard ¶
type MetaweatherCard struct {
// contains filtered or unexported fields
}
MetaweatherCard represents a metaweather card
func (*MetaweatherCard) Content ¶
func (mc *MetaweatherCard) Content() template.HTML
Content returns metaweatherContent with all information added
func (*MetaweatherCard) Footer ¶
func (mc *MetaweatherCard) Footer() template.HTML
Footer returns a footer with a link to metaweather
func (*MetaweatherCard) Head ¶
func (mc *MetaweatherCard) Head() template.HTML
Head returns an empty string as no extra head tags are required for MetaweatherCard
func (*MetaweatherCard) Matches ¶
func (mc *MetaweatherCard) Matches() bool
Matches determines whether the query matches the keys for MetaweatherCard
func (*MetaweatherCard) Returned ¶
func (mc *MetaweatherCard) Returned() bool
Returned checks whether no location was found or response said not found.
func (*MetaweatherCard) RunQuery ¶
func (mc *MetaweatherCard) RunQuery() error
RunQuery searches for the location and then runs an API query using the returned WOEID
func (*MetaweatherCard) StripKey ¶
func (mc *MetaweatherCard) StripKey() string
StripKey removes keys related to MetaweatherCard
func (*MetaweatherCard) Title ¶
func (mc *MetaweatherCard) Title() string
Title of MetaweatherCard is "Weather"
type MetaweatherLocation ¶
MetaweatherLocation represents a location
type MetaweatherResponse ¶
type MetaweatherResponse struct { Detail string `json:"detail"` Title string `json:"title"` Timezone string `json:"timezone"` Consolidated []struct { ID int `json:"id"` State string `json:"weather_state_name"` StateAbbr string `json:"weather_state_abbr"` WindCompass string `json:"wind_direction_compass"` MinTemp float64 `json:"min_temp"` MaxTemp float64 `json:"max_temp"` CurrentTemp float64 `json:"the_temp"` WindSpeed float64 `json:"wind_speed"` WindDirection float64 `json:"wind_direction"` AirPressure float64 `json:"air_pressure"` Visibility float64 `json:"visibility"` Humidity int `json:"humidity"` Predictability int `json:"predictability"` } `json:"consolidated_weather"` }
MetaweatherResponse represents a response from the metaweather API
type NewCardFunc ¶
NewCardFunc creates and returns a new card. This should not be an expensive operation
type PlotCard ¶
type PlotCard struct {
// contains filtered or unexported fields
}
PlotCard represents a card with an equation plot
func (*PlotCard) Content ¶
Content returns plot script with given input
func (*PlotCard) Footer ¶
Footer returns an empty string as PlotCard has no footer
func (*PlotCard) Head ¶
Head returns extra head tags for PlotCard
func (*PlotCard) Matches ¶
Matches checks if the query matches the rules for PlotCard
func (*PlotCard) Returned ¶
Returned will alwats return true because this card is frontend, and this cannot be checked.
func (*PlotCard) RunQuery ¶
RunQuery returns nil as PlotCard is a frontend card
func (*PlotCard) StripKey ¶
StripKey removes all keys related to PlotCard