diff --git a/_site/content/posts/modules/travisci.md b/_site/content/posts/modules/travisci.md new file mode 100644 index 00000000..b2f21fbc --- /dev/null +++ b/_site/content/posts/modules/travisci.md @@ -0,0 +1,50 @@ +--- +title: "TravisCI" +date: 2018-07-18T14:36:08-04:00 +draft: false +--- + +Displays build information for your Travis CI account. + +travisci screenshot + +## Source Code + +```bash +wtf/travisci/ +``` + +## Required ENV Variables + +Key: `WTF_TRAVIS_API_TOKEN`
+Value: Your Travis CI API access token. + +## Keyboard Commands + +None. + +## Configuration + +```yaml +travisci: + enabled: true + position: + top: 4 + left: 1 + height: 1 + width: 2 + refreshInterval: 900 +``` + +### 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`. diff --git a/_site/static/imgs/modules/travisci.png b/_site/static/imgs/modules/travisci.png new file mode 100644 index 00000000..eb423fa9 Binary files /dev/null and b/_site/static/imgs/modules/travisci.png differ diff --git a/_site/themes/hyde-hyde/layouts/partials/sidebar.html b/_site/themes/hyde-hyde/layouts/partials/sidebar.html index 45751f64..253dfcef 100644 --- a/_site/themes/hyde-hyde/layouts/partials/sidebar.html +++ b/_site/themes/hyde-hyde/layouts/partials/sidebar.html @@ -48,6 +48,7 @@ + diff --git a/docs/404.html b/docs/404.html index 19e488fb..ee6de015 100644 --- a/docs/404.html +++ b/docs/404.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/categories/index.html b/docs/categories/index.html index ba7b786a..db2efb7d 100644 --- a/docs/categories/index.html +++ b/docs/categories/index.html @@ -103,6 +103,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/imgs/modules/travisci.png b/docs/imgs/modules/travisci.png new file mode 100644 index 00000000..eb423fa9 Binary files /dev/null and b/docs/imgs/modules/travisci.png differ diff --git a/docs/index.html b/docs/index.html index 1efc0f21..5eb51260 100644 --- a/docs/index.html +++ b/docs/index.html @@ -102,6 +102,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/index.xml b/docs/index.xml index b46704d6..8d2442ad 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -6,11 +6,24 @@ Recent content on WTF - A Terminal Dashboard Hugo -- gohugo.io en-us - Thu, 05 Jul 2018 22:55:55 -0300 + Wed, 18 Jul 2018 14:36:08 -0400 + + TravisCI + https://wtfutil.com/posts/modules/travisci/ + Wed, 18 Jul 2018 14:36:08 -0400 + + https://wtfutil.com/posts/modules/travisci/ + Displays build information for your Travis CI account. +Source Code wtf/travisci/ Required ENV Variables Key: WTF_TRAVIS_API_TOKEN Value: Your Travis CI API access token. +Keyboard Commands None. +Configuration travisci:enabled:trueposition:top:4left:1height:1width:2refreshInterval:900 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. + + Todoist https://wtfutil.com/posts/modules/todoist/ @@ -128,7 +141,7 @@ position Where in the grid this module’s widget will be displayed. diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html index af6dc359..126d33cb 100644 --- a/docs/posts/configuration/attributes/index.html +++ b/docs/posts/configuration/attributes/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/configuration/index.html b/docs/posts/configuration/index.html index 9ba7763b..e49c89d5 100644 --- a/docs/posts/configuration/index.html +++ b/docs/posts/configuration/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/configuration/iterm2/index.html b/docs/posts/configuration/iterm2/index.html index 86337b36..319ad5f7 100644 --- a/docs/posts/configuration/iterm2/index.html +++ b/docs/posts/configuration/iterm2/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/glossary/index.html b/docs/posts/glossary/index.html index 34ffb517..f1d9cee4 100644 --- a/docs/posts/glossary/index.html +++ b/docs/posts/glossary/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/index.html b/docs/posts/index.html index 0a45a14d..ba7b8a29 100644 --- a/docs/posts/index.html +++ b/docs/posts/index.html @@ -103,6 +103,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + @@ -121,6 +122,13 @@ height="0" width="0" style="display:none;visibility:hidden">

Posts

diff --git a/docs/posts/modules/bamboohr/index.html b/docs/posts/modules/bamboohr/index.html index a81753b1..437c197a 100644 --- a/docs/posts/modules/bamboohr/index.html +++ b/docs/posts/modules/bamboohr/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/circleci/index.html b/docs/posts/modules/circleci/index.html index 21ccef72..1ad44416 100644 --- a/docs/posts/modules/circleci/index.html +++ b/docs/posts/modules/circleci/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/clocks/index.html b/docs/posts/modules/clocks/index.html index eda18040..eab939e3 100644 --- a/docs/posts/modules/clocks/index.html +++ b/docs/posts/modules/clocks/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/cmdrunner/index.html b/docs/posts/modules/cmdrunner/index.html index 65d36521..c11f9996 100644 --- a/docs/posts/modules/cmdrunner/index.html +++ b/docs/posts/modules/cmdrunner/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/cryptocurrencies/bittrex/index.html b/docs/posts/modules/cryptocurrencies/bittrex/index.html index d6fd094e..68d8658e 100644 --- a/docs/posts/modules/cryptocurrencies/bittrex/index.html +++ b/docs/posts/modules/cryptocurrencies/bittrex/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/cryptocurrencies/blockfolio/index.html b/docs/posts/modules/cryptocurrencies/blockfolio/index.html index 5320a885..5396e71d 100644 --- a/docs/posts/modules/cryptocurrencies/blockfolio/index.html +++ b/docs/posts/modules/cryptocurrencies/blockfolio/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/cryptocurrencies/cryptolive/index.html b/docs/posts/modules/cryptocurrencies/cryptolive/index.html index 149571ea..d24207f7 100644 --- a/docs/posts/modules/cryptocurrencies/cryptolive/index.html +++ b/docs/posts/modules/cryptocurrencies/cryptolive/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/gcal/index.html b/docs/posts/modules/gcal/index.html index db7d7927..ae76f40f 100644 --- a/docs/posts/modules/gcal/index.html +++ b/docs/posts/modules/gcal/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/gerrit/index.html b/docs/posts/modules/gerrit/index.html index 371ed832..d5cf8fee 100644 --- a/docs/posts/modules/gerrit/index.html +++ b/docs/posts/modules/gerrit/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/git/index.html b/docs/posts/modules/git/index.html index 9dbf14c8..bd1877a0 100644 --- a/docs/posts/modules/git/index.html +++ b/docs/posts/modules/git/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/github/index.html b/docs/posts/modules/github/index.html index 874a21d3..745d9573 100644 --- a/docs/posts/modules/github/index.html +++ b/docs/posts/modules/github/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/gitlab/index.html b/docs/posts/modules/gitlab/index.html index 0ce3cf25..9e0026fc 100644 --- a/docs/posts/modules/gitlab/index.html +++ b/docs/posts/modules/gitlab/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/gspreadsheet/index.html b/docs/posts/modules/gspreadsheet/index.html index 8abd7447..98981d92 100644 --- a/docs/posts/modules/gspreadsheet/index.html +++ b/docs/posts/modules/gspreadsheet/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/index.html b/docs/posts/modules/index.html index 465c33c1..5e47fd89 100644 --- a/docs/posts/modules/index.html +++ b/docs/posts/modules/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/ipapi/index.html b/docs/posts/modules/ipapi/index.html index 0687ff17..af1ead96 100644 --- a/docs/posts/modules/ipapi/index.html +++ b/docs/posts/modules/ipapi/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/ipinfo/index.html b/docs/posts/modules/ipinfo/index.html index 12b0b563..11c6dd47 100644 --- a/docs/posts/modules/ipinfo/index.html +++ b/docs/posts/modules/ipinfo/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/jenkins/index.html b/docs/posts/modules/jenkins/index.html index e83d2d32..e938715a 100644 --- a/docs/posts/modules/jenkins/index.html +++ b/docs/posts/modules/jenkins/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/jira/index.html b/docs/posts/modules/jira/index.html index 52c4bf55..8d253586 100644 --- a/docs/posts/modules/jira/index.html +++ b/docs/posts/modules/jira/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/logger/index.html b/docs/posts/modules/logger/index.html index 8be2231f..25589460 100644 --- a/docs/posts/modules/logger/index.html +++ b/docs/posts/modules/logger/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/newrelic/index.html b/docs/posts/modules/newrelic/index.html index a5505583..620682c7 100644 --- a/docs/posts/modules/newrelic/index.html +++ b/docs/posts/modules/newrelic/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/opsgenie/index.html b/docs/posts/modules/opsgenie/index.html index 1f0209d4..55e1cc52 100644 --- a/docs/posts/modules/opsgenie/index.html +++ b/docs/posts/modules/opsgenie/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/power/index.html b/docs/posts/modules/power/index.html index 49d92ccf..aafe2b73 100644 --- a/docs/posts/modules/power/index.html +++ b/docs/posts/modules/power/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/prettyweather/index.html b/docs/posts/modules/prettyweather/index.html index 7b29359c..fc88defa 100644 --- a/docs/posts/modules/prettyweather/index.html +++ b/docs/posts/modules/prettyweather/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/security/index.html b/docs/posts/modules/security/index.html index fea91832..e7a0c4f0 100644 --- a/docs/posts/modules/security/index.html +++ b/docs/posts/modules/security/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/textfile/index.html b/docs/posts/modules/textfile/index.html index 8542d0ae..8506d5b0 100644 --- a/docs/posts/modules/textfile/index.html +++ b/docs/posts/modules/textfile/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/todo/index.html b/docs/posts/modules/todo/index.html index 3eed5d63..c7baba9f 100644 --- a/docs/posts/modules/todo/index.html +++ b/docs/posts/modules/todo/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/todoist/index.html b/docs/posts/modules/todoist/index.html index 840b496d..8558afcb 100644 --- a/docs/posts/modules/todoist/index.html +++ b/docs/posts/modules/todoist/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/travisci/index.html b/docs/posts/modules/travisci/index.html new file mode 100644 index 00000000..4f2afdbd --- /dev/null +++ b/docs/posts/modules/travisci/index.html @@ -0,0 +1,187 @@ + + + + + + + + + + + + +TravisCI | WTF - A Terminal Dashboard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

TravisCI

+ +
+ +
+ + + +

Displays build information for your Travis CI account.

+ +

travisci screenshot

+ +

Source Code

+
wtf/travisci/
+

Required ENV Variables

+ +

Key: WTF_TRAVIS_API_TOKEN
+Value: Your Travis CI API access token.

+ +

Keyboard Commands

+ +

None.

+ +

Configuration

+
travisci:
+  enabled: true
+  position:
+    top: 4
+    left: 1
+    height: 1
+    width: 2
+  refreshInterval: 900
+

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.

+ +
+ + +
+ + + + diff --git a/docs/posts/modules/trello/index.html b/docs/posts/modules/trello/index.html index a5bba26e..e8133aac 100644 --- a/docs/posts/modules/trello/index.html +++ b/docs/posts/modules/trello/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/weather/index.html b/docs/posts/modules/weather/index.html index 92f65b80..54457351 100644 --- a/docs/posts/modules/weather/index.html +++ b/docs/posts/modules/weather/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/overview/index.html b/docs/posts/overview/index.html index 474ae967..e3c52415 100644 --- a/docs/posts/overview/index.html +++ b/docs/posts/overview/index.html @@ -101,6 +101,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index fbd256d7..1d9d59c7 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -2,6 +2,11 @@ + + https://wtfutil.com/posts/modules/travisci/ + 2018-07-18T14:36:08-04:00 + + https://wtfutil.com/posts/modules/todoist/ 2018-07-05T22:55:55-03:00 @@ -184,7 +189,7 @@ https://wtfutil.com/posts/ - 2018-07-05T22:55:55-03:00 + 2018-07-18T14:36:08-04:00 0 @@ -195,7 +200,7 @@ https://wtfutil.com/ - 2018-07-05T22:55:55-03:00 + 2018-07-18T14:36:08-04:00 0 diff --git a/docs/tags/index.html b/docs/tags/index.html index 02fc016b..0c53a0f7 100644 --- a/docs/tags/index.html +++ b/docs/tags/index.html @@ -103,6 +103,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/travisci/client.go b/travisci/client.go new file mode 100644 index 00000000..a8ae8b79 --- /dev/null +++ b/travisci/client.go @@ -0,0 +1,84 @@ +package travisci + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" +) + +const APIEnvToken = "WTF_TRAVIS_API_TOKEN" + +func BuildsFor() (*Builds, error) { + builds := &Builds{} + + resp, err := travisRequest("builds") + if err != nil { + return builds, err + } + + parseJson(&builds, resp.Body) + + return builds, nil +} + +/* -------------------- Unexported Functions -------------------- */ + +var ( + travisAPIURL = &url.URL{Scheme: "https", Host: "api.travis-ci.org", Path: "/"} +) + +func travisRequest(path string) (*http.Response, error) { + params := url.Values{} + params.Add("limit", "10") + + url := travisAPIURL.ResolveReference(&url.URL{Path: path, RawQuery: params.Encode()}) + + req, err := http.NewRequest("GET", url.String(), nil) + req.Header.Add("Accept", "application/json") + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Travis-API-Version", "3") + + bearer := fmt.Sprintf("token %s", apiToken()) + req.Header.Add("Authorization", bearer) + if err != nil { + return nil, err + } + + httpClient := &http.Client{} + resp, err := httpClient.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return nil, fmt.Errorf(resp.Status) + } + + return resp, nil +} + +func apiToken() string { + return os.Getenv(APIEnvToken) +} + +func parseJson(obj interface{}, text io.Reader) { + jsonStream, err := ioutil.ReadAll(text) + if err != nil { + panic(err) + } + + decoder := json.NewDecoder(bytes.NewReader(jsonStream)) + + for { + if err := decoder.Decode(obj); err == io.EOF { + break + } else if err != nil { + panic(err) + } + } +} diff --git a/travisci/travis.go b/travisci/travis.go new file mode 100644 index 00000000..47f619e6 --- /dev/null +++ b/travisci/travis.go @@ -0,0 +1,25 @@ +package travisci + +type Builds struct { + Builds []Build `json:"builds"` +} + +type Build struct { + CreatedBy Owner `json:"created_by"` + Branch Branch `json:"branch"` + Number string `json:"number"` + Repository Repository `json:"repository"` + State string `json:"state"` +} + +type Owner struct { + Login string `json:"login"` +} + +type Branch struct { + Name string `json:"name"` +} + +type Repository struct { + Name string `json:"name"` +} diff --git a/travisci/widget.go b/travisci/widget.go new file mode 100644 index 00000000..d4d01b5d --- /dev/null +++ b/travisci/widget.go @@ -0,0 +1,82 @@ +package travisci + +import ( + "fmt" + "github.com/senorprogrammer/wtf/wtf" +) + +type Widget struct { + wtf.TextWidget +} + +func NewWidget() *Widget { + widget := Widget{ + TextWidget: wtf.NewTextWidget(" Travis CI", "travisci", false), + } + + return &widget +} + +/* -------------------- Exported Functions -------------------- */ + +func (widget *Widget) Refresh() { + if widget.Disabled() { + return + } + + builds, err := BuildsFor() + + widget.UpdateRefreshedAt() + + widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.Name)) + + var content string + if err != nil { + widget.View.SetWrap(true) + content = err.Error() + } else { + widget.View.SetWrap(false) + content = widget.contentFrom(builds) + } + + widget.View.SetText(content) +} + +/* -------------------- Unexported Functions -------------------- */ + +func (widget *Widget) contentFrom(builds *Builds) string { + var str string + for _, build := range builds.Builds { + str = str + fmt.Sprintf( + "[%s] %s-%s (%s) [white]%s\n", + buildColor(&build), + build.Repository.Name, + build.Number, + build.Branch.Name, + build.CreatedBy.Login, + ) + } + + return str +} + +func buildColor(build *Build) string { + switch build.State { + case "broken": + return "red" + case "failed": + return "red" + case "failing": + return "red" + case "pending": + return "yellow" + case "started": + return "yellow" + case "fixed": + return "green" + case "passed": + return "green" + default: + return "white" + } +} diff --git a/wtf.go b/wtf.go index 4d285251..efeac338 100644 --- a/wtf.go +++ b/wtf.go @@ -41,6 +41,7 @@ import ( "github.com/senorprogrammer/wtf/textfile" "github.com/senorprogrammer/wtf/todo" "github.com/senorprogrammer/wtf/todoist" + "github.com/senorprogrammer/wtf/travisci" "github.com/senorprogrammer/wtf/trello" "github.com/senorprogrammer/wtf/weatherservices/prettyweather" "github.com/senorprogrammer/wtf/weatherservices/weather" @@ -222,6 +223,8 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) { Widgets = append(Widgets, todo.NewWidget(app, pages)) case "todoist": Widgets = append(Widgets, todoist.NewWidget(app, pages)) + case "travisci": + Widgets = append(Widgets, travisci.NewWidget()) case "trello": Widgets = append(Widgets, trello.NewWidget()) case "weather":