1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

add the module to the widget_maker.go

This commit is contained in:
Jade 2020-10-19 00:42:03 +01:00
parent 1ff75dd4cf
commit 5c6833a0df
4 changed files with 8 additions and 4 deletions

View File

@ -73,6 +73,7 @@ import (
"github.com/wtfutil/wtf/modules/weatherservices/weather" "github.com/wtfutil/wtf/modules/weatherservices/weather"
"github.com/wtfutil/wtf/modules/zendesk" "github.com/wtfutil/wtf/modules/zendesk"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
"github.com/wtfutil/wtf/modules/finnhub"
) )
// MakeWidget creates and returns instances of widgets // MakeWidget creates and returns instances of widgets
@ -308,6 +309,9 @@ func MakeWidget(
case "exchangerates": case "exchangerates":
settings := exchangerates.NewSettingsFromYAML(moduleName, moduleConfig, config) settings := exchangerates.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = exchangerates.NewWidget(app, pages, settings) widget = exchangerates.NewWidget(app, pages, settings)
case "finnhub":
settings := finnhub.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = finnhub.NewWidget(app, settings)
default: default:
settings := unknown.NewSettingsFromYAML(moduleName, moduleConfig, config) settings := unknown.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = unknown.NewWidget(app, settings) widget = unknown.NewWidget(app, settings)

View File

@ -5,7 +5,6 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"encoding/json" "encoding/json"
//"github.com/wtfutil/wtf/utils"
) )
// Client .. // Client ..

View File

@ -9,7 +9,7 @@ import (
const ( const (
defaultFocusable = true defaultFocusable = true
defaultTitle = "Stocks" defaultTitle = "Finnhub Stock Price"
) )
// Settings defines the configuration properties for this module // Settings defines the configuration properties for this module

View File

@ -42,7 +42,7 @@ func (widget *Widget) Refresh() {
func (widget *Widget) content() (string, string, bool) { func (widget *Widget) content() (string, string, bool) {
quotes, err := widget.Client.Getquote() quotes, err := widget.Client.Getquote()
title := fmt.Sprintf("%s - from finnhub api", widget.CommonSettings().Title) title := fmt.Sprintf("%s", widget.CommonSettings().Title)
var str string var str string
wrap := false wrap := false
if err != nil { if err != nil {
@ -55,7 +55,8 @@ func (widget *Widget) content() (string, string, bool) {
} }
str += fmt.Sprintf( str += fmt.Sprintf(
"[%s]: %s \n", "[%d]: %s %.2f\n",
idx,
q.Stock, q.Stock,
q.C, q.C,
) )