From 66c14a666db83a68bf93fd610bdddb02248ceb53 Mon Sep 17 00:00:00 2001 From: Wilq Date: Sat, 2 Jun 2018 16:52:29 +0200 Subject: [PATCH 01/15] added git pull and checkout commands --- git/git_repo.go | 13 +++++++++ git/widget.go | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/git/git_repo.go b/git/git_repo.go index 7f82e4bd..3f657732 100644 --- a/git/git_repo.go +++ b/git/git_repo.go @@ -69,6 +69,19 @@ func (repo *GitRepo) repository() string { return str } +func (repo *GitRepo) pull() string { + arg := []string{repo.gitDir(), repo.workTree(), "pull"} + cmd := exec.Command("git", arg...) + str := wtf.ExecuteCommand(cmd) + return str +} + +func (repo *GitRepo) checkout(branch string) string { + arg := []string{repo.gitDir(), repo.workTree(), "checkout", branch} + cmd := exec.Command("git", arg...) + str := wtf.ExecuteCommand(cmd) + return str +} func (repo *GitRepo) gitDir() string { return fmt.Sprintf("--git-dir=%s/.git", repo.Path) diff --git a/git/widget.go b/git/widget.go index f7b3edd2..850d3bfd 100644 --- a/git/widget.go +++ b/git/widget.go @@ -16,6 +16,8 @@ const HelpText = ` /: Show/hide this help window h: Previous git repository l: Next git repository + p: Pull current git repository + c: Checkout to branch arrow left: Previous git repository arrow right: Next git repository @@ -75,8 +77,72 @@ func (widget *Widget) Prev() { widget.display() } +func (widget *Widget) Pull() { + repoToPull := widget.Data[widget.Idx] + repoToPull.pull() + widget.Refresh() + +} +func (widget *Widget) Checkout() { + form := widget.modalForm("Branch to checkout:", "") + + checkoutFctn := func() { + text := form.GetFormItem(0).(*tview.InputField).GetText() + repoToCheckout := widget.Data[widget.Idx] + repoToCheckout.checkout(text) + widget.pages.RemovePage("modal") + widget.app.SetFocus(widget.View) + widget.display() + widget.Refresh() + } + + widget.addButtons(form, checkoutFctn) + widget.modalFocus(form) + +} /* -------------------- Unexported Functions -------------------- */ +func (widget *Widget) addCheckoutButton(form *tview.Form, fctn func()) { + form.AddButton("Checkout", fctn) +} +func (widget *Widget) addButtons(form *tview.Form, checkoutFctn func()) { + widget.addCheckoutButton(form, checkoutFctn) + widget.addCancelButton(form) +} +func (widget *Widget) addCancelButton(form *tview.Form) { + cancelFn := func() { + widget.pages.RemovePage("modal") + widget.app.SetFocus(widget.View) + widget.display() + } + + form.AddButton("Cancel", cancelFn) + form.SetCancelFunc(cancelFn) +} +func (widget *Widget) modalFocus(form *tview.Form) { + frame := widget.modalFrame(form) + widget.pages.AddPage("modal", frame, false, true) + widget.app.SetFocus(frame) +} + +func (widget *Widget) modalForm(lbl, text string) *tview.Form { + form := tview.NewForm(). + SetButtonsAlign(tview.AlignCenter). + SetButtonTextColor(tview.Styles.PrimaryTextColor) + + form.AddInputField(lbl, text, 60, nil, nil) + + 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.SetBorder(true) + frame.SetRect(w+20, h+2, 80, 7) + + return frame +} func (widget *Widget) currentData() *GitRepo { if len(widget.Data) == 0 { @@ -112,6 +178,12 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { case "l": widget.Next() return nil + case "p": + widget.Pull() + return nil + case "c": + widget.Checkout() + return nil } switch event.Key() { From 8ef0396a42b274161a38524ad3e64be4dad021e5 Mon Sep 17 00:00:00 2001 From: deltax Date: Sat, 2 Jun 2018 20:44:09 +0200 Subject: [PATCH 02/15] Fix version number in template - Change version number to 0.0.4 --- .github/ISSUE_TEMPLATE/Support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/Support.md b/.github/ISSUE_TEMPLATE/Support.md index 69eca9ef..49bcfe07 100644 --- a/.github/ISSUE_TEMPLATE/Support.md +++ b/.github/ISSUE_TEMPLATE/Support.md @@ -5,7 +5,7 @@ about: Have a problem that you can't figure out? | Q | A |------------ | ----- -| Version | 4.10.x +| Version | 0.04 #### Support Question From 651f1465dea84dee2050bf72c1eae35065449ba8 Mon Sep 17 00:00:00 2001 From: deltaxflux Date: Sat, 2 Jun 2018 20:49:40 +0200 Subject: [PATCH 03/15] Add subfolder to make pull request template working again --- .github/{ => PULL_REQUEST_TEMPLATE}/Improvement.md | 0 .github/{ => PULL_REQUEST_TEMPLATE}/Other.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ => PULL_REQUEST_TEMPLATE}/Improvement.md (100%) rename .github/{ => PULL_REQUEST_TEMPLATE}/Other.md (100%) diff --git a/.github/Improvement.md b/.github/PULL_REQUEST_TEMPLATE/Improvement.md similarity index 100% rename from .github/Improvement.md rename to .github/PULL_REQUEST_TEMPLATE/Improvement.md diff --git a/.github/Other.md b/.github/PULL_REQUEST_TEMPLATE/Other.md similarity index 100% rename from .github/Other.md rename to .github/PULL_REQUEST_TEMPLATE/Other.md From 73091d55df08c04fbc8fe1b74ceb486138d1cd8c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 2 Jun 2018 12:39:19 -0700 Subject: [PATCH 04/15] Update Support.md --- .github/ISSUE_TEMPLATE/Support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/Support.md b/.github/ISSUE_TEMPLATE/Support.md index 49bcfe07..8e127f00 100644 --- a/.github/ISSUE_TEMPLATE/Support.md +++ b/.github/ISSUE_TEMPLATE/Support.md @@ -5,7 +5,7 @@ about: Have a problem that you can't figure out? | Q | A |------------ | ----- -| Version | 0.04 +| Version | 0.0.4 #### Support Question From 14fcac116608e5ec6a4eeb13d4a04da18912f68e Mon Sep 17 00:00:00 2001 From: George Opritescu Date: Sat, 2 Jun 2018 23:02:04 +0300 Subject: [PATCH 05/15] add log flags to help with debugging --- wtf.go | 1 + 1 file changed, 1 insertion(+) diff --git a/wtf.go b/wtf.go index 43e0a55a..8a8d38ff 100644 --- a/wtf.go +++ b/wtf.go @@ -207,6 +207,7 @@ func loadConfig(configFlag string) { } func main() { + log.SetFlags(log.LstdFlags | log.Lshortfile) cmdFlags := wtf.NewCommandFlags() cmdFlags.Parse(version) From 66bd146aa087b63c09267d0115f1746728acc1d8 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Sat, 2 Jun 2018 23:26:36 +0000 Subject: [PATCH 06/15] Add Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cc422cc3..254326fd 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ displaying infrequently-needed, but very important, daily data. ## Quick Start +[![Join the chat at https://gitter.im/wtfutil/Lobby](https://badges.gitter.im/wtfutil/Lobby.svg)](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + ### Installation from Source *Note:* This has only been tested to build against Go 1.9.2. It won't From e7ec7292c673e44fb453ec762cc7843bfcd1e08e Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Sun, 3 Jun 2018 07:17:13 +0430 Subject: [PATCH 07/15] clean up, support text colors from config file --- docs/posts/modules/ipinfo/index.html | 3 ++ ipinfo/widget.go | 66 +++++++++++++++++++++------- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/docs/posts/modules/ipinfo/index.html b/docs/posts/modules/ipinfo/index.html index f6f6bde9..703d1c35 100644 --- a/docs/posts/modules/ipinfo/index.html +++ b/docs/posts/modules/ipinfo/index.html @@ -128,6 +128,9 @@

Configuration

ipinfo:
   enabled: true
+  colors:
+   name: red
+   value: white
   position:
     top: 1
     left: 2
diff --git a/ipinfo/widget.go b/ipinfo/widget.go
index a0bd3002..ff3999a2 100644
--- a/ipinfo/widget.go
+++ b/ipinfo/widget.go
@@ -3,9 +3,13 @@ package ipinfo
 import (
 	"encoding/json"
 	"fmt"
+	"net/http"
+	"text/template"
+
+	"bytes"
+
 	"github.com/olebedev/config"
 	"github.com/senorprogrammer/wtf/wtf"
-	"net/http"
 )
 
 // Config is a pointer to the global config object
@@ -14,6 +18,9 @@ var Config *config.Config
 type Widget struct {
 	wtf.TextWidget
 	result string
+	colors struct {
+		name, value string
+	}
 }
 
 type ipinfo struct {
@@ -29,11 +36,13 @@ type ipinfo struct {
 
 func NewWidget() *Widget {
 	widget := Widget{
-		TextWidget: wtf.NewTextWidget("IPInfo", "ipinfo", false),
+		TextWidget: wtf.NewTextWidget(" IPInfo ", "ipinfo", false),
 	}
 
 	widget.View.SetWrap(true)
 
+	widget.config()
+
 	return &widget
 }
 
@@ -45,9 +54,8 @@ func (widget *Widget) Refresh() {
 	widget.UpdateRefreshedAt()
 	widget.ipinfo()
 	widget.View.Clear()
-	widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name))
 
-	fmt.Fprintf(widget.View, "%s", widget.result)
+	widget.View.SetText(widget.result)
 }
 
 //this method reads the config and calls ipinfo for ip information
@@ -75,15 +83,43 @@ func (widget *Widget) ipinfo() {
 		widget.result = fmt.Sprintf("%s", err.Error())
 		return
 	}
-	widget.result = fmt.Sprintf(
-		"[red]IP Address:[white] %s\n[red]Hostname:[white] %v\n[red]City:[white] %s\n[red]Region:[white] %s\n[red]Country:[white] %s\n[red]Coordinates:[white] %v\n[red]Postal Code:[white] %s\n[red]Organization:[white] %v",
-		info.Ip,
-		info.Hostname,
-		info.City,
-		info.Region,
-		info.Country,
-		info.Coordinates,
-		info.PostalCode,
-		info.Organization,
-	)
+
+	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(
+		"[{{.nameColor}}]IP Address: [{{.valueColor}}]{{.Ip}}\n" +
+			"[{{.nameColor}}]Hostname: [{{.valueColor}}]{{.Hostname}}\n" +
+			"[{{.nameColor}}]City: [{{.valueColor}}]{{.City}}\n" +
+			"[{{.nameColor}}]Region: [{{.valueColor}}]{{.Region}}\n" +
+			"[{{.nameColor}}]Country: [{{.valueColor}}]{{.Country}}\n" +
+			"[{{.nameColor}}]Coordinates: [{{.valueColor}}]{{.Coordinates}}\n" +
+			"[{{.nameColor}}]Postal Code: [{{.valueColor}}]{{.PostalCode}}\n" +
+			"[{{.nameColor}}]Organization: [{{.valueColor}}]{{.Organization}}\n",
+	)
+
+	resultBuffer := new(bytes.Buffer)
+
+	resultTemplate.Execute(resultBuffer, map[string]string{
+		"nameColor":    widget.colors.name,
+		"valueColor":   widget.colors.value,
+		"Ip":           info.Ip,
+		"Hostname":     info.Hostname,
+		"City":         info.City,
+		"Region":       info.Region,
+		"Country":      info.Country,
+		"Coordinates":  info.Coordinates,
+		"PostalCode":   info.PostalCode,
+		"Organization": info.Organization,
+	})
+
+	widget.result = resultBuffer.String()
 }

From a546f49e52f87cc9d5aa50417bef5484fff2ebba Mon Sep 17 00:00:00 2001
From: Hossein Mehrabi 
Date: Sun, 3 Jun 2018 07:21:34 +0430
Subject: [PATCH 08/15] clean up

---
 ipinfo/widget.go | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/ipinfo/widget.go b/ipinfo/widget.go
index ff3999a2..8b18c0a4 100644
--- a/ipinfo/widget.go
+++ b/ipinfo/widget.go
@@ -96,14 +96,14 @@ func (widget *Widget) config() {
 
 func (widget *Widget) setResult(info *ipinfo) {
 	resultTemplate, _ := template.New("ipinfo_result").Parse(
-		"[{{.nameColor}}]IP Address: [{{.valueColor}}]{{.Ip}}\n" +
-			"[{{.nameColor}}]Hostname: [{{.valueColor}}]{{.Hostname}}\n" +
-			"[{{.nameColor}}]City: [{{.valueColor}}]{{.City}}\n" +
-			"[{{.nameColor}}]Region: [{{.valueColor}}]{{.Region}}\n" +
-			"[{{.nameColor}}]Country: [{{.valueColor}}]{{.Country}}\n" +
-			"[{{.nameColor}}]Coordinates: [{{.valueColor}}]{{.Coordinates}}\n" +
-			"[{{.nameColor}}]Postal Code: [{{.valueColor}}]{{.PostalCode}}\n" +
-			"[{{.nameColor}}]Organization: [{{.valueColor}}]{{.Organization}}\n",
+		formatableText("IP Address", "Ip") +
+			formatableText("Hostname", "Hostname") +
+			formatableText("City", "City") +
+			formatableText("Region", "Region") +
+			formatableText("Country", "Country") +
+			formatableText("Coordinates", "Coordinates") +
+			formatableText("Postal Code", "PostalCode") +
+			formatableText("Organization", "Organization"),
 	)
 
 	resultBuffer := new(bytes.Buffer)
@@ -123,3 +123,7 @@ func (widget *Widget) setResult(info *ipinfo) {
 
 	widget.result = resultBuffer.String()
 }
+
+func formatableText(key, value string) string {
+	return fmt.Sprintf("[{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value)
+}

From f1cf8fc93363b90f2c0d2617ae294a5aa3e252f8 Mon Sep 17 00:00:00 2001
From: Chris Cummer 
Date: Sat, 2 Jun 2018 21:06:23 -0700
Subject: [PATCH 09/15] Add documentatin for IPInfo colors

---
 _site/content/posts/modules/ipinfo.md | 11 +++++++++++
 docs/index.xml                        |  6 ++++--
 docs/posts/index.xml                  |  6 ++++--
 docs/posts/modules/ipinfo/index.html  | 14 +++++++++++---
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/_site/content/posts/modules/ipinfo.md b/_site/content/posts/modules/ipinfo.md
index 4894706a..f1c40c79 100644
--- a/_site/content/posts/modules/ipinfo.md
+++ b/_site/content/posts/modules/ipinfo.md
@@ -26,6 +26,9 @@ None.
 
 ```yaml
 ipinfo:
+  colors:
+    name: red
+    value: white
   enabled: true
   position:
     top: 1
@@ -37,6 +40,14 @@ ipinfo:
 
 ### Attributes
 
+`colors.name` 
+The default colour for the row names.
+Values: Any X11 color name. + +`colors.value`
+The default colour for the row values.
+Values: Any X11 color name. + `enabled`
Determines whether or not this module is executed and if its data displayed onscreen.
Values: `true`, `false`. diff --git a/docs/index.xml b/docs/index.xml index ccf66010..cdae0707 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -36,8 +36,10 @@ position Defines where in the grid this module’s widget will be displa Displays your current IP address information, from ipinfo.io. Source Code wtf/ipinfo/ Required ENV Variables None. Keyboard Commands None. -Configuration ipinfo:enabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false. -position Defines where in the grid this module’s widget will be displayed. refreshInterval How often, in seconds, this module will update its data. Values: A positive integer, 0..n. +Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes colors.name The default colour for the row names. Values: Any X11 color name. +colors.value The default colour for the row values. Values: Any X11 color name. +enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false. +position Defines where in the grid this module’s widget will be displayed. diff --git a/docs/posts/index.xml b/docs/posts/index.xml index 5626986c..ed7cb0bc 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -36,8 +36,10 @@ position Defines where in the grid this module’s widget will be displa Displays your current IP address information, from ipinfo.io. Source Code wtf/ipinfo/ Required ENV Variables None. Keyboard Commands None. -Configuration ipinfo:enabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false. -position Defines where in the grid this module’s widget will be displayed. refreshInterval How often, in seconds, this module will update its data. Values: A positive integer, 0..n. +Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes colors.name The default colour for the row names. Values: Any X11 color name. +colors.value The default colour for the row values. Values: Any X11 color name. +enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false. +position Defines where in the grid this module’s widget will be displayed. diff --git a/docs/posts/modules/ipinfo/index.html b/docs/posts/modules/ipinfo/index.html index 703d1c35..82387b46 100644 --- a/docs/posts/modules/ipinfo/index.html +++ b/docs/posts/modules/ipinfo/index.html @@ -127,10 +127,10 @@

Configuration

ipinfo:
-  enabled: true
   colors:
-   name: red
-   value: white
+    name: red
+    value: white
+  enabled: true
   position:
     top: 1
     left: 2
@@ -139,6 +139,14 @@
   refreshInterval: 15

Attributes

+

colors.name
+The default colour for the row names.
+Values: Any X11 color name.

+ +

colors.value
+The default colour for the row values.
+Values: Any X11 color name.

+

enabled
Determines whether or not this module is executed and if its data displayed onscreen.
Values: true, false.

From db3a82855f3f6872662f9494b3cbd6f74379714c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 2 Jun 2018 21:22:01 -0700 Subject: [PATCH 10/15] Update the readme with Gitter info --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 254326fd..6ed53242 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ displaying infrequently-needed, but very important, daily data. ## Quick Start -[![Join the chat at https://gitter.im/wtfutil/Lobby](https://badges.gitter.im/wtfutil/Lobby.svg)](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - ### Installation from Source *Note:* This has only been tested to build against Go 1.9.2. It won't @@ -25,6 +23,15 @@ make install make run ``` +Or [download the latest binary](https://github.com/senorprogrammer/wtf/releases). + +## Support + +Chat on Gitter: +[![Join the chat at https://gitter.im/wtfutil/Lobby](https://badges.gitter.im/wtfutil/Lobby.svg)](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Documentation + See [https://wtfutil.com](https://wtfutil.com) for the definitive documentation. Here's some short-cuts: @@ -45,11 +52,14 @@ And a "probably up-to-date" list of currently-implemented modules: * [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. From 332ce2a41eb7b28c7120eaa5000505d2dbd525d9 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 2 Jun 2018 21:41:01 -0700 Subject: [PATCH 11/15] Change the text wrap policy for IPInfo from true to false. No need to wrap that widget --- ipinfo/widget.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipinfo/widget.go b/ipinfo/widget.go index 8b18c0a4..eb114556 100644 --- a/ipinfo/widget.go +++ b/ipinfo/widget.go @@ -39,7 +39,7 @@ func NewWidget() *Widget { TextWidget: wtf.NewTextWidget(" IPInfo ", "ipinfo", false), } - widget.View.SetWrap(true) + widget.View.SetWrap(false) widget.config() From d14e60a8813476e3b618257781b80b460ba0e40c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 2 Jun 2018 21:42:01 -0700 Subject: [PATCH 12/15] Add left-hand margin for IPInfo widget --- ipinfo/widget.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipinfo/widget.go b/ipinfo/widget.go index eb114556..95257c45 100644 --- a/ipinfo/widget.go +++ b/ipinfo/widget.go @@ -125,5 +125,5 @@ func (widget *Widget) setResult(info *ipinfo) { } func formatableText(key, value string) string { - return fmt.Sprintf("[{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value) + return fmt.Sprintf(" [{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value) } From a4879ca1ff57cfe1f3081cf8e1993e1f429a6e5c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sat, 2 Jun 2018 21:54:19 -0700 Subject: [PATCH 13/15] Add Google Calendar authentication pointers to the GCal documenation --- _site/content/posts/modules/gcal.md | 3 +++ docs/index.xml | 6 ++---- docs/posts/index.xml | 6 ++---- docs/posts/modules/gcal/index.html | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/_site/content/posts/modules/gcal.md b/_site/content/posts/modules/gcal.md index 29860761..a5774fd3 100644 --- a/_site/content/posts/modules/gcal.md +++ b/_site/content/posts/modules/gcal.md @@ -8,6 +8,9 @@ Displays your upcoming Google calendar events. gcal screenshot +**Not:** Setting up access to Google Calendars for Go is a bit unobvious. Check out Google's [Go Quickstart](https://developers.google.com/calendar/quickstart/go) +first and if you have problems, then take a look at this [comment by WesleydeSouza](https://github.com/senorprogrammer/wtf/issues/83#issuecomment-393665229) which offers a slightly different approach. + ## Source Code ```bash diff --git a/docs/index.xml b/docs/index.xml index cdae0707..2b3ff365 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -152,12 +152,10 @@ email The email address associated with your Jira account. https://wtfutil.com/posts/modules/gcal/ Displays your upcoming Google calendar events. +Not: Setting up access to Google Calendars for Go is a bit unobvious. Check out Google’s Go Quickstart first and if you have problems, then take a look at this comment by WesleydeSouza which offers a slightly different approach. Source Code wtf/gcal/ Required ENV Variables Key: WTF_GOOGLE_CAL_CLIENT_ID Value: Your Google API client ID. Key: WTF_GOOGLE_CAL_CLIENT_SECRET Value: Your Google API client secret. -Keyboard Commands None. -Configuration gcal:colors:title:"red"description:"lightblue"highlights:-['1on1|1\/11','green']-['apple|google|aws','blue']-['interview|meet','magenta']-['lunch','yellow']past:"gray"conflictIcon:"🚨"currentIcon:"💥"displayResponseStatus:trueemail:"chriscummer@me.com"enabled:trueeventCount:12position:top:0left:0height:4width:1refreshInterval:300secretFile:"~/.wtf/gcal/client_secret.json"withLocation:true Attributes colors.title The default colour for calendar event titles. Values: Any X11 color name. -colors.description The default color for calendar event descriptions. Values: Any X11 color name. -colors.highlights A list of arrays that define a regular expression pattern and a color. +Keyboard Commands None.
diff --git a/docs/posts/index.xml b/docs/posts/index.xml index ed7cb0bc..21b14d1e 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -152,12 +152,10 @@ email The email address associated with your Jira account. https://wtfutil.com/posts/modules/gcal/ Displays your upcoming Google calendar events. +Not: Setting up access to Google Calendars for Go is a bit unobvious. Check out Google’s Go Quickstart first and if you have problems, then take a look at this comment by WesleydeSouza which offers a slightly different approach. Source Code wtf/gcal/ Required ENV Variables Key: WTF_GOOGLE_CAL_CLIENT_ID Value: Your Google API client ID. Key: WTF_GOOGLE_CAL_CLIENT_SECRET Value: Your Google API client secret. -Keyboard Commands None. -Configuration gcal:colors:title:"red"description:"lightblue"highlights:-['1on1|1\/11','green']-['apple|google|aws','blue']-['interview|meet','magenta']-['lunch','yellow']past:"gray"conflictIcon:"🚨"currentIcon:"💥"displayResponseStatus:trueemail:"chriscummer@me.com"enabled:trueeventCount:12position:top:0left:0height:4width:1refreshInterval:300secretFile:"~/.wtf/gcal/client_secret.json"withLocation:true Attributes colors.title The default colour for calendar event titles. Values: Any X11 color name. -colors.description The default color for calendar event descriptions. Values: Any X11 color name. -colors.highlights A list of arrays that define a regular expression pattern and a color. +Keyboard Commands None. diff --git a/docs/posts/modules/gcal/index.html b/docs/posts/modules/gcal/index.html index 4bafcb43..6991cc95 100644 --- a/docs/posts/modules/gcal/index.html +++ b/docs/posts/modules/gcal/index.html @@ -115,6 +115,9 @@

gcal screenshot

+

Not: Setting up access to Google Calendars for Go is a bit unobvious. Check out Google’s Go Quickstart +first and if you have problems, then take a look at this comment by WesleydeSouza which offers a slightly different approach.

+

Source Code

wtf/gcal/

Required ENV Variables

From 8f3f5e912078548863ed85f2d4678d4728803c04 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Sun, 3 Jun 2018 10:53:26 +0430 Subject: [PATCH 14/15] use widget.View.SetText to print --- bamboohr/widget.go | 3 +-- clocks/display.go | 2 +- clocks/widget.go | 1 - cmdrunner/widget.go | 3 +-- gcal/widget.go | 3 +-- git/display.go | 3 +-- github/display.go | 3 +-- jira/widget.go | 3 +-- newrelic/widget.go | 6 +++--- opsgenie/widget.go | 5 ++--- power/widget.go | 3 +-- prettyweather/widget.go | 8 ++++---- security/widget.go | 3 +-- status/widget.go | 10 +++++----- system/widget.go | 24 ++++++++++++------------ textfile/widget.go | 5 ++--- todo/display.go | 2 +- 17 files changed, 38 insertions(+), 49 deletions(-) diff --git a/bamboohr/widget.go b/bamboohr/widget.go index a8997013..a2b5f443 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -38,9 +38,8 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(todayItems))) - widget.View.Clear() - fmt.Fprintf(widget.View, "%s", widget.contentFrom(todayItems)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(todayItems))) } /* -------------------- Unexported Functions -------------------- */ diff --git a/clocks/display.go b/clocks/display.go index 1cf632e9..6cc7d60f 100644 --- a/clocks/display.go +++ b/clocks/display.go @@ -23,5 +23,5 @@ func (widget *Widget) display(clocks []Clock) { ) } - fmt.Fprintf(widget.View, "%s", str) + widget.View.SetText(fmt.Sprintf("%s", str)) } diff --git a/clocks/widget.go b/clocks/widget.go index e5214fb6..3dff6cae 100644 --- a/clocks/widget.go +++ b/clocks/widget.go @@ -34,7 +34,6 @@ func (widget *Widget) Refresh() { } widget.UpdateRefreshedAt() - widget.View.Clear() widget.display(widget.clockColl.Sorted()) } diff --git a/cmdrunner/widget.go b/cmdrunner/widget.go index a489cd2c..bb25dac6 100644 --- a/cmdrunner/widget.go +++ b/cmdrunner/widget.go @@ -40,10 +40,9 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.execute() - widget.View.Clear() widget.View.SetTitle(fmt.Sprintf(" %s ", widget)) - fmt.Fprintf(widget.View, "%s", widget.result) + widget.View.SetText(fmt.Sprintf("%s", widget.result)) } func (widget *Widget) String() string { diff --git a/gcal/widget.go b/gcal/widget.go index 112be1ca..6e2df90c 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -36,9 +36,8 @@ func (widget *Widget) Refresh() { events, _ := Fetch() widget.UpdateRefreshedAt() - widget.View.Clear() - fmt.Fprintf(widget.View, "%s", widget.contentFrom(events)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(events))) } /* -------------------- Unexported Functions -------------------- */ diff --git a/git/display.go b/git/display.go index e6fffe34..e809224f 100644 --- a/git/display.go +++ b/git/display.go @@ -9,7 +9,6 @@ import ( ) func (widget *Widget) display() { - widget.View.Clear() repoData := widget.currentData() if repoData == nil { @@ -28,7 +27,7 @@ func (widget *Widget) display() { str = str + "\n" str = str + widget.formatCommits(repoData.Commits) - fmt.Fprintf(widget.View, "%s", str) + widget.View.SetText(fmt.Sprintf("%s", str)) } func (widget *Widget) formatChanges(data []string) string { diff --git a/github/display.go b/github/display.go index a3732369..1d35ef1b 100644 --- a/github/display.go +++ b/github/display.go @@ -7,7 +7,6 @@ import ( ) func (widget *Widget) display() { - widget.View.Clear() repo := widget.currentGithubRepo() if repo == nil { @@ -27,7 +26,7 @@ func (widget *Widget) display() { str = str + " [red]My Pull Requests[white]\n" str = str + widget.displayMyPullRequests(repo, Config.UString("wtf.mods.github.username")) - fmt.Fprintf(widget.View, str) + widget.View.SetText(str) } func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string { diff --git a/jira/widget.go b/jira/widget.go index ed3c11c3..ebe85237 100644 --- a/jira/widget.go +++ b/jira/widget.go @@ -32,7 +32,6 @@ 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", "")) widget.UpdateRefreshedAt() - widget.View.Clear() if err != nil { widget.View.SetWrap(true) @@ -47,7 +46,7 @@ func (widget *Widget) Refresh() { Config.UString("wtf.mods.jira.project"), ), ) - fmt.Fprintf(widget.View, "%s", widget.contentFrom(searchResult)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(searchResult))) } } diff --git a/newrelic/widget.go b/newrelic/widget.go index c4076af9..61a72a95 100644 --- a/newrelic/widget.go +++ b/newrelic/widget.go @@ -44,10 +44,10 @@ func (widget *Widget) Refresh() { if depErr != nil { widget.View.SetWrap(true) - fmt.Fprintf(widget.View, "%s", depErr) + widget.View.SetText(fmt.Sprintf("%s", depErr)) } else { widget.View.SetWrap(false) - fmt.Fprintf(widget.View, "%s", widget.contentFrom(deploys)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(deploys))) } } @@ -70,7 +70,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string { var revLen = 8 if revLen > len(deploy.Revision) { - revLen = len(deploy.Revision) + revLen = len(deploy.Revision) } str = str + fmt.Sprintf( diff --git a/opsgenie/widget.go b/opsgenie/widget.go index 3a75ce37..1089c918 100644 --- a/opsgenie/widget.go +++ b/opsgenie/widget.go @@ -34,14 +34,13 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.View.SetTitle(" ⏰ On Call ") - widget.View.Clear() if err != nil { widget.View.SetWrap(true) - fmt.Fprintf(widget.View, "%s", err) + widget.View.SetText(fmt.Sprintf("%s", err)) } else { widget.View.SetWrap(false) - fmt.Fprintf(widget.View, "%s", widget.contentFrom(data)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(data))) } } diff --git a/power/widget.go b/power/widget.go index f971bec8..bd7a3652 100644 --- a/power/widget.go +++ b/power/widget.go @@ -34,12 +34,11 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.Battery.Refresh() - widget.View.Clear() str := "" str = str + fmt.Sprintf(" %10s: %s\n", "Source", powerSource()) str = str + "\n" str = str + widget.Battery.String() - fmt.Fprintf(widget.View, "%s", str) + widget.View.SetText(fmt.Sprintf("%s", str)) } diff --git a/prettyweather/widget.go b/prettyweather/widget.go index 0dcea050..d4e237ea 100644 --- a/prettyweather/widget.go +++ b/prettyweather/widget.go @@ -2,11 +2,12 @@ package prettyweather import ( "fmt" - "github.com/olebedev/config" - "github.com/senorprogrammer/wtf/wtf" "io/ioutil" "net/http" "strings" + + "github.com/olebedev/config" + "github.com/senorprogrammer/wtf/wtf" ) // Config is a pointer to the global config object @@ -34,10 +35,9 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.prettyWeather() - widget.View.Clear() widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name)) - fmt.Fprintf(widget.View, "%s", widget.result) + widget.View.SetText(fmt.Sprintf("%s", widget.result)) } //this method reads the config and calls wttr.in for pretty weather diff --git a/security/widget.go b/security/widget.go index 61bab3b2..2ec6ba3f 100644 --- a/security/widget.go +++ b/security/widget.go @@ -34,9 +34,8 @@ func (widget *Widget) Refresh() { data.Fetch() widget.UpdateRefreshedAt() - widget.View.Clear() - fmt.Fprintf(widget.View, "%s", widget.contentFrom(data)) + widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(data))) } /* -------------------- Unexported Functions -------------------- */ diff --git a/status/widget.go b/status/widget.go index a4f2b4d0..83d2861e 100644 --- a/status/widget.go +++ b/status/widget.go @@ -33,12 +33,12 @@ func (widget *Widget) Refresh() { } widget.UpdateRefreshedAt() - widget.View.Clear() - fmt.Fprintf( - widget.View, - "\n%s", - widget.animation(), + widget.View.SetText( + fmt.Sprintf( + "\n%s", + widget.animation(), + ), ) } diff --git a/system/widget.go b/system/widget.go index 5cfc8e60..6da695f8 100644 --- a/system/widget.go +++ b/system/widget.go @@ -38,19 +38,19 @@ func (widget *Widget) Refresh() { } widget.UpdateRefreshedAt() - widget.View.Clear() - fmt.Fprintf( - widget.View, - "%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s", - "Built", - widget.prettyDate(), - "Vers", - widget.Version, - "OS", - widget.systemInfo.ProductVersion, - "Build", - widget.systemInfo.BuildVersion, + widget.View.SetText( + fmt.Sprintf( + "%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s", + "Built", + widget.prettyDate(), + "Vers", + widget.Version, + "OS", + widget.systemInfo.ProductVersion, + "Build", + widget.systemInfo.BuildVersion, + ), ) } diff --git a/textfile/widget.go b/textfile/widget.go index e452c0d7..12f2a7fa 100644 --- a/textfile/widget.go +++ b/textfile/widget.go @@ -54,7 +54,6 @@ func (widget *Widget) Refresh() { widget.UpdateRefreshedAt() widget.View.SetTitle(fmt.Sprintf(" 📄 %s ", widget.filePath)) - widget.View.Clear() filePath, _ := wtf.ExpandHomeDir(widget.filePath) @@ -64,9 +63,9 @@ func (widget *Widget) Refresh() { } if err != nil { - fmt.Fprintf(widget.View, "%s", err) + widget.View.SetText(fmt.Sprintf("%s", err)) } else { - fmt.Fprintf(widget.View, "%s", string(fileData)) + widget.View.SetText(fmt.Sprintf("%s", string(fileData))) } } diff --git a/todo/display.go b/todo/display.go index 98f3eb72..d25d20cb 100644 --- a/todo/display.go +++ b/todo/display.go @@ -29,7 +29,7 @@ func (widget *Widget) display() { widget.SetList(&newList) widget.View.Clear() - fmt.Fprintf(widget.View, "%s", str) + widget.View.SetText(fmt.Sprintf("%s", str)) } func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string { From f39a302caa5f3bccc4ec92839fee6eef1451680f Mon Sep 17 00:00:00 2001 From: askl56 Date: Sun, 3 Jun 2018 09:22:35 +0100 Subject: [PATCH 15/15] Banish .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes gcal/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 gcal/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c815196bbdbca134abde4167b6ec0bb185d1b57b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T32AZYW|8f_mGFw;uXK#fuQC9=r(^J*c#aDH@1bX;O>UN}faC$QST+ zoc(EOtsWICGcfzjPG&aQFJUJG0Ib;$ssJSb;HV074h~<4x~_Cia@LbaWO|LRKS=KU zNcwZJsc6deQTdc8BJ`@KMlKsc4>WI#;F&^-QHCA#aS2!a?q6hI7sw5$6k7axsKy-r(N0_ z4r}##S=4vyqp}!QE47`nXjB@b5$7A*)xD$6?Ze~nY4rSJsAc#KYFV>5hF3JE_ITgw z#gUA!(W^4@5P*a$Nap<4==C7_H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0