From 78d3becdf3b538194f6926d1f2792a7a131de1d0 Mon Sep 17 00:00:00 2001
From: FengYa
Date: Fri, 8 Jun 2018 13:44:38 +0800
Subject: [PATCH 01/12] create another module to use another ipinfo api
---
ipinfohigherlimit/widget.go | 141 ++++++++++++++++++++++++++++++++++++
wtf.go | 4 +
2 files changed, 145 insertions(+)
create mode 100644 ipinfohigherlimit/widget.go
diff --git a/ipinfohigherlimit/widget.go b/ipinfohigherlimit/widget.go
new file mode 100644
index 00000000..3fdabb3f
--- /dev/null
+++ b/ipinfohigherlimit/widget.go
@@ -0,0 +1,141 @@
+package ipinfohigherlimit
+
+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 ", "ipinfohigherlimit", false),
+ }
+
+ widget.View.SetWrap(false)
+
+ widget.config()
+
+ return &widget
+}
+
+// Refresh refresh the module
+func (widget *Widget) Refresh() {
+ if widget.Disabled() {
+ return
+ }
+
+ widget.UpdateRefreshedAt()
+ widget.ipinfo()
+ widget.View.Clear()
+
+ 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()
+ if err != nil {
+ widget.result = fmt.Sprintf("%s", err.Error())
+ return
+ }
+ 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/wtf.go b/wtf.go
index f0df2b06..ad739a99 100644
--- a/wtf.go
+++ b/wtf.go
@@ -20,6 +20,7 @@ import (
"github.com/senorprogrammer/wtf/github"
"github.com/senorprogrammer/wtf/help"
"github.com/senorprogrammer/wtf/ipinfo"
+ "github.com/senorprogrammer/wtf/ipinfohigherlimit"
"github.com/senorprogrammer/wtf/jira"
"github.com/senorprogrammer/wtf/newrelic"
"github.com/senorprogrammer/wtf/opsgenie"
@@ -176,6 +177,8 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
Widgets = append(Widgets, github.NewWidget(app, pages))
case "ipinfo":
Widgets = append(Widgets, ipinfo.NewWidget())
+ case "ipinfohigherlimit":
+ Widgets = append(Widgets, ipinfohigherlimit.NewWidget())
case "jira":
Widgets = append(Widgets, jira.NewWidget())
case "newrelic":
@@ -215,6 +218,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) {
git.Config = Config
github.Config = Config
ipinfo.Config = Config
+ ipinfohigherlimit.Config = Config
jira.Config = Config
newrelic.Config = Config
opsgenie.Config = Config
From 5ba7c6416fcd0ab8bb58cb460b3fedea238ce2bc Mon Sep 17 00:00:00 2001
From: FengYa
Date: Fri, 8 Jun 2018 14:22:01 +0800
Subject: [PATCH 02/12] delete the useless clear operation
---
ipinfohigherlimit/widget.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/ipinfohigherlimit/widget.go b/ipinfohigherlimit/widget.go
index 3fdabb3f..32ed40e2 100644
--- a/ipinfohigherlimit/widget.go
+++ b/ipinfohigherlimit/widget.go
@@ -61,7 +61,6 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.ipinfo()
- widget.View.Clear()
widget.View.SetText(widget.result)
}
From b0af0d1d3be60bd7aded6be37a090f48dc489b36 Mon Sep 17 00:00:00 2001
From: FengYa
Date: Fri, 8 Jun 2018 14:43:58 +0800
Subject: [PATCH 03/12] delete useless check code
---
ipinfohigherlimit/widget.go | 5 -----
1 file changed, 5 deletions(-)
diff --git a/ipinfohigherlimit/widget.go b/ipinfohigherlimit/widget.go
index 32ed40e2..e0106a15 100644
--- a/ipinfohigherlimit/widget.go
+++ b/ipinfohigherlimit/widget.go
@@ -55,13 +55,8 @@ func NewWidget() *Widget {
// Refresh refresh the module
func (widget *Widget) Refresh() {
- if widget.Disabled() {
- return
- }
-
widget.UpdateRefreshedAt()
widget.ipinfo()
-
widget.View.SetText(widget.result)
}
From 115e9df9a8671effc9923705804bd3339cf57a1a Mon Sep 17 00:00:00 2001
From: FengYa
Date: Fri, 8 Jun 2018 14:56:57 +0800
Subject: [PATCH 04/12] delete useless repeat code
---
ipinfohigherlimit/widget.go | 4 ----
1 file changed, 4 deletions(-)
diff --git a/ipinfohigherlimit/widget.go b/ipinfohigherlimit/widget.go
index e0106a15..9b781d0d 100644
--- a/ipinfohigherlimit/widget.go
+++ b/ipinfohigherlimit/widget.go
@@ -75,10 +75,6 @@ func (widget *Widget) ipinfo() {
return
}
defer response.Body.Close()
- if err != nil {
- widget.result = fmt.Sprintf("%s", err.Error())
- return
- }
var info ipinfo
err = json.NewDecoder(response.Body).Decode(&info)
if err != nil {
From e319ab69e78ded09aeb7635247f18b3fd214b105 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Fri, 8 Jun 2018 15:57:22 -0700
Subject: [PATCH 05/12] Make Google Spreadsheet widget work with new module
lazy-loading
---
gspreadsheets/widget.go | 6 +-----
wtf.go | 6 ++++--
2 files changed, 5 insertions(+), 7 deletions(-)
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/wtf.go b/wtf.go
index 22659cd7..954d3871 100644
--- a/wtf.go
+++ b/wtf.go
@@ -17,9 +17,9 @@ import (
"github.com/senorprogrammer/wtf/cryptoexchanges/bittrex"
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive"
"github.com/senorprogrammer/wtf/gcal"
- "github.com/senorprogrammer/wtf/gspreadsheets"
"github.com/senorprogrammer/wtf/git"
"github.com/senorprogrammer/wtf/github"
+ "github.com/senorprogrammer/wtf/gspreadsheets"
"github.com/senorprogrammer/wtf/help"
"github.com/senorprogrammer/wtf/ipinfo"
"github.com/senorprogrammer/wtf/jira"
@@ -186,6 +186,8 @@ 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 "jira":
@@ -225,9 +227,9 @@ 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
jira.Config = Config
newrelic.Config = Config
From a1af76c17afdfe1dd3e8606e108612514e5ffb33 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Fri, 8 Jun 2018 16:15:25 -0700
Subject: [PATCH 06/12] Remove experimental tag from PrettyWeather
---
README.md | 19 -------------------
_site/content/posts/modules/prettyweather.md | 2 --
_site/themes/hyde-hyde/layouts/index.html | 6 +++---
.../hyde-hyde/layouts/partials/sidebar.html | 2 +-
docs/404.html | 2 +-
docs/categories/index.html | 2 +-
docs/index.html | 8 ++++----
docs/index.xml | 3 +--
.../posts/configuration/attributes/index.html | 2 +-
docs/posts/configuration/index.html | 2 +-
docs/posts/configuration/iterm2/index.html | 2 +-
docs/posts/glossary/index.html | 2 +-
docs/posts/index.html | 2 +-
docs/posts/index.xml | 3 +--
docs/posts/installation/index.html | 2 +-
docs/posts/modules/bamboohr/index.html | 2 +-
docs/posts/modules/clocks/index.html | 2 +-
docs/posts/modules/cmdrunner/index.html | 2 +-
.../cryptocurrencies/bittrex/index.html | 2 +-
.../cryptocurrencies/cryptolive/index.html | 2 +-
docs/posts/modules/gcal/index.html | 2 +-
docs/posts/modules/git/index.html | 2 +-
docs/posts/modules/github/index.html | 2 +-
docs/posts/modules/index.html | 2 +-
docs/posts/modules/ipinfo/index.html | 2 +-
docs/posts/modules/jira/index.html | 2 +-
docs/posts/modules/newrelic/index.html | 2 +-
docs/posts/modules/opsgenie/index.html | 2 +-
docs/posts/modules/power/index.html | 2 +-
docs/posts/modules/prettyweather/index.html | 4 +---
docs/posts/modules/security/index.html | 2 +-
docs/posts/modules/textfile/index.html | 2 +-
docs/posts/modules/todo/index.html | 2 +-
docs/posts/modules/weather/index.html | 2 +-
docs/posts/overview/index.html | 2 +-
docs/tags/index.html | 2 +-
36 files changed, 39 insertions(+), 64 deletions(-)
diff --git a/README.md b/README.md
index 705c2be5..4fb8b7c7 100644
--- a/README.md
+++ b/README.md
@@ -43,25 +43,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
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/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 @@
-
+
From 00c07a9421334d00178c9f5b939af3315cb7bb48 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Fri, 8 Jun 2018 16:26:51 -0700
Subject: [PATCH 07/12] Remove experimental tag from README
---
README.md | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 4fb8b7c7..d9a53bd7 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
-
-
+
A personal terminal-based dashboard utility, designed for
@@ -43,8 +42,6 @@ documentation. Here's some short-cuts:
* [Configuration](http://wtfutil.com/posts/configuration/)
* [Module Documentation](http://wtfutil.com/posts/modules/)
-*experimental
-
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.
From d2dfcd8978a4ae886c3dda17227dbdd1f7e687f2 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 9 Jun 2018 03:58:45 -0700
Subject: [PATCH 08/12] Add cfg/ as a top-level package concept
---
{wtf => cfg}/config_files.go | 9 +++++----
todo/widget.go | 7 ++++---
wtf.go | 7 ++++---
3 files changed, 13 insertions(+), 10 deletions(-)
rename {wtf => cfg}/config_files.go (94%)
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/todo/widget.go b/todo/widget.go
index 00dcb984..f529f53e 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"
)
@@ -95,7 +96,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 +178,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 +204,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)
diff --git a/wtf.go b/wtf.go
index 954d3871..2c27fb13 100644
--- a/wtf.go
+++ b/wtf.go
@@ -12,6 +12,7 @@ import (
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/bamboohr"
"github.com/senorprogrammer/wtf/bargraph"
+ "github.com/senorprogrammer/wtf/cfg"
"github.com/senorprogrammer/wtf/clocks"
"github.com/senorprogrammer/wtf/cmdrunner"
"github.com/senorprogrammer/wtf/cryptoexchanges/bittrex"
@@ -260,7 +261,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) {
}
func loadConfig(configFlag string) {
- Config = wtf.LoadConfigFile(configFlag)
+ Config = cfg.LoadConfigFile(configFlag)
}
func main() {
@@ -277,8 +278,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")))
From b593f3517ae4928a54ef0bcb4f2536984db38e7e Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 9 Jun 2018 04:07:01 -0700
Subject: [PATCH 09/12] Basic Weather widget API key validation
---
weather/display.go | 5 +++++
weather/widget.go | 12 ++++++++++++
2 files changed, 17 insertions(+)
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..fa92b60d 100644
--- a/weather/widget.go
+++ b/weather/widget.go
@@ -104,6 +104,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
From cca845d4ffd266184c62c9597130d2e272268026 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 9 Jun 2018 04:09:04 -0700
Subject: [PATCH 10/12] Don't crash if the Weather API is missing or invalid
---
weather/widget.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/weather/widget.go b/weather/widget.go
index fa92b60d..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()
From 97aafd60f932b19c55ff662fa30b80abcb7d5706 Mon Sep 17 00:00:00 2001
From: FengYa
Date: Sat, 9 Jun 2018 23:06:51 +0800
Subject: [PATCH 11/12] change name of the module
---
{ipinfohigherlimit => ipapi}/widget.go | 4 ++--
wtf.go | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
rename {ipinfohigherlimit => ipapi}/widget.go (97%)
diff --git a/ipinfohigherlimit/widget.go b/ipapi/widget.go
similarity index 97%
rename from ipinfohigherlimit/widget.go
rename to ipapi/widget.go
index 9b781d0d..d65f2456 100644
--- a/ipinfohigherlimit/widget.go
+++ b/ipapi/widget.go
@@ -1,4 +1,4 @@
-package ipinfohigherlimit
+package ipapi
import (
"encoding/json"
@@ -43,7 +43,7 @@ type ipinfo struct {
// NewWidget constructor
func NewWidget() *Widget {
widget := Widget{
- TextWidget: wtf.NewTextWidget(" IPInfo ", "ipinfohigherlimit", false),
+ TextWidget: wtf.NewTextWidget(" IPInfo ", "ipapi", false),
}
widget.View.SetWrap(false)
diff --git a/wtf.go b/wtf.go
index 8957edd5..7cfe4c74 100644
--- a/wtf.go
+++ b/wtf.go
@@ -21,7 +21,7 @@ import (
"github.com/senorprogrammer/wtf/github"
"github.com/senorprogrammer/wtf/help"
"github.com/senorprogrammer/wtf/ipinfo"
- "github.com/senorprogrammer/wtf/ipinfohigherlimit"
+ "github.com/senorprogrammer/wtf/ipapi"
"github.com/senorprogrammer/wtf/jira"
"github.com/senorprogrammer/wtf/newrelic"
"github.com/senorprogrammer/wtf/opsgenie"
@@ -186,8 +186,8 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
Widgets = append(Widgets, github.NewWidget(app, pages))
case "ipinfo":
Widgets = append(Widgets, ipinfo.NewWidget())
- case "ipinfohigherlimit":
- Widgets = append(Widgets, ipinfohigherlimit.NewWidget())
+ case "ipapi":
+ Widgets = append(Widgets, ipapi.NewWidget())
case "jira":
Widgets = append(Widgets, jira.NewWidget())
case "newrelic":
@@ -228,7 +228,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) {
git.Config = Config
github.Config = Config
ipinfo.Config = Config
- ipinfohigherlimit.Config = Config
+ ipapi.Config = Config
jira.Config = Config
newrelic.Config = Config
opsgenie.Config = Config
From 5e13618813747341313e1dbf66a446aa459c6063 Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Sat, 9 Jun 2018 08:52:32 -0700
Subject: [PATCH 12/12] Close #168. Modal dialogs now center onscreen properly
---
git/widget.go | 17 ++++++++++++++---
todo/widget.go | 17 ++++++++++++++---
wtf/billboard_modal.go | 16 ++++++++--------
3 files changed, 36 insertions(+), 14 deletions(-)
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/todo/widget.go b/todo/widget.go
index f529f53e..e06c007c 100644
--- a/todo/widget.go
+++ b/todo/widget.go
@@ -34,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
@@ -267,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/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
}