diff --git a/README.md b/README.md index 705c2be5..d9a53bd7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@

-

- +

A personal terminal-based dashboard utility, designed for @@ -43,27 +42,6 @@ documentation. Here's some short-cuts: * [Configuration](http://wtfutil.com/posts/configuration/) * [Module Documentation](http://wtfutil.com/posts/modules/) -And a "probably up-to-date" list of currently-implemented modules: - -* [BambooHR](http://wtfutil.com/posts/modules/bamboohr/) -* [World Clocks](http://wtfutil.com/posts/modules/clocks/) -* [Command Runner](http://wtfutil.com/posts/modules/cmdrunner/) -* [Google Calendar](http://wtfutil.com/posts/modules/gcal/) -* [Git](http://wtfutil.com/posts/modules/git/) -* [GitHub](http://wtfutil.com/posts/modules/github/) -* [IPInfo](http://wtfutil.com/posts/modules/ipinfo/) -* [Jira](http://wtfutil.com/posts/modules/jira/) -* [New Relic](http://wtfutil.com/posts/modules/newrelic/) -* [OpsGenie](http://wtfutil.com/posts/modules/opsgenie) -* [Power](http://wtfutil.com/posts/modules/power/) -* [PrettyWeather](http://wtfutil.com/posts/modules/prettyweather/)* -* [Security](http://wtfutil.com/posts/modules/security/) -* [Textfile](http://wtfutil.com/posts/modules/textfile/) -* [Todo List](http://wtfutil.com/posts/modules/todo/) -* [Weather](http://wtfutil.com/posts/modules/weather/) - -*experimental - ## Contributing Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests. diff --git a/_site/content/posts/modules/prettyweather.md b/_site/content/posts/modules/prettyweather.md index 1f748a32..66a78c1e 100644 --- a/_site/content/posts/modules/prettyweather.md +++ b/_site/content/posts/modules/prettyweather.md @@ -4,8 +4,6 @@ date: 2018-06-02T05:32:04-07:00 draft: false --- -**🔬 Experimental** - Displays weather information as ASCII art from [Wttr.in](http://wttr.in). diff --git a/_site/themes/hyde-hyde/layouts/index.html b/_site/themes/hyde-hyde/layouts/index.html index 888abc24..d6fed31f 100644 --- a/_site/themes/hyde-hyde/layouts/index.html +++ b/_site/themes/hyde-hyde/layouts/index.html @@ -15,7 +15,7 @@

- Keep an eye on your OpsGenie schedules, Google Calendar, Git + Keep an eye on your OpsGenie schedules, Google Calendar, Git and Github repositories, and New Relic deployments.

@@ -28,8 +28,8 @@

Download Latest - - On Github + Source on Github + Chat on Gitter

diff --git a/_site/themes/hyde-hyde/layouts/partials/sidebar.html b/_site/themes/hyde-hyde/layouts/partials/sidebar.html index fe5c83e2..7d593f21 100644 --- a/_site/themes/hyde-hyde/layouts/partials/sidebar.html +++ b/_site/themes/hyde-hyde/layouts/partials/sidebar.html @@ -35,7 +35,7 @@

- + diff --git a/wtf/config_files.go b/cfg/config_files.go similarity index 94% rename from wtf/config_files.go rename to cfg/config_files.go index ff57654d..85e848e8 100644 --- a/wtf/config_files.go +++ b/cfg/config_files.go @@ -1,4 +1,4 @@ -package wtf +package cfg import ( "fmt" @@ -6,10 +6,11 @@ import ( "os" "github.com/olebedev/config" + "github.com/senorprogrammer/wtf/wtf" ) func ConfigDir() (string, error) { - configDir, err := ExpandHomeDir("~/.wtf/") + configDir, err := wtf.ExpandHomeDir("~/.wtf/") if err != nil { return "", err } @@ -59,7 +60,7 @@ func CreateFile(fileName string) (string, error) { // LoadConfigFile loads the config.yml file to configure the app func LoadConfigFile(filePath string) *config.Config { - absPath, _ := ExpandHomeDir(filePath) + absPath, _ := wtf.ExpandHomeDir(filePath) cfg, err := config.ParseYamlFile(absPath) if err != nil { @@ -79,7 +80,7 @@ func ReadConfigFile(fileName string) (string, error) { filePath := fmt.Sprintf("%s/%s", configDir, fileName) - fileData, err := ReadFileBytes(filePath) + fileData, err := wtf.ReadFileBytes(filePath) if err != nil { return "", err } diff --git a/docs/404.html b/docs/404.html index a6f51b08..262aef29 100644 --- a/docs/404.html +++ b/docs/404.html @@ -76,7 +76,7 @@ - + diff --git a/docs/categories/index.html b/docs/categories/index.html index b52bb86e..8803ffb8 100644 --- a/docs/categories/index.html +++ b/docs/categories/index.html @@ -78,7 +78,7 @@ - + diff --git a/docs/index.html b/docs/index.html index 5b332b6c..fb5764ed 100644 --- a/docs/index.html +++ b/docs/index.html @@ -77,7 +77,7 @@ - + @@ -107,7 +107,7 @@

- Keep an eye on your OpsGenie schedules, Google Calendar, Git + Keep an eye on your OpsGenie schedules, Google Calendar, Git and Github repositories, and New Relic deployments.

@@ -120,8 +120,8 @@

Download Latest - - On Github + Source on Github + Chat on Gitter

diff --git a/docs/index.xml b/docs/index.xml index a86b5ce2..28d48bd1 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -53,8 +53,7 @@ position Defines where in the grid this module’s widget will be displa Sat, 02 Jun 2018 05:32:04 -0700 https://wtfutil.com/posts/modules/prettyweather/ - 🔬 Experimental -Displays weather information as ASCII art from Wttr.in. + Displays weather information as ASCII art from Wttr.in. Source Code wtf/prettyweather/ Required ENV Variables None. Keyboard Commands None. Configuration prettyweather:enabled:truecity:"tehran"position:top:3left:5height:1width:1refreshInterval:300unit:"c"view:0 Attributes city Optional. It will grab the current location from your IP address if omitted. diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html index a5354fce..bd308fdf 100644 --- a/docs/posts/configuration/attributes/index.html +++ b/docs/posts/configuration/attributes/index.html @@ -76,7 +76,7 @@

- + diff --git a/docs/posts/configuration/index.html b/docs/posts/configuration/index.html index ec410d85..067aab24 100644 --- a/docs/posts/configuration/index.html +++ b/docs/posts/configuration/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/configuration/iterm2/index.html b/docs/posts/configuration/iterm2/index.html index dcb4d6c6..ba679394 100644 --- a/docs/posts/configuration/iterm2/index.html +++ b/docs/posts/configuration/iterm2/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/glossary/index.html b/docs/posts/glossary/index.html index 9a4f7187..b88135ae 100644 --- a/docs/posts/glossary/index.html +++ b/docs/posts/glossary/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/index.html b/docs/posts/index.html index ae588754..120d52e0 100644 --- a/docs/posts/index.html +++ b/docs/posts/index.html @@ -78,7 +78,7 @@ - + diff --git a/docs/posts/index.xml b/docs/posts/index.xml index 2dc5ba0f..71eef75b 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -53,8 +53,7 @@ position Defines where in the grid this module’s widget will be displa Sat, 02 Jun 2018 05:32:04 -0700 https://wtfutil.com/posts/modules/prettyweather/ - 🔬 Experimental -Displays weather information as ASCII art from Wttr.in. + Displays weather information as ASCII art from Wttr.in. Source Code wtf/prettyweather/ Required ENV Variables None. Keyboard Commands None. Configuration prettyweather:enabled:truecity:"tehran"position:top:3left:5height:1width:1refreshInterval:300unit:"c"view:0 Attributes city Optional. It will grab the current location from your IP address if omitted. diff --git a/docs/posts/installation/index.html b/docs/posts/installation/index.html index 1237a416..57c8acd7 100644 --- a/docs/posts/installation/index.html +++ b/docs/posts/installation/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/bamboohr/index.html b/docs/posts/modules/bamboohr/index.html index 240a8181..e3b3ac7c 100644 --- a/docs/posts/modules/bamboohr/index.html +++ b/docs/posts/modules/bamboohr/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/clocks/index.html b/docs/posts/modules/clocks/index.html index 04333353..71a519c8 100644 --- a/docs/posts/modules/clocks/index.html +++ b/docs/posts/modules/clocks/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/cmdrunner/index.html b/docs/posts/modules/cmdrunner/index.html index 1ec0afca..edca5f69 100644 --- a/docs/posts/modules/cmdrunner/index.html +++ b/docs/posts/modules/cmdrunner/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/cryptocurrencies/bittrex/index.html b/docs/posts/modules/cryptocurrencies/bittrex/index.html index f9f033eb..18730b2b 100644 --- a/docs/posts/modules/cryptocurrencies/bittrex/index.html +++ b/docs/posts/modules/cryptocurrencies/bittrex/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/cryptocurrencies/cryptolive/index.html b/docs/posts/modules/cryptocurrencies/cryptolive/index.html index 832af988..f84dea13 100644 --- a/docs/posts/modules/cryptocurrencies/cryptolive/index.html +++ b/docs/posts/modules/cryptocurrencies/cryptolive/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/gcal/index.html b/docs/posts/modules/gcal/index.html index 7e6f4a4b..fa6de93d 100644 --- a/docs/posts/modules/gcal/index.html +++ b/docs/posts/modules/gcal/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/git/index.html b/docs/posts/modules/git/index.html index e958c4f1..0ab526af 100644 --- a/docs/posts/modules/git/index.html +++ b/docs/posts/modules/git/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/github/index.html b/docs/posts/modules/github/index.html index eb556adb..55afa1e3 100644 --- a/docs/posts/modules/github/index.html +++ b/docs/posts/modules/github/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/index.html b/docs/posts/modules/index.html index fad43ff2..5ffb2199 100644 --- a/docs/posts/modules/index.html +++ b/docs/posts/modules/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/ipinfo/index.html b/docs/posts/modules/ipinfo/index.html index f3cd4865..5f3994cb 100644 --- a/docs/posts/modules/ipinfo/index.html +++ b/docs/posts/modules/ipinfo/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/jira/index.html b/docs/posts/modules/jira/index.html index 4a60fb7a..258cb919 100644 --- a/docs/posts/modules/jira/index.html +++ b/docs/posts/modules/jira/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/newrelic/index.html b/docs/posts/modules/newrelic/index.html index eac8a8db..db3a032b 100644 --- a/docs/posts/modules/newrelic/index.html +++ b/docs/posts/modules/newrelic/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/opsgenie/index.html b/docs/posts/modules/opsgenie/index.html index dd2eef1a..ff57d7cb 100644 --- a/docs/posts/modules/opsgenie/index.html +++ b/docs/posts/modules/opsgenie/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/power/index.html b/docs/posts/modules/power/index.html index 7cbb1d72..e42e346c 100644 --- a/docs/posts/modules/power/index.html +++ b/docs/posts/modules/power/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/prettyweather/index.html b/docs/posts/modules/prettyweather/index.html index d6bd7e91..a0c4d36b 100644 --- a/docs/posts/modules/prettyweather/index.html +++ b/docs/posts/modules/prettyweather/index.html @@ -76,7 +76,7 @@ - + @@ -113,8 +113,6 @@ -

🔬 Experimental

-

Displays weather information as ASCII art from Wttr.in.

diff --git a/docs/posts/modules/security/index.html b/docs/posts/modules/security/index.html index 04437186..98c131b0 100644 --- a/docs/posts/modules/security/index.html +++ b/docs/posts/modules/security/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/textfile/index.html b/docs/posts/modules/textfile/index.html index c18d9229..a8e53ab4 100644 --- a/docs/posts/modules/textfile/index.html +++ b/docs/posts/modules/textfile/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/todo/index.html b/docs/posts/modules/todo/index.html index 9ffa4bc6..6c105daa 100644 --- a/docs/posts/modules/todo/index.html +++ b/docs/posts/modules/todo/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/modules/weather/index.html b/docs/posts/modules/weather/index.html index f22a2a21..7021ceb2 100644 --- a/docs/posts/modules/weather/index.html +++ b/docs/posts/modules/weather/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/posts/overview/index.html b/docs/posts/overview/index.html index beef7287..a3d75261 100644 --- a/docs/posts/overview/index.html +++ b/docs/posts/overview/index.html @@ -76,7 +76,7 @@ - + diff --git a/docs/tags/index.html b/docs/tags/index.html index 68425b68..9681fff7 100644 --- a/docs/tags/index.html +++ b/docs/tags/index.html @@ -78,7 +78,7 @@ - + diff --git a/git/widget.go b/git/widget.go index 89aad5a2..894d71b5 100644 --- a/git/widget.go +++ b/git/widget.go @@ -23,6 +23,10 @@ const HelpText = ` arrow right: Next git repository ` +const offscreen = -1000 +const modalWidth = 80 +const modalHeight = 7 + type Widget struct { wtf.TextWidget @@ -131,11 +135,18 @@ func (widget *Widget) modalForm(lbl, text string) *tview.Form { return form } func (widget *Widget) modalFrame(form *tview.Form) *tview.Frame { - _, _, w, h := widget.View.GetInnerRect() - frame := tview.NewFrame(form).SetBorders(0, 0, 0, 0, 0, 0) + frame.SetRect(offscreen, offscreen, modalWidth, modalHeight) frame.SetBorder(true) - frame.SetRect(w+20, h+2, 80, 7) + frame.SetBorders(1, 1, 0, 0, 1, 1) + + drawFunc := func(screen tcell.Screen, x, y, width, height int) (int, int, int, int) { + w, h := screen.Size() + frame.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height) + return x, y, width, height + } + + frame.SetDrawFunc(drawFunc) return frame } diff --git a/gspreadsheets/widget.go b/gspreadsheets/widget.go index e754ce74..680869cf 100644 --- a/gspreadsheets/widget.go +++ b/gspreadsheets/widget.go @@ -3,8 +3,8 @@ package gspreadsheets import ( "fmt" - "github.com/senorprogrammer/wtf/wtf" "github.com/olebedev/config" + "github.com/senorprogrammer/wtf/wtf" sheets "google.golang.org/api/sheets/v4" ) @@ -26,10 +26,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - cells, _ := Fetch() widget.UpdateRefreshedAt() diff --git a/ipapi/widget.go b/ipapi/widget.go new file mode 100644 index 00000000..d65f2456 --- /dev/null +++ b/ipapi/widget.go @@ -0,0 +1,131 @@ +package ipapi + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + "text/template" + + "bytes" + + "github.com/olebedev/config" + "github.com/senorprogrammer/wtf/wtf" +) + +// Config is a pointer to the global config object +var Config *config.Config + +// Widget widget struct +type Widget struct { + wtf.TextWidget + result string + colors struct { + name, value string + } +} + +type ipinfo struct { + Query string `json:"query"` + ISP string `json:"isp"` + AS string `json:"as"` + City string `json:"city"` + Region string `json:"region"` + Country string `json:"country"` + CountryCode string `json:"countryCode"` + Latitude float64 `json:"lat"` + Longitude float64 `json:"lon"` + PostalCode string `json:"zip"` + Organization string `json:"org"` + Timezone string `json:"timezone"` +} + +// NewWidget constructor +func NewWidget() *Widget { + widget := Widget{ + TextWidget: wtf.NewTextWidget(" IPInfo ", "ipapi", false), + } + + widget.View.SetWrap(false) + + widget.config() + + return &widget +} + +// Refresh refresh the module +func (widget *Widget) Refresh() { + widget.UpdateRefreshedAt() + widget.ipinfo() + widget.View.SetText(widget.result) +} + +//this method reads the config and calls ipinfo for ip information +func (widget *Widget) ipinfo() { + client := &http.Client{} + req, err := http.NewRequest("GET", "http://ip-api.com/json", nil) + if err != nil { + widget.result = fmt.Sprintf("%s", err.Error()) + return + } + req.Header.Set("User-Agent", "curl") + response, err := client.Do(req) + if err != nil { + widget.result = fmt.Sprintf("%s", err.Error()) + return + } + defer response.Body.Close() + var info ipinfo + err = json.NewDecoder(response.Body).Decode(&info) + if err != nil { + widget.result = fmt.Sprintf("%s", err.Error()) + return + } + + widget.setResult(&info) +} + +// read module configs +func (widget *Widget) config() { + nameColor, valueColor := Config.UString("wtf.mods.ipinfo.colors.name", "red"), Config.UString("wtf.mods.ipinfo.colors.value", "white") + widget.colors.name = nameColor + widget.colors.value = valueColor +} + +func (widget *Widget) setResult(info *ipinfo) { + resultTemplate, _ := template.New("ipinfo_result").Parse( + formatableText("IP Address", "Ip") + + formatableText("ISP", "ISP") + + formatableText("AS", "AS") + + formatableText("City", "City") + + formatableText("Region", "Region") + + formatableText("Country", "Country") + + formatableText("Coordinates", "Coordinates") + + formatableText("Postal Code", "PostalCode") + + formatableText("Organization", "Organization") + + formatableText("Timezone", "Timezone"), + ) + + resultBuffer := new(bytes.Buffer) + + resultTemplate.Execute(resultBuffer, map[string]string{ + "nameColor": widget.colors.name, + "valueColor": widget.colors.value, + "Ip": info.Query, + "ISP": info.ISP, + "AS": info.AS, + "City": info.City, + "Region": info.Region, + "Country": info.Country, + "Coordinates": strconv.FormatFloat(info.Latitude, 'f', 6, 64) + "," + strconv.FormatFloat(info.Longitude, 'f', 6, 64), + "PostalCode": info.PostalCode, + "Organization": info.Organization, + "Timezone": info.Timezone, + }) + + widget.result = resultBuffer.String() +} + +func formatableText(key, value string) string { + return fmt.Sprintf(" [{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value) +} diff --git a/todo/widget.go b/todo/widget.go index 00dcb984..e06c007c 100644 --- a/todo/widget.go +++ b/todo/widget.go @@ -7,6 +7,7 @@ import ( "github.com/gdamore/tcell" "github.com/olebedev/config" "github.com/rivo/tview" + "github.com/senorprogrammer/wtf/cfg" "github.com/senorprogrammer/wtf/wtf" "gopkg.in/yaml.v2" ) @@ -33,6 +34,10 @@ const HelpText = ` space: Check the selected item on or off ` +const offscreen = -1000 +const modalWidth = 80 +const modalHeight = 7 + type Widget struct { wtf.TextWidget @@ -95,7 +100,7 @@ func (widget *Widget) editItem() { } func (widget *Widget) init() { - _, err := wtf.CreateFile(widget.filePath) + _, err := cfg.CreateFile(widget.filePath) if err != nil { panic(err) } @@ -177,7 +182,7 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { // Loads the todo list from Yaml file func (widget *Widget) load() { - confDir, _ := wtf.ConfigDir() + confDir, _ := cfg.ConfigDir() filePath := fmt.Sprintf("%s/%s", confDir, widget.filePath) fileData, _ := wtf.ReadFileBytes(filePath) @@ -203,7 +208,7 @@ func (widget *Widget) newItem() { // persist writes the todo list to Yaml file func (widget *Widget) persist() { - confDir, _ := wtf.ConfigDir() + confDir, _ := cfg.ConfigDir() filePath := fmt.Sprintf("%s/%s", confDir, widget.filePath) fileData, _ := yaml.Marshal(&widget.list) @@ -266,11 +271,18 @@ func (widget *Widget) modalForm(lbl, text string) *tview.Form { } func (widget *Widget) modalFrame(form *tview.Form) *tview.Frame { - _, _, w, h := widget.View.GetInnerRect() - frame := tview.NewFrame(form).SetBorders(0, 0, 0, 0, 0, 0) + frame.SetRect(offscreen, offscreen, modalWidth, modalHeight) frame.SetBorder(true) - frame.SetRect(w+20, h+2, 80, 7) + frame.SetBorders(1, 1, 0, 0, 1, 1) + + drawFunc := func(screen tcell.Screen, x, y, width, height int) (int, int, int, int) { + w, h := screen.Size() + frame.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height) + return x, y, width, height + } + + frame.SetDrawFunc(drawFunc) return frame } diff --git a/weather/display.go b/weather/display.go index 1b237789..9acd9e3d 100644 --- a/weather/display.go +++ b/weather/display.go @@ -11,6 +11,11 @@ import ( func (widget *Widget) display() { widget.View.Clear() + if widget.apiKeyValid() == false { + fmt.Fprintf(widget.View, "%s", " Environment variable WTF_OWM_API_KEY is not set") + return + } + cityData := widget.currentData() if cityData == nil { fmt.Fprintf(widget.View, "%s", " Weather data is unavailable (1)") diff --git a/weather/widget.go b/weather/widget.go index 992c7207..8a1176cb 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -74,7 +74,9 @@ func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData { // Refresh fetches new data from the OpenWeatherMap API and loads the new data into the. // widget's view for rendering func (widget *Widget) Refresh() { - widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) + if widget.apiKeyValid() { + widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) + } widget.UpdateRefreshedAt() widget.display() @@ -104,6 +106,18 @@ func (widget *Widget) Prev() { /* -------------------- Unexported Functions -------------------- */ +func (widget *Widget) apiKeyValid() bool { + if widget.APIKey == "" { + return false + } + + if len(widget.APIKey) != 32 { + return false + } + + return true +} + func (widget *Widget) currentData() *owm.CurrentWeatherData { if len(widget.Data) == 0 { return nil diff --git a/wtf.go b/wtf.go index 0580fc0f..bf8163c2 100644 --- a/wtf.go +++ b/wtf.go @@ -6,9 +6,14 @@ import ( "os" "time" + "github.com/gdamore/tcell" + "github.com/olebedev/config" + "github.com/radovskyb/watcher" + "github.com/rivo/tview" "github.com/senorprogrammer/wtf/bamboohr" "github.com/senorprogrammer/wtf/bargraph" "github.com/senorprogrammer/wtf/blockfolio" + "github.com/senorprogrammer/wtf/cfg" "github.com/senorprogrammer/wtf/clocks" "github.com/senorprogrammer/wtf/cmdrunner" "github.com/senorprogrammer/wtf/cryptoexchanges/bittrex" @@ -18,6 +23,7 @@ import ( "github.com/senorprogrammer/wtf/github" "github.com/senorprogrammer/wtf/gspreadsheets" "github.com/senorprogrammer/wtf/help" + "github.com/senorprogrammer/wtf/ipapi" "github.com/senorprogrammer/wtf/ipinfo" "github.com/senorprogrammer/wtf/jira" "github.com/senorprogrammer/wtf/newrelic" @@ -31,10 +37,6 @@ import ( "github.com/senorprogrammer/wtf/todo" "github.com/senorprogrammer/wtf/weather" "github.com/senorprogrammer/wtf/wtf" - "github.com/gdamore/tcell" - "github.com/olebedev/config" - "github.com/radovskyb/watcher" - "github.com/rivo/tview" ) /* -------------------- Functions -------------------- */ @@ -187,8 +189,12 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) { Widgets = append(Widgets, git.NewWidget(app, pages)) case "github": Widgets = append(Widgets, github.NewWidget(app, pages)) + case "gspreadsheets": + Widgets = append(Widgets, gspreadsheets.NewWidget()) case "ipinfo": Widgets = append(Widgets, ipinfo.NewWidget()) + case "ipapi": + Widgets = append(Widgets, ipapi.NewWidget()) case "jira": Widgets = append(Widgets, jira.NewWidget()) case "newrelic": @@ -228,10 +234,11 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) { cmdrunner.Config = Config cryptolive.Config = Config gcal.Config = Config - gspreadsheets.Config = Config git.Config = Config github.Config = Config + gspreadsheets.Config = Config ipinfo.Config = Config + ipapi.Config = Config jira.Config = Config newrelic.Config = Config opsgenie.Config = Config @@ -262,7 +269,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) { } func loadConfig(configFlag string) { - Config = wtf.LoadConfigFile(configFlag) + Config = cfg.LoadConfigFile(configFlag) } func main() { @@ -279,8 +286,8 @@ func main() { // Responsible for creating the configuration directory and default // configuration file if they don't already exist - wtf.CreateConfigDir() - wtf.WriteConfigFile() + cfg.CreateConfigDir() + cfg.WriteConfigFile() loadConfig(cmdFlags.Config) os.Setenv("TERM", Config.UString("wtf.term", os.Getenv("TERM"))) diff --git a/wtf/billboard_modal.go b/wtf/billboard_modal.go index 552ffb21..70137c2a 100644 --- a/wtf/billboard_modal.go +++ b/wtf/billboard_modal.go @@ -35,19 +35,19 @@ func NewBillboardModal(text string, closeFunc func()) *tview.Frame { textView.SetBackgroundColor(tview.Styles.ContrastBackgroundColor) textView.SetInputCapture(keyboardIntercept) - thing := tview.NewFrame(textView) - thing.SetRect(offscreen, offscreen, modalWidth, modalHeight) + frame := tview.NewFrame(textView) + frame.SetRect(offscreen, offscreen, modalWidth, modalHeight) drawFunc := func(screen tcell.Screen, x, y, width, height int) (int, int, int, int) { w, h := screen.Size() - thing.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height) + frame.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height) return x, y, width, height } - thing.SetBackgroundColor(tview.Styles.ContrastBackgroundColor) - thing.SetBorder(true) - thing.SetBorders(1, 1, 0, 0, 1, 1) - thing.SetDrawFunc(drawFunc) + frame.SetBackgroundColor(tview.Styles.ContrastBackgroundColor) + frame.SetBorder(true) + frame.SetBorders(1, 1, 0, 0, 1, 1) + frame.SetDrawFunc(drawFunc) - return thing + return frame }