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

Merge branch 'master' into another_ipinfo_api_187

This commit is contained in:
FengYa 2018-06-09 23:11:12 +08:00 committed by GitHub
commit 9e47f8f42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 344 additions and 89 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@
# Misc
.DS_Store
gcal/client_secret.json
gspreadsheets/client_secret.json
#intellij idea
.idea/

View File

@ -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.

View File

@ -79,6 +79,25 @@ wtf:
refreshInterval: 300
secretFile: "~/.wtf/gcal/client_secret.json"
withLocation: true
gspreadsheets:
enabled: true
secretFile: "~/.wtf/gspreadsheets/client_secret.json"
refreshInterval: "300"
sheetId: "id_of_google_spreadsheet"
colors:
values: "green"
cells:
names:
- "Cell 1 name"
- "Cell 2 name"
addresses:
- "A1"
- "A2"
position:
top: 0
left: 0
width: 1
height: 1
git:
commitCount: 5
enabled: true

View File

@ -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).

View File

@ -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>

View File

@ -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>

View File

@ -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
}

View File

@ -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>

View File

@ -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>

View File

@ -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>
@ -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>

View File

@ -53,8 +53,7 @@ position Defines where in the grid this module&amp;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:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -53,8 +53,7 @@ position Defines where in the grid this module&amp;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:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -22,7 +22,7 @@ func NewGitRepo(repoPath string) *GitRepo {
repo.Branch = repo.branch()
repo.ChangedFiles = repo.changedFiles()
repo.Commits = repo.commits()
repo.Repository = repo.repository()
repo.Repository = strings.TrimSpace(repo.repository())
return &repo
}

145
gspreadsheets/client.go Normal file
View File

@ -0,0 +1,145 @@
/*
* This butt-ugly code is direct from Google itself
* https://developers.google.com/sheets/api/quickstart/go
*/
package gspreadsheets
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/user"
"path/filepath"
"strings"
"github.com/senorprogrammer/wtf/wtf"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
sheets "google.golang.org/api/sheets/v4"
)
/* -------------------- Exported Functions -------------------- */
func Fetch() ([]*sheets.ValueRange, error) {
ctx := context.Background()
secretPath, _ := wtf.ExpandHomeDir(Config.UString("wtf.mods.gspreadsheets.secretFile"))
b, err := ioutil.ReadFile(secretPath)
if err != nil {
log.Fatalf("Unable to read secretPath. %v", err)
return nil, err
}
config, err := google.ConfigFromJSON(b, "https://www.googleapis.com/auth/spreadsheets.readonly")
if err != nil {
log.Fatalf("Unable to get config from JSON. %v", err)
return nil, err
}
client := getClient(ctx, config)
srv, err := sheets.New(client)
if err != nil {
log.Fatalf("Unable to get create server. %v", err)
return nil, err
}
cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.addresses"))
documentId := Config.UString("wtf.mods.gspreadsheets.sheetId")
addresses := strings.Join(cells[:], ";")
responses := make([]*sheets.ValueRange, len(cells))
for i := 0; i < len(cells); i++ {
resp, err := srv.Spreadsheets.Values.Get(documentId, cells[i]).Do()
if err != nil {
log.Fatalf("Error fetching cells %s", addresses)
return nil, err
}
responses[i] = resp
}
return responses, err
}
/* -------------------- Unexported Functions -------------------- */
// getClient uses a Context and Config to retrieve a Token
// then generate a Client. It returns the generated Client.
func getClient(ctx context.Context, config *oauth2.Config) *http.Client {
cacheFile, err := tokenCacheFile()
if err != nil {
log.Fatalf("Unable to get path to cached credential file. %v", err)
}
tok, err := tokenFromFile(cacheFile)
if err != nil {
tok = getTokenFromWeb(config)
saveToken(cacheFile, tok)
}
return config.Client(ctx, tok)
}
// getTokenFromWeb uses Config to request a Token.
// It returns the retrieved Token.
func getTokenFromWeb(config *oauth2.Config) *oauth2.Token {
authURL := config.AuthCodeURL("state-token", oauth2.AccessTypeOffline)
fmt.Printf("Go to the following link in your browser then type the "+
"authorization code: \n%v\n", authURL)
var code string
if _, err := fmt.Scan(&code); err != nil {
log.Fatalf("Unable to read authorization code %v", err)
}
tok, err := config.Exchange(oauth2.NoContext, code)
if err != nil {
log.Fatalf("Unable to retrieve token from web %v", err)
}
return tok
}
// tokenCacheFile generates credential file path/filename.
// It returns the generated credential path/filename.
func tokenCacheFile() (string, error) {
usr, err := user.Current()
if err != nil {
return "", err
}
tokenCacheDir := filepath.Join(usr.HomeDir, ".credentials")
os.MkdirAll(tokenCacheDir, 0700)
return filepath.Join(tokenCacheDir,
url.QueryEscape("spreadsheets-go-quickstart.json")), err
}
// tokenFromFile retrieves a Token from a given file path.
// It returns the retrieved Token and any read error encountered.
func tokenFromFile(file string) (*oauth2.Token, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
t := &oauth2.Token{}
err = json.NewDecoder(f).Decode(t)
defer f.Close()
return t, err
}
// saveToken uses a file path to create a file and store the
// token in it.
func saveToken(file string, token *oauth2.Token) {
fmt.Printf("Saving credential file to: %s\n", file)
f, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
log.Fatalf("Unable to cache oauth token: %v", err)
}
defer f.Close()
json.NewEncoder(f).Encode(token)
}

52
gspreadsheets/widget.go Normal file
View File

@ -0,0 +1,52 @@
package gspreadsheets
import (
"fmt"
"github.com/olebedev/config"
"github.com/senorprogrammer/wtf/wtf"
sheets "google.golang.org/api/sheets/v4"
)
// Config is a pointer to the global config object
var Config *config.Config
type Widget struct {
wtf.TextWidget
}
func NewWidget() *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(" Google Spreadsheets ", "gspreadsheets", false),
}
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
cells, _ := Fetch()
widget.UpdateRefreshedAt()
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(cells)))
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) contentFrom(valueRanges []*sheets.ValueRange) string {
if valueRanges == nil {
return "error 1"
}
valuesColor := Config.UString("wtf.mods.gspreadsheets.colors.values", "green")
res := ""
cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.names"))
for i := 0; i < len(valueRanges); i++ {
res = res + fmt.Sprintf("%s\t[%s]%s\n", cells[i], valuesColor, valueRanges[i].Values[0][0])
}
return res
}

View File

@ -12,11 +12,12 @@ import (
"strings"
)
func IssuesFor(username string, project string, jql string) (*SearchResult, error) {
func IssuesFor(username string, projects []string, jql string) (*SearchResult, error) {
query := []string{}
if project != "" {
query = append(query, buildJql("project", project))
var projQuery = getProjectQuery(projects)
if projQuery != "" {
query = append(query, projQuery)
}
if username != "" {
@ -88,3 +89,18 @@ func parseJson(obj interface{}, text io.Reader) {
}
}
}
func getProjectQuery(projects []string) string {
singleEmptyProject := len(projects) == 1 && len(projects[0]) == 0
if len(projects) == 0 || singleEmptyProject {
return ""
} else if len(projects) == 1 {
return buildJql("project", projects[0])
}
quoted := make([]string, len(projects))
for i := range projects {
quoted[i] = fmt.Sprintf("\"%s\"", projects[i])
}
return fmt.Sprintf("project in (%s)", strings.Join(quoted, ", "))
}

View File

@ -25,7 +25,7 @@ func NewWidget() *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), Config.UString("wtf.mods.jira.project", ""), Config.UString("wtf.mods.jira.jql", ""))
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), getProjects(), Config.UString("wtf.mods.jira.jql", ""))
widget.UpdateRefreshedAt()
@ -81,3 +81,21 @@ func (widget *Widget) issueTypeColor(issue *Issue) string {
return color
}
func getProjects() []string {
// see if project is set to a single string
configPath := "wtf.mods.jira.project"
singleProject, err := Config.String(configPath)
if err == nil {
return []string{singleProject}
}
// else, assume list
projList := Config.UList(configPath)
var ret []string
for _, proj := range projList {
if str, ok := proj.(string); ok {
ret = append(ret, str)
}
}
return ret
}

View File

@ -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)

View File

@ -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)")

View File

@ -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() {
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

13
wtf.go
View File

@ -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"
@ -19,6 +20,7 @@ import (
"github.com/senorprogrammer/wtf/gcal"
"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/ipapi"
@ -170,6 +172,8 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
switch widgetName {
case "bamboohr":
Widgets = append(Widgets, bamboohr.NewWidget())
case "bargraph":
Widgets = append(Widgets, bargraph.NewWidget())
case "bittrex":
Widgets = append(Widgets, bittrex.NewWidget())
case "clocks":
@ -184,6 +188,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 "ipapi":
@ -227,6 +233,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) {
gcal.Config = Config
git.Config = Config
github.Config = Config
gspreadsheets.Config = Config
ipinfo.Config = Config
ipapi.Config = Config
jira.Config = Config
@ -258,7 +265,7 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) {
}
func loadConfig(configFlag string) {
Config = wtf.LoadConfigFile(configFlag)
Config = cfg.LoadConfigFile(configFlag)
}
func main() {
@ -275,8 +282,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")))

View File

@ -54,6 +54,10 @@ func (widget *BarGraph) BorderColor() string {
return Config.UString("wtf.colors.border.normal", "gray")
}
func (widget *BarGraph) Disable() {
widget.enabled = false
}
func (widget *BarGraph) Disabled() bool {
return !widget.Enabled()
}

View File

@ -53,6 +53,10 @@ func (widget *TextWidget) BorderColor() string {
return Config.UString("wtf.colors.border.normal", "gray")
}
func (widget *TextWidget) Disable() {
widget.enabled = false
}
func (widget *TextWidget) Disabled() bool {
return !widget.Enabled()
}
@ -61,10 +65,6 @@ func (widget *TextWidget) Enabled() bool {
return widget.enabled
}
func (widget *TextWidget) Disable() {
widget.enabled = false
}
func (widget *TextWidget) Focusable() bool {
return widget.enabled && widget.focusable
}