mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merged from upstream
This commit is contained in:
commit
3f7f804e62
24
README.md
24
README.md
@ -1,10 +1,9 @@
|
||||
<p align="right">
|
||||
|
||||
<img src="https://travis-ci.com/senorprogrammer/wtf.svg?branch=master" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="./docs/img/wtf.jpg?raw=true" title="WTF" width="852" height="240" />
|
||||
<img src="./docs/img/wtf.jpg?raw=true" title="WTF" width="852" height="240" />
|
||||
</p>
|
||||
|
||||
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.
|
||||
|
@ -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).
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keep an eye on your <strong>OpsGenie</strong> schedules, <strong>Google Calendar</strong>, <strong>Git</strong>
|
||||
Keep an eye on your <strong>OpsGenie</strong> schedules, <strong>Google Calendar</strong>, <strong>Git</strong>
|
||||
and <strong>Github</strong> repositories, and <strong>New Relic</strong> deployments.
|
||||
</p>
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
</p>
|
||||
|
||||
<a href="https://github.com/senorprogrammer/wtf/releases" class="button button-small">Download Latest</a>
|
||||
|
||||
<a href="https://github.com/senorprogrammer/wtf" class="button button-small">On Github</a>
|
||||
<a href="https://github.com/senorprogrammer/wtf" class="button button-small">Source on Github</a>
|
||||
<a href="https://gitter.im/wtfutil/Lobby" class="button button-small">Chat on Gitter</a>
|
||||
|
||||
<p>
|
||||
<small>
|
||||
|
@ -35,7 +35,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -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
|
||||
}
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -78,7 +78,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -77,7 +77,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
@ -107,7 +107,7 @@
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Keep an eye on your <strong>OpsGenie</strong> schedules, <strong>Google Calendar</strong>, <strong>Git</strong>
|
||||
Keep an eye on your <strong>OpsGenie</strong> schedules, <strong>Google Calendar</strong>, <strong>Git</strong>
|
||||
and <strong>Github</strong> repositories, and <strong>New Relic</strong> deployments.
|
||||
</p>
|
||||
|
||||
@ -120,8 +120,8 @@
|
||||
</p>
|
||||
|
||||
<a href="https://github.com/senorprogrammer/wtf/releases" class="button button-small">Download Latest</a>
|
||||
|
||||
<a href="https://github.com/senorprogrammer/wtf" class="button button-small">On Github</a>
|
||||
<a href="https://github.com/senorprogrammer/wtf" class="button button-small">Source on Github</a>
|
||||
<a href="https://gitter.im/wtfutil/Lobby" class="button button-small">Chat on Gitter</a>
|
||||
|
||||
<p>
|
||||
<small>
|
||||
|
@ -53,8 +53,7 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
||||
<pubDate>Sat, 02 Jun 2018 05:32:04 -0700</pubDate>
|
||||
|
||||
<guid>https://wtfutil.com/posts/modules/prettyweather/</guid>
|
||||
<description>🔬 Experimental
|
||||
Displays weather information as ASCII art from Wttr.in.
|
||||
<description>Displays weather information as ASCII art from Wttr.in.
|
||||
Source Code wtf/prettyweather/ Required ENV Variables None.
|
||||
Keyboard Commands None.
|
||||
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -78,7 +78,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -53,8 +53,7 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
||||
<pubDate>Sat, 02 Jun 2018 05:32:04 -0700</pubDate>
|
||||
|
||||
<guid>https://wtfutil.com/posts/modules/prettyweather/</guid>
|
||||
<description>🔬 Experimental
|
||||
Displays weather information as ASCII art from Wttr.in.
|
||||
<description>Displays weather information as ASCII art from Wttr.in.
|
||||
Source Code wtf/prettyweather/ Required ENV Variables None.
|
||||
Keyboard Commands None.
|
||||
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
@ -113,8 +113,6 @@
|
||||
|
||||
|
||||
|
||||
<p><strong>🔬 Experimental</strong></p>
|
||||
|
||||
<p>Displays weather information as ASCII art from
|
||||
<a href="http://wttr.in">Wttr.in</a>.</p>
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -78,7 +78,7 @@
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/newrelic/">New Relic</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/opsgenie/">OpsGenie</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/power/">Power</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather <span title="experimental">🔬</span></a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/prettyweather/">PrettyWeather</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/security/">Security</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/textfile/">Text File</a></li>
|
||||
<li class="sidebar-list-item-2"><a href="/posts/modules/todo/">Todo</a></li>
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
131
ipapi/widget.go
Normal file
131
ipapi/widget.go
Normal file
@ -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)
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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)")
|
||||
|
@ -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
|
||||
|
23
wtf.go
23
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")))
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user