Documentation
¶
Index ¶
- Variables
- func DetectCarrierFromNumber(trackingNumber string) (name, code, url string, detected bool)
- func ExtractFoodItem(query string) string
- func GetSupportedCarriers() []struct{ ... }
- func IsNutritionQuery(query string) bool
- func ValidateTrackingNumber(trackingNumber string) bool
- type AtomEntry
- type AtomFeed
- type AtomLink
- type Cache
- type CacheItem
- type CarrierInfo
- type CoinData
- type CoinGeckoResponse
- type CryptoData
- type CryptoFetcher
- type CurrencyData
- type CurrencyFetcher
- type DictionaryData
- type DictionaryDefinition
- type DictionaryFetcher
- type DictionaryMeaning
- type Fetcher
- type GameData
- type GameStatus
- type GeocodingResponse
- type MacroNutrients
- type Manager
- func (m *Manager) Close()
- func (m *Manager) FetchWidgetData(ctx context.Context, widgetType WidgetType, params map[string]string) (*WidgetData, error)
- func (m *Manager) GetAllWidgets() []*Widget
- func (m *Manager) GetConfig() *config.WidgetsConfig
- func (m *Manager) GetDefaultWidgets() []string
- func (m *Manager) GetWidget(widgetType WidgetType) *Widget
- func (m *Manager) GetWidgetsByCategory(category WidgetCategory) []*Widget
- func (m *Manager) IsEnabled() bool
- func (m *Manager) IsWidgetEnabled(widgetType WidgetType) bool
- func (m *Manager) RegisterFetcher(fetcher Fetcher)
- type NewsData
- type NewsFetcher
- type NewsItem
- type NutrientInfo
- type NutritionData
- type NutritionFetcher
- type OpenMeteoResponse
- type RSSChannel
- type RSSData
- type RSSFeed
- type RSSFetcher
- type RSSItem
- type RSSItemData
- type RelatedArticle
- type ServingSize
- type SportsData
- type SportsFetcher
- type StockQuote
- type StocksData
- type StocksFetcher
- type TeamStats
- type TrackingConfig
- type TrackingData
- type TrackingEvent
- type TrackingFetcher
- type TranslateData
- type TranslateFetcher
- type TranslateQuery
- type WeatherData
- type WeatherFetcher
- type Widget
- type WidgetCategory
- type WidgetData
- type WidgetType
- type WikipediaData
- type WikipediaFetcher
- type YahooFinanceResponse
Constants ¶
This section is empty.
Variables ¶
var CommonCurrencies = []struct { Code string `json:"code"` Name string `json:"name"` Symbol string `json:"symbol"` }{ {"USD", "US Dollar", "$"}, {"EUR", "Euro", "€"}, {"GBP", "British Pound", "£"}, {"JPY", "Japanese Yen", "¥"}, {"CNY", "Chinese Yuan", "¥"}, {"AUD", "Australian Dollar", "A$"}, {"CAD", "Canadian Dollar", "C$"}, {"CHF", "Swiss Franc", "Fr"}, {"INR", "Indian Rupee", "₹"}, {"MXN", "Mexican Peso", "$"}, {"BRL", "Brazilian Real", "R$"}, {"KRW", "South Korean Won", "₩"}, {"RUB", "Russian Ruble", "₽"}, {"SGD", "Singapore Dollar", "S$"}, {"HKD", "Hong Kong Dollar", "HK$"}, {"NZD", "New Zealand Dollar", "NZ$"}, {"SEK", "Swedish Krona", "kr"}, {"NOK", "Norwegian Krone", "kr"}, {"DKK", "Danish Krone", "kr"}, {"ZAR", "South African Rand", "R"}, }
Common currency codes for the widget UI
var SupportedLanguages = []struct { Code string `json:"code"` Name string `json:"name"` }{ {"en", "English"}, {"es", "Spanish"}, {"fr", "French"}, {"de", "German"}, {"it", "Italian"}, {"pt", "Portuguese"}, {"ru", "Russian"}, {"ja", "Japanese"}, {"ko", "Korean"}, {"zh", "Chinese"}, {"ar", "Arabic"}, {"hi", "Hindi"}, {"nl", "Dutch"}, {"pl", "Polish"}, {"tr", "Turkish"}, {"vi", "Vietnamese"}, {"th", "Thai"}, {"id", "Indonesian"}, {"sv", "Swedish"}, {"da", "Danish"}, }
SupportedLanguages returns common translation languages
Functions ¶
func DetectCarrierFromNumber ¶
DetectCarrierFromNumber is a public helper to detect carrier without creating a fetcher
func ExtractFoodItem ¶
ExtractFoodItem extracts the food item from a natural language nutrition query
func GetSupportedCarriers ¶
GetSupportedCarriers returns a list of supported carriers
func IsNutritionQuery ¶
IsNutritionQuery checks if a query is related to nutrition
func ValidateTrackingNumber ¶
ValidateTrackingNumber checks if a tracking number matches any known carrier pattern
Types ¶
type AtomFeed ¶
type AtomFeed struct {
XMLName xml.Name `xml:"feed"`
Title string `xml:"title"`
Entries []AtomEntry `xml:"entry"`
}
Atom feed structures
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides thread-safe caching for widget data
func (*Cache) Get ¶
func (c *Cache) Get(key string) (*WidgetData, bool)
Get retrieves an item from the cache
type CacheItem ¶
type CacheItem struct {
Data *WidgetData
ExpiresAt time.Time
}
CacheItem represents a cached item with expiration
type CarrierInfo ¶
type CarrierInfo struct {
Name string
Code string
Pattern *regexp.Regexp
TrackURL string
Priority int // Higher priority patterns are checked first
}
CarrierInfo represents carrier detection info
type CoinData ¶
type CoinData struct {
ID string `json:"id"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Price float64 `json:"price"`
Change24h float64 `json:"change_24h"`
MarketCap float64 `json:"market_cap,omitempty"`
Volume24h float64 `json:"volume_24h,omitempty"`
}
CoinData represents data for a single cryptocurrency
type CoinGeckoResponse ¶
type CoinGeckoResponse map[string]struct { USD float64 `json:"usd"` EUR float64 `json:"eur"` GBP float64 `json:"gbp"` USDChange24h float64 `json:"usd_24h_change"` EURChange24h float64 `json:"eur_24h_change"` GBPChange24h float64 `json:"gbp_24h_change"` USDMarketCap float64 `json:"usd_market_cap"` USDVolume24h float64 `json:"usd_24h_vol"` }
CoinGeckoResponse represents CoinGecko API response
type CryptoData ¶
type CryptoData struct {
Coins []CoinData `json:"coins"`
}
CryptoData represents crypto widget data
type CryptoFetcher ¶
type CryptoFetcher struct {
// contains filtered or unexported fields
}
CryptoFetcher fetches cryptocurrency prices from CoinGecko API
func NewCryptoFetcher ¶
func NewCryptoFetcher(cfg *config.CryptoWidgetConfig) *CryptoFetcher
NewCryptoFetcher creates a new crypto fetcher
func (*CryptoFetcher) CacheDuration ¶
func (f *CryptoFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data
func (*CryptoFetcher) Fetch ¶
func (f *CryptoFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches crypto prices
func (*CryptoFetcher) WidgetType ¶
func (f *CryptoFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type CurrencyData ¶
type CurrencyData struct {
From string `json:"from"`
To string `json:"to"`
Amount float64 `json:"amount"`
Result float64 `json:"result"`
Rate float64 `json:"rate"`
RateDate string `json:"rate_date"`
Rates map[string]float64 `json:"rates,omitempty"`
}
CurrencyData represents currency conversion result
type CurrencyFetcher ¶
type CurrencyFetcher struct {
// contains filtered or unexported fields
}
CurrencyFetcher fetches currency exchange rates
func NewCurrencyFetcher ¶
func NewCurrencyFetcher(apiKey string) *CurrencyFetcher
NewCurrencyFetcher creates a new currency fetcher
func (*CurrencyFetcher) CacheDuration ¶
func (f *CurrencyFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache currency data
func (*CurrencyFetcher) Fetch ¶
func (f *CurrencyFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches currency conversion data
func (*CurrencyFetcher) WidgetType ¶
func (f *CurrencyFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type DictionaryData ¶
type DictionaryData struct {
Word string `json:"word"`
Phonetic string `json:"phonetic,omitempty"`
Audio string `json:"audio,omitempty"`
Meanings []DictionaryMeaning `json:"meanings"`
Synonyms []string `json:"synonyms,omitempty"`
Antonyms []string `json:"antonyms,omitempty"`
}
DictionaryData represents dictionary lookup result
type DictionaryDefinition ¶
type DictionaryDefinition struct {
Definition string `json:"definition"`
Example string `json:"example,omitempty"`
Synonyms []string `json:"synonyms,omitempty"`
Antonyms []string `json:"antonyms,omitempty"`
}
DictionaryDefinition represents a single definition
type DictionaryFetcher ¶
type DictionaryFetcher struct {
// contains filtered or unexported fields
}
DictionaryFetcher fetches word definitions
func NewDictionaryFetcher ¶
func NewDictionaryFetcher() *DictionaryFetcher
NewDictionaryFetcher creates a new dictionary fetcher
func (*DictionaryFetcher) CacheDuration ¶
func (f *DictionaryFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache dictionary data
func (*DictionaryFetcher) Fetch ¶
func (f *DictionaryFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches dictionary definition
func (*DictionaryFetcher) WidgetType ¶
func (f *DictionaryFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type DictionaryMeaning ¶
type DictionaryMeaning struct {
PartOfSpeech string `json:"part_of_speech"`
Definitions []DictionaryDefinition `json:"definitions"`
}
DictionaryMeaning represents a word meaning
type Fetcher ¶
type Fetcher interface {
Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
CacheDuration() time.Duration
WidgetType() WidgetType
}
Fetcher is the interface for widgets that fetch external data
type GameData ¶
type GameData struct {
ID string `json:"id"`
League string `json:"league"`
LeagueID string `json:"league_id,omitempty"`
Season string `json:"season,omitempty"`
HomeTeam string `json:"home_team"`
HomeTeamID string `json:"home_team_id,omitempty"`
HomeTeamBadge string `json:"home_team_badge,omitempty"`
AwayTeam string `json:"away_team"`
AwayTeamID string `json:"away_team_id,omitempty"`
AwayTeamBadge string `json:"away_team_badge,omitempty"`
HomeScore *int `json:"home_score"` // Pointer to distinguish 0 from not played
AwayScore *int `json:"away_score"`
Status GameStatus `json:"status"`
StatusDetail string `json:"status_detail,omitempty"` // e.g., "Q3 5:30", "Final", "7:00 PM ET"
StartTime string `json:"start_time,omitempty"` // ISO 8601 format
Venue string `json:"venue,omitempty"`
Round string `json:"round,omitempty"`
// Additional stats if available
HomeStats *TeamStats `json:"home_stats,omitempty"`
AwayStats *TeamStats `json:"away_stats,omitempty"`
}
GameData represents data for a single game
type GameStatus ¶
type GameStatus string
GameStatus represents the status of a game
const ( GameStatusScheduled GameStatus = "scheduled" GameStatusLive GameStatus = "live" GameStatusFinal GameStatus = "final" GameStatusPostponed GameStatus = "postponed" GameStatusCanceled GameStatus = "canceled" )
type GeocodingResponse ¶
type GeocodingResponse struct {
Results []struct {
Name string `json:"name"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Country string `json:"country"`
Admin1 string `json:"admin1"` // State/Region
} `json:"results"`
}
GeocodingResponse represents Open-Meteo geocoding API response
type MacroNutrients ¶
type MacroNutrients struct {
Protein float64 `json:"protein"`
Carbohydrates float64 `json:"carbohydrates"`
Fat float64 `json:"fat"`
Fiber float64 `json:"fiber,omitempty"`
Sugar float64 `json:"sugar,omitempty"`
SaturatedFat float64 `json:"saturated_fat,omitempty"`
}
MacroNutrients represents macronutrient values
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages widgets and their data fetching
func NewManager ¶
func NewManager(cfg *config.WidgetsConfig) *Manager
NewManager creates a new widget manager
func (*Manager) FetchWidgetData ¶
func (m *Manager) FetchWidgetData(ctx context.Context, widgetType WidgetType, params map[string]string) (*WidgetData, error)
FetchWidgetData fetches data for a data widget
func (*Manager) GetAllWidgets ¶
GetAllWidgets returns all available widgets
func (*Manager) GetConfig ¶
func (m *Manager) GetConfig() *config.WidgetsConfig
GetConfig returns the widgets configuration
func (*Manager) GetDefaultWidgets ¶
GetDefaultWidgets returns the default enabled widgets
func (*Manager) GetWidget ¶
func (m *Manager) GetWidget(widgetType WidgetType) *Widget
GetWidget returns a widget definition by type
func (*Manager) GetWidgetsByCategory ¶
func (m *Manager) GetWidgetsByCategory(category WidgetCategory) []*Widget
GetWidgetsByCategory returns widgets filtered by category
func (*Manager) IsEnabled ¶
IsEnabled returns whether widgets are enabled Widgets are always enabled - users control via localStorage
func (*Manager) IsWidgetEnabled ¶
func (m *Manager) IsWidgetEnabled(widgetType WidgetType) bool
IsWidgetEnabled checks if a specific widget type is enabled All widgets are always enabled - users control via localStorage Data widgets that require API keys will return appropriate errors from their fetchers
func (*Manager) RegisterFetcher ¶
RegisterFetcher registers a data fetcher for a widget type
type NewsData ¶
type NewsData struct {
Items []NewsItem `json:"items"`
}
NewsData represents news widget data
type NewsFetcher ¶
type NewsFetcher struct {
// contains filtered or unexported fields
}
NewsFetcher fetches news from RSS feeds
func NewNewsFetcher ¶
func NewNewsFetcher(cfg *config.NewsWidgetConfig) *NewsFetcher
NewNewsFetcher creates a new news fetcher
func (*NewsFetcher) CacheDuration ¶
func (f *NewsFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data
func (*NewsFetcher) Fetch ¶
func (f *NewsFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches news from configured RSS feeds
func (*NewsFetcher) WidgetType ¶
func (f *NewsFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type NewsItem ¶
type NewsItem struct {
Title string `json:"title"`
URL string `json:"url"`
Source string `json:"source"`
PublishedAt time.Time `json:"published_at"`
Summary string `json:"summary,omitempty"`
}
NewsItem represents a single news item
type NutrientInfo ¶
type NutrientInfo struct {
Name string `json:"name"`
Amount float64 `json:"amount"`
Unit string `json:"unit"`
DV float64 `json:"dv,omitempty"` // Daily value percentage
}
NutrientInfo represents a single nutrient value
type NutritionData ¶
type NutritionData struct {
Name string `json:"name"`
BrandName string `json:"brand_name,omitempty"`
Category string `json:"category,omitempty"`
ServingSize string `json:"serving_size"`
ServingSizes []ServingSize `json:"serving_sizes,omitempty"`
Calories float64 `json:"calories"`
Macros MacroNutrients `json:"macros"`
Micros []NutrientInfo `json:"micros,omitempty"`
Source string `json:"source"`
FDCId string `json:"fdc_id,omitempty"`
}
NutritionData represents nutrition facts result
type NutritionFetcher ¶
type NutritionFetcher struct {
// contains filtered or unexported fields
}
NutritionFetcher fetches nutrition facts from USDA FoodData Central and Open Food Facts
func NewNutritionFetcher ¶
func NewNutritionFetcher(usdaAPIKey string) *NutritionFetcher
NewNutritionFetcher creates a new nutrition fetcher usdaAPIKey is optional - if empty, uses DEMO_KEY (limited requests)
func (*NutritionFetcher) CacheDuration ¶
func (f *NutritionFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache nutrition data (24 hours since nutritional data is static)
func (*NutritionFetcher) Fetch ¶
func (f *NutritionFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches nutrition facts
func (*NutritionFetcher) WidgetType ¶
func (f *NutritionFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type OpenMeteoResponse ¶
type OpenMeteoResponse struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
CurrentWeather struct {
Temperature float64 `json:"temperature"`
WindSpeed float64 `json:"windspeed"`
WindDirection int `json:"winddirection"`
WeatherCode int `json:"weathercode"`
IsDay int `json:"is_day"`
Time string `json:"time"`
} `json:"current_weather"`
Hourly struct {
RelativeHumidity2m []int `json:"relativehumidity_2m"`
ApparentTemperature []float64 `json:"apparent_temperature"`
} `json:"hourly"`
}
OpenMeteoResponse represents Open-Meteo weather API response
type RSSChannel ¶
type RSSData ¶
type RSSData struct {
Items []RSSItemData `json:"items"`
}
RSSData represents RSS widget data
type RSSFeed ¶
type RSSFeed struct {
XMLName xml.Name `xml:"rss"`
Channel RSSChannel `xml:"channel"`
}
RSS feed structures
type RSSFetcher ¶
type RSSFetcher struct {
// contains filtered or unexported fields
}
RSSFetcher fetches items from user-configured RSS feeds
func NewRSSFetcher ¶
func NewRSSFetcher(cfg *config.RSSWidgetConfig) *RSSFetcher
NewRSSFetcher creates a new RSS fetcher
func (*RSSFetcher) CacheDuration ¶
func (f *RSSFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data
func (*RSSFetcher) Fetch ¶
func (f *RSSFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches items from user-configured RSS feeds
func (*RSSFetcher) WidgetType ¶
func (f *RSSFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type RSSItemData ¶
type RSSItemData struct {
Title string `json:"title"`
URL string `json:"url"`
Source string `json:"source"`
PublishedAt time.Time `json:"published_at"`
Summary string `json:"summary,omitempty"`
}
RSSItemData represents a single RSS item
type RelatedArticle ¶
type RelatedArticle struct {
Title string `json:"title"`
URL string `json:"url"`
Extract string `json:"extract,omitempty"`
}
RelatedArticle represents a related Wikipedia article
type ServingSize ¶
type ServingSize struct {
Description string `json:"description"`
Grams float64 `json:"grams"`
Calories float64 `json:"calories,omitempty"`
}
ServingSize represents a common serving size
type SportsData ¶
type SportsData struct {
Games []GameData `json:"games"`
League string `json:"league,omitempty"`
Team string `json:"team,omitempty"`
QueryType string `json:"query_type"` // "team", "league", or "live"
HasLive bool `json:"has_live"` // Whether any games are currently live
LastUpdate string `json:"last_update"`
}
SportsData represents sports widget data
type SportsFetcher ¶
type SportsFetcher struct {
// contains filtered or unexported fields
}
SportsFetcher fetches sports scores from TheSportsDB API
func NewSportsFetcher ¶
func NewSportsFetcher(cfg *config.SportsWidgetConfig) *SportsFetcher
NewSportsFetcher creates a new sports fetcher
func (*SportsFetcher) CacheDuration ¶
func (f *SportsFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data Live games: 1 minute, Completed/Scheduled: 1 hour
func (*SportsFetcher) Fetch ¶
func (f *SportsFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches sports scores based on query parameters Supported params:
- team: Team name (e.g., "lakers", "yankees", "Manchester United")
- league: League name (e.g., "nfl", "premier league", "nba")
- live: "true" to fetch only live games
func (*SportsFetcher) WidgetType ¶
func (f *SportsFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type StockQuote ¶
type StockQuote struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
Price float64 `json:"price"`
Change float64 `json:"change"`
ChangePercent float64 `json:"change_percent"`
Volume int64 `json:"volume,omitempty"`
MarketCap float64 `json:"market_cap,omitempty"`
}
StockQuote represents data for a single stock
type StocksData ¶
type StocksData struct {
Symbols []StockQuote `json:"symbols"`
}
StocksData represents stocks widget data
type StocksFetcher ¶
type StocksFetcher struct {
// contains filtered or unexported fields
}
StocksFetcher fetches stock prices
func NewStocksFetcher ¶
func NewStocksFetcher(cfg *config.StocksWidgetConfig) *StocksFetcher
NewStocksFetcher creates a new stocks fetcher
func (*StocksFetcher) CacheDuration ¶
func (f *StocksFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data
func (*StocksFetcher) Fetch ¶
func (f *StocksFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches stock prices
func (*StocksFetcher) WidgetType ¶
func (f *StocksFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type TeamStats ¶
type TeamStats struct {
Shots int `json:"shots,omitempty"`
ShotsOnGoal int `json:"shots_on_goal,omitempty"`
Possession int `json:"possession,omitempty"` // Percentage
Corners int `json:"corners,omitempty"`
Fouls int `json:"fouls,omitempty"`
YellowCards int `json:"yellow_cards,omitempty"`
RedCards int `json:"red_cards,omitempty"`
}
TeamStats represents basic team statistics for a game
type TrackingConfig ¶
type TrackingConfig struct {
APIKey string // API key for 17track or similar
APIEnabled bool // Whether to use API for live tracking
RateLimitMax int // Max requests per window (default: 10)
RateLimitWindow time.Duration // Rate limit window (default: 1 minute)
}
TrackingConfig holds configuration for the tracking fetcher
type TrackingData ¶
type TrackingData struct {
TrackingNumber string `json:"tracking_number"`
Carrier string `json:"carrier"`
CarrierCode string `json:"carrier_code"`
CarrierURL string `json:"carrier_url"`
Status string `json:"status"`
StatusCode string `json:"status_code,omitempty"`
StatusDescription string `json:"status_description,omitempty"`
Events []TrackingEvent `json:"events,omitempty"`
EstimatedDelivery string `json:"estimated_delivery,omitempty"`
Detected bool `json:"detected"`
APIEnabled bool `json:"api_enabled"`
LastUpdated time.Time `json:"last_updated,omitempty"`
}
TrackingData represents package tracking result
type TrackingEvent ¶
type TrackingEvent struct {
Date string `json:"date"`
Time string `json:"time,omitempty"`
Location string `json:"location"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
Description string `json:"description"`
StatusCode string `json:"status_code,omitempty"`
}
TrackingEvent represents a tracking history event
type TrackingFetcher ¶
type TrackingFetcher struct {
// contains filtered or unexported fields
}
TrackingFetcher fetches package tracking info Implements the Fetcher interface for the widget system
func NewTrackingFetcher ¶
func NewTrackingFetcher() *TrackingFetcher
NewTrackingFetcher creates a basic tracking fetcher without API support For backward compatibility - use NewTrackingFetcherWithConfig for custom configuration
func NewTrackingFetcherDefault ¶
func NewTrackingFetcherDefault() *TrackingFetcher
NewTrackingFetcherDefault creates a basic tracking fetcher with default settings Backward-compatible alias - use NewTrackingFetcherWithConfig for custom configuration
func NewTrackingFetcherSimple ¶
func NewTrackingFetcherSimple() *TrackingFetcher
NewTrackingFetcherSimple creates a basic tracking fetcher without API support This is an alias for NewTrackingFetcherDefault() for clearer naming
func NewTrackingFetcherWithConfig ¶
func NewTrackingFetcherWithConfig(cfg *TrackingConfig) *TrackingFetcher
NewTrackingFetcherWithConfig creates a new tracking fetcher with optional API support
func (*TrackingFetcher) CacheDuration ¶
func (f *TrackingFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache tracking data Returns shorter duration (5 min) for API-enabled tracking to get fresh updates Returns longer duration (15 min) for carrier-detection-only mode
func (*TrackingFetcher) Fetch ¶
func (f *TrackingFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch detects carrier and provides tracking URL Implements the Fetcher interface
func (*TrackingFetcher) HasAPIEnabled ¶
func (f *TrackingFetcher) HasAPIEnabled() bool
HasAPIEnabled returns whether API tracking is enabled
func (*TrackingFetcher) WidgetType ¶
func (f *TrackingFetcher) WidgetType() WidgetType
WidgetType returns the widget type Implements the Fetcher interface
type TranslateData ¶
type TranslateData struct {
SourceLang string `json:"source_lang"`
TargetLang string `json:"target_lang"`
SourceText string `json:"source_text"`
TranslatedText string `json:"translated_text"`
DetectedLang string `json:"detected_lang,omitempty"`
Confidence float64 `json:"confidence,omitempty"`
Provider string `json:"provider,omitempty"`
}
TranslateData represents translation result
type TranslateFetcher ¶
type TranslateFetcher struct {
// contains filtered or unexported fields
}
TranslateFetcher fetches translations
func NewTranslateFetcher ¶
func NewTranslateFetcher() *TranslateFetcher
NewTranslateFetcher creates a new translate fetcher
func (*TranslateFetcher) CacheDuration ¶
func (f *TranslateFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache translation data
func (*TranslateFetcher) Fetch ¶
func (f *TranslateFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches translation Supports params:
- text: text to translate (required unless query is provided)
- query: natural language query (e.g., "translate hello to spanish")
- from / source_lang: source language code or name (default: auto)
- to / target_lang: target language code or name (default: en)
func (*TranslateFetcher) WidgetType ¶
func (f *TranslateFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type TranslateQuery ¶
TranslateQuery represents a parsed translation query
func ParseTranslateQuery ¶
func ParseTranslateQuery(query string) *TranslateQuery
ParseTranslateQuery parses natural language translation queries
type WeatherData ¶
type WeatherData struct {
Location string `json:"location"`
Temperature float64 `json:"temperature"`
FeelsLike float64 `json:"feels_like"`
Humidity int `json:"humidity"`
Description string `json:"description"`
Condition string `json:"condition"`
WindSpeed float64 `json:"wind_speed"`
Icon string `json:"icon"`
}
WeatherData represents weather widget data
type WeatherFetcher ¶
type WeatherFetcher struct {
// contains filtered or unexported fields
}
WeatherFetcher fetches weather data from Open-Meteo API
func NewWeatherFetcher ¶
func NewWeatherFetcher(cfg *config.WeatherWidgetConfig) *WeatherFetcher
NewWeatherFetcher creates a new weather fetcher
func (*WeatherFetcher) CacheDuration ¶
func (f *WeatherFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache the data
func (*WeatherFetcher) Fetch ¶
func (f *WeatherFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches weather data
func (*WeatherFetcher) WidgetType ¶
func (f *WeatherFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type Widget ¶
type Widget struct {
Type WidgetType `json:"type"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon"`
Category WidgetCategory `json:"category"`
Order int `json:"order"`
}
Widget represents a widget definition
type WidgetCategory ¶
type WidgetCategory string
WidgetCategory represents the category of a widget
const ( CategoryData WidgetCategory = "data" // Requires API calls CategoryTool WidgetCategory = "tool" // Client-side only CategoryUser WidgetCategory = "user" // User-customizable, localStorage )
type WidgetData ¶
type WidgetData struct {
Type WidgetType `json:"type"`
Data interface{} `json:"data"`
UpdatedAt time.Time `json:"updated_at"`
Error string `json:"error,omitempty"`
}
WidgetData represents the data returned by a widget fetcher
type WidgetType ¶
type WidgetType string
WidgetType represents the type of widget
const ( WidgetWeather WidgetType = "weather" WidgetClock WidgetType = "clock" WidgetQuickLinks WidgetType = "quicklinks" WidgetNotes WidgetType = "notes" WidgetNews WidgetType = "news" WidgetCalculator WidgetType = "calculator" WidgetCalendar WidgetType = "calendar" WidgetConverter WidgetType = "converter" WidgetStocks WidgetType = "stocks" WidgetCrypto WidgetType = "crypto" WidgetSports WidgetType = "sports" WidgetRSS WidgetType = "rss" // Additional instant answers per IDEA.md WidgetCurrency WidgetType = "currency" WidgetTimezone WidgetType = "timezone" WidgetTranslate WidgetType = "translate" WidgetWikipedia WidgetType = "wikipedia" WidgetTracking WidgetType = "tracking" WidgetNutrition WidgetType = "nutrition" WidgetQRCode WidgetType = "qrcode" WidgetTimer WidgetType = "timer" WidgetLoremIpsum WidgetType = "lorem" WidgetDictionary WidgetType = "dictionary" WidgetIPAddress WidgetType = "ipaddress" WidgetColorPicker WidgetType = "colorpicker" )
type WikipediaData ¶
type WikipediaData struct {
Title string `json:"title"`
Extract string `json:"extract"`
Description string `json:"description,omitempty"`
Thumbnail string `json:"thumbnail,omitempty"`
URL string `json:"url"`
Language string `json:"language"`
RelatedArticles []RelatedArticle `json:"related_articles,omitempty"`
}
WikipediaData represents Wikipedia summary result
type WikipediaFetcher ¶
type WikipediaFetcher struct {
// contains filtered or unexported fields
}
WikipediaFetcher fetches Wikipedia summaries
func NewWikipediaFetcher ¶
func NewWikipediaFetcher() *WikipediaFetcher
NewWikipediaFetcher creates a new Wikipedia fetcher
func (*WikipediaFetcher) CacheDuration ¶
func (f *WikipediaFetcher) CacheDuration() time.Duration
CacheDuration returns how long to cache Wikipedia data
func (*WikipediaFetcher) Fetch ¶
func (f *WikipediaFetcher) Fetch(ctx context.Context, params map[string]string) (*WidgetData, error)
Fetch fetches Wikipedia summary
func (*WikipediaFetcher) WidgetType ¶
func (f *WikipediaFetcher) WidgetType() WidgetType
WidgetType returns the widget type
type YahooFinanceResponse ¶
type YahooFinanceResponse struct {
QuoteResponse struct {
Result []struct {
Symbol string `json:"symbol"`
ShortName string `json:"shortName"`
LongName string `json:"longName"`
RegularMarketPrice float64 `json:"regularMarketPrice"`
RegularMarketChange float64 `json:"regularMarketChange"`
RegularMarketChangePercent float64 `json:"regularMarketChangePercent"`
RegularMarketVolume int64 `json:"regularMarketVolume"`
MarketCap float64 `json:"marketCap"`
} `json:"result"`
Error interface{} `json:"error"`
} `json:"quoteResponse"`
}
YahooFinanceResponse represents Yahoo Finance API response