diff --git a/Makefile b/Makefile index dfa59a84..55414bf7 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ contrib_check: install: go clean - go install -ldflags="-s -w -X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)" + #go install -ldflags="-s -w -X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)" + go install -ldflags="-X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)" which wtf lint: diff --git a/_site/content/posts/modules/gitter.md b/_site/content/posts/modules/gitter.md new file mode 100644 index 00000000..cb500c8a --- /dev/null +++ b/_site/content/posts/modules/gitter.md @@ -0,0 +1,75 @@ +--- +title: "Gitter" +date: 2018-08-02T12:36:08-04:00 +draft: false +--- + +Added in `v0.2.1`. + +Displays chat messages from Gitter. + +gitter screenshot + +## Source Code + +```bash +wtf/gitter/ +``` + +## Keyboard Commands + +Key: `j`
+Action: Select the next message in the list. + +Key: `k`
+Action: Select the previous message in the list. + +Key: `r`
+Action: Refresh the data. + +Key: `↓`
+Action: Select the next message in the list. + +Key: `↑`
+Action: Select the previous message in the list. + +## Configuration + +```yaml +gitter: + apiToken: "ab345546asdfasb465234fgjgh068f39a35c3e4139ee383f7" + enabled: true + numberOfMessages: 10 + position: + top: 4 + left: 1 + height: 1 + width: 4 + roomUri: wtfutil/Lobby + refreshInterval: 300 +``` + +### Attributes + +`apiToken`
+Value: Your GitterPersonal Access Token. + +`enabled`
+Determines whether or not this module is executed and if its data displayed onscreen.
+Values: `true`, `false`. + +`numberOfMessages`
+_Optional_
+Maximum number of _(newest)_ messages to be displayed. Default is `10`
+ +`position`
+Defines where in the grid this module's widget will be displayed.
+ +`roomUri`
+_Optional_
+Values: `new`, `top`, `job`, `ask` + +`refreshInterval`
+How often, in seconds, this module will update its data.
+Values: A positive integer, `0..n`. diff --git a/_site/static/imgs/modules/gitter.png b/_site/static/imgs/modules/gitter.png new file mode 100644 index 00000000..bdd1c7ad Binary files /dev/null and b/_site/static/imgs/modules/gitter.png differ diff --git a/_site/themes/hyde-hyde/layouts/partials/sidebar.html b/_site/themes/hyde-hyde/layouts/partials/sidebar.html index 438647a7..bda6f93c 100644 --- a/_site/themes/hyde-hyde/layouts/partials/sidebar.html +++ b/_site/themes/hyde-hyde/layouts/partials/sidebar.html @@ -34,6 +34,7 @@ + diff --git a/docs/404.html b/docs/404.html index ecafbfe3..aad522fa 100644 --- a/docs/404.html +++ b/docs/404.html @@ -8,7 +8,7 @@ - + 404 Page not found | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/categories/index.html b/docs/categories/index.html index a481fa53..c3e3a661 100644 --- a/docs/categories/index.html +++ b/docs/categories/index.html @@ -8,7 +8,7 @@ - + Categories | WTF - A Terminal Dashboard @@ -89,6 +89,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/imgs/modules/gitter.png b/docs/imgs/modules/gitter.png new file mode 100644 index 00000000..bdd1c7ad Binary files /dev/null and b/docs/imgs/modules/gitter.png differ diff --git a/docs/index.html b/docs/index.html index 17acc8a8..c33abbbf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,7 +8,7 @@ - + WTF - A Terminal Dashboard @@ -88,6 +88,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/index.xml b/docs/index.xml index d80fa280..4bcd1598 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -27,6 +27,23 @@ Key: ↓ Action: Select the next story in the list. Key: ↑ Action: Select the previous story in the list. + + Gitter + https://wtfutil.com/posts/modules/gitter/ + Thu, 02 Aug 2018 12:36:08 -0400 + + https://wtfutil.com/posts/modules/gitter/ + Added in v0.2.1. +Displays chat messages from Gitter. +Source Code wtf/gitter/ Keyboard Commands Key: j Action: Select the next message in the list. +Key: k Action: Select the previous message in the list. +Key: r Action: Refresh the data. +Key: ↓ Action: Select the next message in the list. +Key: ↑ Action: Select the previous message in the list. +Configuration gitter:apiToken:"ab345546asdfasb465234fgjgh068f39a35c3e4139ee383f7"enabled:truenumberOfMessages:10position:top:4left:1height:1width:4roomUri:wtfutil/LobbyrefreshInterval:300 Attributes apiToken Value: Your GitterPersonal Access Token. +enabled Determines whether or not this module is executed and if its data displayed onscreen. + + Twitter https://wtfutil.com/posts/modules/twitter/ diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html index ba4470b2..ab0f03d8 100644 --- a/docs/posts/configuration/attributes/index.html +++ b/docs/posts/configuration/attributes/index.html @@ -8,7 +8,7 @@ - + Configuration: Attributes | WTF - A Terminal Dashboard @@ -87,6 +87,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 6df824d6..5d99c019 100644 --- a/docs/posts/configuration/index.html +++ b/docs/posts/configuration/index.html @@ -8,7 +8,7 @@ - + Configuration | WTF - A Terminal Dashboard @@ -87,6 +87,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 18d1b895..b9e6020a 100644 --- a/docs/posts/configuration/iterm2/index.html +++ b/docs/posts/configuration/iterm2/index.html @@ -8,7 +8,7 @@ - + Configuration: iTerm2 | WTF - A Terminal Dashboard @@ -87,6 +87,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 5349138d..1033dc5c 100644 --- a/docs/posts/glossary/index.html +++ b/docs/posts/glossary/index.html @@ -8,7 +8,7 @@ - + Glossary | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/index.html b/docs/posts/index.html index 6f66b37f..87157aba 100644 --- a/docs/posts/index.html +++ b/docs/posts/index.html @@ -8,7 +8,7 @@ - + Posts | WTF - A Terminal Dashboard @@ -89,6 +89,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + @@ -129,6 +130,13 @@ height="0" width="0" style="display:none;visibility:hidden"> + +
  • + + Gitter + + +
  • diff --git a/docs/posts/index.xml b/docs/posts/index.xml index bdf1aa67..d6140267 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -27,6 +27,23 @@ Key: ↓ Action: Select the next story in the list. Key: ↑ Action: Select the previous story in the list. + + Gitter + https://wtfutil.com/posts/modules/gitter/ + Thu, 02 Aug 2018 12:36:08 -0400 + + https://wtfutil.com/posts/modules/gitter/ + Added in v0.2.1. +Displays chat messages from Gitter. +Source Code wtf/gitter/ Keyboard Commands Key: j Action: Select the next message in the list. +Key: k Action: Select the previous message in the list. +Key: r Action: Refresh the data. +Key: ↓ Action: Select the next message in the list. +Key: ↑ Action: Select the previous message in the list. +Configuration gitter:apiToken:"ab345546asdfasb465234fgjgh068f39a35c3e4139ee383f7"enabled:truenumberOfMessages:10position:top:4left:1height:1width:4roomUri:wtfutil/LobbyrefreshInterval:300 Attributes apiToken Value: Your GitterPersonal Access Token. +enabled Determines whether or not this module is executed and if its data displayed onscreen. + + Twitter https://wtfutil.com/posts/modules/twitter/ diff --git a/docs/posts/installation/index.html b/docs/posts/installation/index.html index 5f3505ec..d13619c8 100644 --- a/docs/posts/installation/index.html +++ b/docs/posts/installation/index.html @@ -8,7 +8,7 @@ - + Installation | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden">
  • + diff --git a/docs/posts/modules/bamboohr/index.html b/docs/posts/modules/bamboohr/index.html index ba93113a..5715d3cd 100644 --- a/docs/posts/modules/bamboohr/index.html +++ b/docs/posts/modules/bamboohr/index.html @@ -8,7 +8,7 @@ - + BambooHR | WTF - A Terminal Dashboard @@ -87,6 +87,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 f8d767ba..020447e0 100644 --- a/docs/posts/modules/circleci/index.html +++ b/docs/posts/modules/circleci/index.html @@ -8,7 +8,7 @@ - + CircleCI | WTF - A Terminal Dashboard @@ -87,6 +87,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 c09d1319..acca1616 100644 --- a/docs/posts/modules/clocks/index.html +++ b/docs/posts/modules/clocks/index.html @@ -8,7 +8,7 @@ - + Clocks | WTF - A Terminal Dashboard @@ -87,6 +87,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 752e85cc..46728c99 100644 --- a/docs/posts/modules/cmdrunner/index.html +++ b/docs/posts/modules/cmdrunner/index.html @@ -8,7 +8,7 @@ - + CmdRunner | WTF - A Terminal Dashboard @@ -87,6 +87,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 f2942967..6a4af406 100644 --- a/docs/posts/modules/cryptocurrencies/bittrex/index.html +++ b/docs/posts/modules/cryptocurrencies/bittrex/index.html @@ -8,7 +8,7 @@ - + Bittrex | WTF - A Terminal Dashboard @@ -87,6 +87,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 41512fcd..142b944b 100644 --- a/docs/posts/modules/cryptocurrencies/blockfolio/index.html +++ b/docs/posts/modules/cryptocurrencies/blockfolio/index.html @@ -8,7 +8,7 @@ - + Blockfolio | WTF - A Terminal Dashboard @@ -87,6 +87,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 2680c5e3..3a777388 100644 --- a/docs/posts/modules/cryptocurrencies/cryptolive/index.html +++ b/docs/posts/modules/cryptocurrencies/cryptolive/index.html @@ -8,7 +8,7 @@ - + CryptoLive | WTF - A Terminal Dashboard @@ -87,6 +87,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 3e4938c7..bea85d8d 100644 --- a/docs/posts/modules/gcal/index.html +++ b/docs/posts/modules/gcal/index.html @@ -8,7 +8,7 @@ - + Google Calendar | WTF - A Terminal Dashboard @@ -87,6 +87,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 8d98d3b1..71f98d8d 100644 --- a/docs/posts/modules/gerrit/index.html +++ b/docs/posts/modules/gerrit/index.html @@ -8,7 +8,7 @@ - + Gerrit | WTF - A Terminal Dashboard @@ -87,6 +87,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 733ffde0..a47b943d 100644 --- a/docs/posts/modules/git/index.html +++ b/docs/posts/modules/git/index.html @@ -8,7 +8,7 @@ - + Git | WTF - A Terminal Dashboard @@ -87,6 +87,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 d73a9a3b..da349e32 100644 --- a/docs/posts/modules/github/index.html +++ b/docs/posts/modules/github/index.html @@ -8,7 +8,7 @@ - + GitHub | WTF - A Terminal Dashboard @@ -87,6 +87,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 6b27d748..18940490 100644 --- a/docs/posts/modules/gitlab/index.html +++ b/docs/posts/modules/gitlab/index.html @@ -8,7 +8,7 @@ - + GitLab | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/gitter/index.html b/docs/posts/modules/gitter/index.html new file mode 100644 index 00000000..21b86cc2 --- /dev/null +++ b/docs/posts/modules/gitter/index.html @@ -0,0 +1,215 @@ + + + + + + + + + + + + +Gitter | WTF - A Terminal Dashboard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +

    Gitter

    + +
    + +
    + + + +

    Added in v0.2.1.

    + +

    Displays chat messages from Gitter.

    + +

    gitter screenshot

    + +

    Source Code

    +
    wtf/gitter/
    +

    Keyboard Commands

    + +

    Key: j
    +Action: Select the next message in the list.

    + +

    Key: k
    +Action: Select the previous message in the list.

    + +

    Key: r
    +Action: Refresh the data.

    + +

    Key:
    +Action: Select the next message in the list.

    + +

    Key:
    +Action: Select the previous message in the list.

    + +

    Configuration

    +
    gitter:
    +  apiToken: "ab345546asdfasb465234fgjgh068f39a35c3e4139ee383f7"
    +  enabled: true
    +  numberOfMessages: 10
    +  position:
    +    top: 4
    +    left: 1
    +    height: 1
    +    width: 4
    +  roomUri: wtfutil/Lobby
    +  refreshInterval: 300
    +

    Attributes

    + +

    apiToken
    +Value: Your GitterPersonal Access Token.

    + +

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

    + +

    numberOfMessages
    +Optional
    +Maximum number of (newest) messages to be displayed. Default is 10

    + +

    position
    +Defines where in the grid this module’s widget will be displayed.

    + +

    roomUri
    +Optional
    +Values: new, top, job, ask

    + +

    refreshInterval
    +How often, in seconds, this module will update its data.
    +Values: A positive integer, 0..n.

    + +
    + + +
    + + + + diff --git a/docs/posts/modules/gspreadsheet/index.html b/docs/posts/modules/gspreadsheet/index.html index 5df06d08..0ca4c9fc 100644 --- a/docs/posts/modules/gspreadsheet/index.html +++ b/docs/posts/modules/gspreadsheet/index.html @@ -8,7 +8,7 @@ - + Google Spreadsheets | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/hackernews/index.html b/docs/posts/modules/hackernews/index.html index e9993c8e..b7ced333 100644 --- a/docs/posts/modules/hackernews/index.html +++ b/docs/posts/modules/hackernews/index.html @@ -8,7 +8,7 @@ - + Hacker News | WTF - A Terminal Dashboard @@ -87,6 +87,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 fbb6d84a..856c846a 100644 --- a/docs/posts/modules/index.html +++ b/docs/posts/modules/index.html @@ -8,7 +8,7 @@ - + Modules | WTF - A Terminal Dashboard @@ -87,6 +87,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 20ec1e33..91e322af 100644 --- a/docs/posts/modules/ipapi/index.html +++ b/docs/posts/modules/ipapi/index.html @@ -8,7 +8,7 @@ - + IP-API | WTF - A Terminal Dashboard @@ -87,6 +87,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 041870b3..ee285862 100644 --- a/docs/posts/modules/ipinfo/index.html +++ b/docs/posts/modules/ipinfo/index.html @@ -8,7 +8,7 @@ - + IPInfo | WTF - A Terminal Dashboard @@ -87,6 +87,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 f55c7874..c943ec46 100644 --- a/docs/posts/modules/jenkins/index.html +++ b/docs/posts/modules/jenkins/index.html @@ -8,7 +8,7 @@ - + Modules: Jenkins | WTF - A Terminal Dashboard @@ -87,6 +87,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 1bd08389..e1e446a1 100644 --- a/docs/posts/modules/jira/index.html +++ b/docs/posts/modules/jira/index.html @@ -8,7 +8,7 @@ - + Jira | WTF - A Terminal Dashboard @@ -87,6 +87,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 e103eb1f..9e55030a 100644 --- a/docs/posts/modules/logger/index.html +++ b/docs/posts/modules/logger/index.html @@ -8,7 +8,7 @@ - + Logger | WTF - A Terminal Dashboard @@ -87,6 +87,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 60309234..84abe8c2 100644 --- a/docs/posts/modules/newrelic/index.html +++ b/docs/posts/modules/newrelic/index.html @@ -8,7 +8,7 @@ - + New Relic | WTF - A Terminal Dashboard @@ -87,6 +87,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 5e84789f..2b22ffc9 100644 --- a/docs/posts/modules/opsgenie/index.html +++ b/docs/posts/modules/opsgenie/index.html @@ -8,7 +8,7 @@ - + OpsGenie | WTF - A Terminal Dashboard @@ -87,6 +87,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 41ee943a..a4095c42 100644 --- a/docs/posts/modules/power/index.html +++ b/docs/posts/modules/power/index.html @@ -8,7 +8,7 @@ - + Power | WTF - A Terminal Dashboard @@ -87,6 +87,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 f1d329d1..2223f275 100644 --- a/docs/posts/modules/prettyweather/index.html +++ b/docs/posts/modules/prettyweather/index.html @@ -8,7 +8,7 @@ - + Pretty Weather | WTF - A Terminal Dashboard @@ -87,6 +87,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 60ca147d..c8c96e9b 100644 --- a/docs/posts/modules/security/index.html +++ b/docs/posts/modules/security/index.html @@ -8,7 +8,7 @@ - + Security | WTF - A Terminal Dashboard @@ -87,6 +87,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 a32c10be..19b7852e 100644 --- a/docs/posts/modules/textfile/index.html +++ b/docs/posts/modules/textfile/index.html @@ -8,7 +8,7 @@ - + Textfile | WTF - A Terminal Dashboard @@ -87,6 +87,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 c51ae52c..e3dabba3 100644 --- a/docs/posts/modules/todo/index.html +++ b/docs/posts/modules/todo/index.html @@ -8,7 +8,7 @@ - + Todo | WTF - A Terminal Dashboard @@ -87,6 +87,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 39efe7e8..3aa1baee 100644 --- a/docs/posts/modules/todoist/index.html +++ b/docs/posts/modules/todoist/index.html @@ -8,7 +8,7 @@ - + Todoist | WTF - A Terminal Dashboard @@ -87,6 +87,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 index 908dc159..b1a94a69 100644 --- a/docs/posts/modules/travisci/index.html +++ b/docs/posts/modules/travisci/index.html @@ -8,7 +8,7 @@ - + TravisCI | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/trello/index.html b/docs/posts/modules/trello/index.html index 745f3b40..a13ed94d 100644 --- a/docs/posts/modules/trello/index.html +++ b/docs/posts/modules/trello/index.html @@ -8,7 +8,7 @@ - + Trello | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/twitter/index.html b/docs/posts/modules/twitter/index.html index 2688e820..b0320135 100644 --- a/docs/posts/modules/twitter/index.html +++ b/docs/posts/modules/twitter/index.html @@ -8,7 +8,7 @@ - + Twitter | WTF - A Terminal Dashboard @@ -87,6 +87,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 1df8c6ab..960c86db 100644 --- a/docs/posts/modules/weather/index.html +++ b/docs/posts/modules/weather/index.html @@ -8,7 +8,7 @@ - + Weather | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/posts/modules/zendesk/index.html b/docs/posts/modules/zendesk/index.html index fc406824..d6e1ab6a 100644 --- a/docs/posts/modules/zendesk/index.html +++ b/docs/posts/modules/zendesk/index.html @@ -8,7 +8,7 @@ - + Zendesk | WTF - A Terminal Dashboard @@ -87,6 +87,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 a03f4a7f..6a9e2df7 100644 --- a/docs/posts/overview/index.html +++ b/docs/posts/overview/index.html @@ -8,7 +8,7 @@ - + Overview | WTF - A Terminal Dashboard @@ -87,6 +87,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index f63a628c..95fcf933 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -7,6 +7,11 @@ 2018-08-02T16:36:08-04:00 + + https://wtfutil.com/posts/modules/gitter/ + 2018-08-02T12:36:08-04:00 + + https://wtfutil.com/posts/modules/twitter/ 2018-07-31T20:21:37-07:00 diff --git a/docs/tags/index.html b/docs/tags/index.html index 7f8b989c..950a001a 100644 --- a/docs/tags/index.html +++ b/docs/tags/index.html @@ -8,7 +8,7 @@ - + Tags | WTF - A Terminal Dashboard @@ -89,6 +89,7 @@ height="0" width="0" style="display:none;visibility:hidden"> + diff --git a/gitter/client.go b/gitter/client.go new file mode 100644 index 00000000..6ead88e1 --- /dev/null +++ b/gitter/client.go @@ -0,0 +1,95 @@ +package gitter + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/senorprogrammer/wtf/logger" + "github.com/senorprogrammer/wtf/wtf" + "io" + "io/ioutil" + "net/http" + "os" + "strconv" +) + +func GetMessages(roomId string, numberOfMessages int) ([]Message, error) { + var messages []Message + + resp, err := apiRequest("rooms/" + roomId + "/chatMessages?limit=" + strconv.Itoa(numberOfMessages)) + if err != nil { + return nil, err + } + + parseJson(&messages, resp.Body) + + return messages, nil +} + +func GetRoom(roomUri string) (*Room, error) { + var rooms Rooms + + resp, err := apiRequest("rooms?q=" + roomUri) + if err != nil { + return nil, err + } + + parseJson(&rooms, resp.Body) + + for _, room := range rooms.Results { + logger.Log(fmt.Sprintf("room: %s", room)) + if room.URI == roomUri { + return &room, nil + } + } + + return nil, nil +} + +/* -------------------- Unexported Functions -------------------- */ + +var ( + apiBaseURL = "https://api.gitter.im/v1/" +) + +func apiRequest(path string) (*http.Response, error) { + req, err := http.NewRequest("GET", apiBaseURL+path, nil) + bearer := fmt.Sprintf("Bearer %s", apiToken()) + req.Header.Add("Authorization", bearer) + + 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 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) + } + } +} + +func apiToken() string { + return wtf.Config.UString( + "wtf.mods.gitter.apiToken", + os.Getenv("WTF_GITTER_API_TOKEN"), + ) +} diff --git a/gitter/gitter.go b/gitter/gitter.go new file mode 100644 index 00000000..fea5bd01 --- /dev/null +++ b/gitter/gitter.go @@ -0,0 +1,28 @@ +package gitter + +import "time" + +type Rooms struct { + Results []Room `json:"results"` +} + +type Room struct { + ID string `json:"id"` + Name string `json:"name"` + URI string `json:"uri"` +} + +type User struct { + ID string `json:"id"` + Username string `json:"username"` + DisplayName string `json:"displayName"` +} + +type Message struct { + ID string `json:"id"` + Text string `json:"text"` + HTML string `json:"html"` + Sent time.Time `json:"sent"` + From User `json:"fromUser"` + Unread bool `json:"unread"` +} diff --git a/gitter/widget.go b/gitter/widget.go new file mode 100644 index 00000000..b1270198 --- /dev/null +++ b/gitter/widget.go @@ -0,0 +1,182 @@ +package gitter + +import ( + "fmt" + "github.com/gdamore/tcell" + "github.com/rivo/tview" + "github.com/senorprogrammer/wtf/wtf" + "strconv" +) + +const HelpText = ` + Keyboard commands for Gitter: + + /: Show/hide this help window + j: Select the next message in the list + k: Select the previous message in the list + r: Refresh the data + + arrow down: Select the next message in the list + arrow up: Select the previous message in the list +` + +type Widget struct { + wtf.HelpfulWidget + wtf.TextWidget + + messages []Message + selected int +} + +func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { + widget := Widget{ + HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText), + TextWidget: wtf.NewTextWidget("Gitter", "gitter", true), + } + + widget.HelpfulWidget.SetView(widget.View) + widget.unselect() + + widget.View.SetScrollable(true) + widget.View.SetRegions(true) + widget.View.SetInputCapture(widget.keyboardIntercept) + + return &widget +} + +/* -------------------- Exported Functions -------------------- */ + +func (widget *Widget) Refresh() { + if widget.Disabled() { + return + } + + room, err := GetRoom(wtf.Config.UString("wtf.mods.gitter.roomUri", "wtfutil/Lobby")) + if err != nil { + widget.View.SetWrap(true) + widget.View.SetTitle(widget.Name) + widget.View.SetText(err.Error()) + return + } + + if room == nil { + return + } + + messages, err := GetMessages(room.ID, wtf.Config.UInt("wtf.mods.gitter.numberOfMessages", 10)) + widget.UpdateRefreshedAt() + + if err != nil { + widget.View.SetWrap(true) + widget.View.SetTitle(widget.Name) + widget.View.SetText(err.Error()) + } else { + widget.messages = messages + } + + widget.display() + widget.View.ScrollToEnd() +} + +/* -------------------- Unexported Functions -------------------- */ + +func (widget *Widget) display() { + if widget.messages == nil { + return + } + + widget.View.SetWrap(true) + widget.View.Clear() + widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name, wtf.Config.UString("wtf.mods.gitter.roomUri", "wtfutil/Lobby")))) + widget.View.SetText(widget.contentFrom(widget.messages)) + widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight() +} + +func (widget *Widget) contentFrom(messages []Message) string { + var str string + for idx, message := range messages { + str = str + fmt.Sprintf( + `["%d"][""][%s] [blue]%s [lightslategray]%s: [%s]%s [aqua]%s`, + idx, + widget.rowColor(idx), + message.From.DisplayName, + message.From.Username, + widget.rowColor(idx), + message.Text, + message.Sent.Format("Jan 02, 15:04 MST"), + ) + + str = str + "\n" + } + + return str +} + +func (widget *Widget) rowColor(idx int) string { + if widget.View.HasFocus() && (idx == widget.selected) { + return wtf.DefaultFocussedRowColor() + } + + return wtf.RowColor("gitter", idx) +} + +func (widget *Widget) next() { + widget.selected++ + if widget.messages != nil && widget.selected >= len(widget.messages) { + widget.selected = 0 + } + + widget.display() +} + +func (widget *Widget) prev() { + widget.selected-- + if widget.selected < 0 && widget.messages != nil { + widget.selected = len(widget.messages) - 1 + } + + widget.display() +} + +func (widget *Widget) openMessage() { + sel := widget.selected + if sel >= 0 && widget.messages != nil && sel < len(widget.messages) { + message := &widget.messages[widget.selected] + wtf.OpenFile(message.Text) + } +} + +func (widget *Widget) unselect() { + widget.selected = -1 + widget.display() +} + +func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { + switch string(event.Rune()) { + case "/": + widget.ShowHelp() + case "j": + widget.next() + return nil + case "k": + widget.prev() + return nil + case "r": + widget.Refresh() + return nil + } + + switch event.Key() { + case tcell.KeyDown: + widget.next() + return nil + case tcell.KeyEsc: + widget.unselect() + return event + case tcell.KeyUp: + widget.prev() + return nil + default: + return event + } +} diff --git a/main.go b/main.go index 5370557d..1da83728 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ import ( "github.com/senorprogrammer/wtf/git" "github.com/senorprogrammer/wtf/github" "github.com/senorprogrammer/wtf/gitlab" + "github.com/senorprogrammer/wtf/gitter" "github.com/senorprogrammer/wtf/gspreadsheets" "github.com/senorprogrammer/wtf/hackernews" "github.com/senorprogrammer/wtf/ipaddresses/ipapi" @@ -203,6 +204,8 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) { widgets = append(widgets, github.NewWidget(app, pages)) case "gitlab": widgets = append(widgets, gitlab.NewWidget(app, pages)) + case "gitter": + widgets = append(widgets, gitter.NewWidget(app, pages)) case "gspreadsheets": widgets = append(widgets, gspreadsheets.NewWidget()) case "hackernews":