Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into gitlog
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Apr 21, 2017
2 parents f38f9fd + 1d769c9 commit d349d8d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 57 deletions.
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Follow the template below to ensure a more accurate response to your issue.

**Node Version**: `node --version`
**tiny-core-terminal version**: `npm info tiny-care-terminal | grep version:`
**Shell**: `bash, zsh, fish, something else?`
**Terminal Program**: `tmux, iterm, terminator, cmd, something else?`
**Operating System**: `Mac, Windows, Linux, BSD, Really, something else?`

Thank you!
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ lists the environment variables that you can copy in your `rc` files:
in this list will be displayed in the party parrot.
- `TTC_REPOS`, a comma separated list of repos to look at for `git` commits.
- `TTC_REPOS_DEPTH` is the max directory-depth to look for git repositories in the directories defined with `TTC_REPOS` (by default 1)
- `TTC_WEATHER`, the location or zip code to check the weather for (so both
`90210` and `Paris` should work)
- `TTC_WEATHER`, the location to check the weather for. A zipcode doesn't
always work, so if you can, use a location first (so prefer `Paris` over
`90210`)
- `TTC_CELSIUS` (by default true)
- `TTC_APIKEYS` -- set this to false if you don't want to use Twitter API
keys and want to scrape the tweets instead.
Expand All @@ -37,9 +38,11 @@ lists the environment variables that you can copy in your `rc` files:
### Setting the environment variables

Every OS and shell is different so I probably won't hit all of them, but the bottom line is that
you should copy those environment variables wherever the rest of your system's variables live:
you should copy those environment variables wherever the rest of your system's variables live.
For example,
- if you're using `zsh`, that's probably in your home directory's `.zshrc` file
- if you're using `bash`, that could be your `bash_profile` file
- if you're using `fish`, use `set -gx key value` in your `~/.config/fish/config.fish` file

Note that the `export` bit is pretty key, to make sure that they are globally available. To check that the
variables have been set correctly, you can print them in the terminal -- for example, `echo $TTC_WEATHER`.
Expand All @@ -57,10 +60,10 @@ After you've set them up, set these env variables (see the `sample.env` for an
example):

```
CONSUMER_KEY='...'
CONSUMER_SECRET='...'
ACCESS_TOKEN='...'
ACCESS_TOKEN_SECRET='...'
TTC_CONSUMER_KEY='...'
TTC_CONSUMER_SECRET='...'
TTC_ACCESS_TOKEN='...'
TTC_ACCESS_TOKEN_SECRET='...'
```

### Do the npm dance
Expand All @@ -75,4 +78,12 @@ tiny-care-terminal
You can exit the dashboard by pressing `esc` or `q`. You can refresh it
manually by pressing `r`.

## 🆘 Halp I don't see my commits

There's a couple of reasons why this might happen:
- did you run `npm install -g git-standup` after installing `tiny-care-terminal`? If you didn't, that's the most likely culprit
- did you forget to export your `TTC_REPOS` environment variable? Open a new tab, and type `echo $TTC_REPOS` to make sure it's not empty. Note that spaces inside the repo names are not supported right now :(
- are you on Windows? Not super sure it works on Windows because of the `bash` scripts, but working on it
- did you use `yarn`? I know `yarn` is cool, and I've seen it work with this, but can you double check that it still doesn't work with a basic `npm` installation instead?

## Take care of yourself, ok? 💖
18 changes: 10 additions & 8 deletions care.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env node
#!/usr/bin/env node
var config = require(__dirname + '/config.js');
var twitterbot = require(__dirname + '/twitterbot.js');

Expand Down Expand Up @@ -38,7 +38,7 @@ var weatherBox = grid.set(0, 8, 2, 4, blessed.box, makeScrollBox(' 🌤 '));
var todayBox = grid.set(0, 0, 6, 6, blessed.box, makeScrollBox(' 📝 Today '));
var weekBox = grid.set(6, 0, 6, 6, blessed.box, makeScrollBox(' 📝 Week '));
var commits = grid.set(0, 6, 6, 2, contrib.bar, {label: 'Commits', barWidth: 5, xOffset: 4, maxHeight: 10});
var parrotBox = grid.set(6, 6, 6, 6, blessed.box, makeBox(''));
var parrotBox = grid.set(6, 6, 6, 6, blessed.box, makeScrollBox(''));

var tweetBoxes = {}
tweetBoxes[config.twitter[1]] = grid.set(2, 8, 2, 4, blessed.box, makeBox(' 💖 '));
Expand All @@ -60,14 +60,16 @@ function doTheWeather() {
// TODO: add emoji for this thing.
var skytext = json.current.skytext.toLowerCase();
var currentDay = json.current.day;
var degreetype = json.location.degreetype;
var forecastString = '';
for (var i = 0; i < json.forecast.length; i++) {
if (json.forecast[i].day === currentDay) {
var skytextforecast = json.forecast[i].skytextday.toLowerCase();
forecastString = `Today, it will be ${skytextforecast} with the forecasted high of ${json.forecast[i].high} and a low of ${json.forecast[i].low}.`;
var forecast = json.forecast[i];
if (forecast.day === currentDay) {
var skytextforecast = forecast.skytextday.toLowerCase();
forecastString = `Today, it will be ${skytextforecast} with the forecasted high of ${forecast.high}°${degreetype} and a low of ${forecast.low}°${degreetype}.`;
}
}
weatherBox.content = `In ${json.location.name} it's ${json.current.temperature}${json.location.degreetype} and ${skytext} right now. ${forecastString}`;
weatherBox.content = `In ${json.location.name} it's ${json.current.temperature}°${degreetype} and ${skytext} right now. ${forecastString}`;
} else {
weatherBox.content = 'Having trouble fetching the weather for you :(';
}
Expand Down Expand Up @@ -174,7 +176,7 @@ function getGitCommits(repos, days, callback) {
}, (err, logs) => {
if (err) callback(err, null);
logs.forEach(c => {
cmts.push(`${c.abbrevHash} - ${c.subject} (${c.authorDateRel}) <${c.authorName}>`);
cmts.push(`${c.abbrevHash} - ${c.subject} (${c.authorDateRel}) <${c.authorName.replace('@end@\n','')}>`);
});
repoDone();
});
Expand Down Expand Up @@ -235,7 +237,7 @@ function colorizeLog(text) {
} else {
// It's a commit.
var matches = lines[i].match(regex);
if (matches ) {
if (matches) {
lines[i] = chalk.red(matches[1]) + ' ' + matches[2] + ' ' +
chalk.green(matches[3])
}
Expand Down
65 changes: 31 additions & 34 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
var config = {};
// Accounts to read the last tweet from. The first one in the list will be
// spoken by the party parrot.
config.twitter = process.env.TTC_BOTS || 'tinycarebot,selfcare_bot,magicrealismbot';
config.twitter = config.twitter.split(',')

// Set this to false if you want to scrape twitter.com instead of using
// API keys. The tweets may include RTs in this case :(
config.apiKeys = process.env.TTC_APIKEYS || 'true';
config.apiKeys = config.apiKeys === 'true' ? true : false;

// Directories in which to run git-standup on for a list of your recent commits.
config.repos = process.env.TTC_REPOS || '~/Code';
config.repos = config.repos.split(',');

// The directory-depth on how to look for git-repos. Use with care!
config.reposDepth = process.env.TTC_REPOS_DEPTH || 1;

// Where to check the weather for. This can be a zip code or a location name
// So both 90210 and "San Francisco, CA" should be ok.
// It's using weather.service.msn.com behind the curtains.
config.weather = process.env.TTC_WEATHER || 'San Francisco';

// Set to false if you're an imperial savage. <3
config.celsius = process.env.TTC_CELSIUS || 'true';
config.celsius = config.celsius === 'true' ? true : false;

config.updateInterval = parseFloat(process.env.TTC_UPDATE_INTERVAL) || 20;

config.keys = {};
config.keys.consumer_key = process.env.CONSUMER_KEY || 'none';
config.keys.consumer_secret = process.env.CONSUMER_SECRET || 'none';
config.keys.access_token = process.env.ACCESS_TOKEN || 'none';
config.keys.access_token_secret = process.env.ACCESS_TOKEN_SECRET || 'none';
var config = {
// Accounts to read the last tweet from. The first one in the list will be
// spoken by the party parrot.
twitter: (process.env.TTC_BOTS || 'tinycarebot,selfcare_bot,magicrealismbot').split(','),

// Set this to false if you want to scrape twitter.com instead of using
// API keys. The tweets may include RTs in this case :(
apiKeys: (process.env.TTC_APIKEYS || 'true') === 'true',

// Directories in which to run git-standup on for a list of your recent commits.
repos: (process.env.TTC_REPOS || '~/Code').split(','),

// The directory-depth on how to look for git-repos. Use with care!
reposDepth: process.env.TTC_REPOS_DEPTH || 1,

// Where to check the weather for.
// It's using weather.service.msn.com behind the curtains.
weather: process.env.TTC_WEATHER || 'San Francisco',

// Set to false if you're an imperial savage. <3
celsius: (process.env.TTC_CELSIUS || 'true') === 'true',

updateInterval: parseFloat(process.env.TTC_UPDATE_INTERVAL) || 20,

keys: {
consumer_key: process.env.TTC_CONSUMER_KEY || process.env.CONSUMER_KEY || 'none',
consumer_secret: process.env.TTC_CONSUMER_SECRET || process.env.CONSUMER_SECRET || 'none',
access_token: process.env.TTC_ACCESS_TOKEN || process.env.ACCESS_TOKEN || 'none',
access_token_secret: process.env.TTC_ACCESS_TOKEN_SECRET || process.env.ACCESS_TOKEN_SECRET || 'none',
}
};

module.exports = config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiny-care-terminal",
"version": "1.0.7",
"version": "1.0.8",
"description": "A terminal that tries to take care of you 💖",
"main": "care.js",
"author": "Monica Dinculescu <[email protected]>",
Expand Down
12 changes: 11 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export TTC_REPOS='~/Work/Code,~/Fun/Code'
export TTC_REPOS_DEPTH=2

# Location/zip code to check the weather for. Both 90210 and "San Francisco, CA"
# should be ok. It's using weather.service.msn.com behind the curtains.
# _should_ be ok (the zip code doesn't always work -- use a location
# first, if you can). It's using weather.service.msn.com behind the curtains.
export TTC_WEATHER='Paris'

# Set to false if you're an imperial savage. <3
Expand All @@ -23,6 +24,15 @@ export TTC_APIKEYS=true
export TTC_UPDATE_INTERVAL=20

# Twitter api keys
export TTC_CONSUMER_KEY='...'
export TTC_CONSUMER_SECRET='...'
export TTC_ACCESS_TOKEN='...'
export TTC_ACCESS_TOKEN_SECRET='...'

# Note: in tiny-terminal-care < 1.0.7, the recommended variables for the Twitter
# API keys were the ones before. As of 1.0.8, they are deprecated
# (because the names are too generic), but will still be supported
# until the next major version.
export CONSUMER_KEY='...'
export CONSUMER_SECRET='...'
export ACCESS_TOKEN='...'
Expand Down
12 changes: 6 additions & 6 deletions twitterbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ var config = require(__dirname + '/config.js');
var scraperjs = require('scraperjs');

var T = new Twit({
consumer_key:config.keys.consumer_key,
consumer_secret:config.keys.consumer_secret,
access_token:config.keys.access_token,
access_token_secret:config.keys.access_token_secret,
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
consumer_key: config.keys.consumer_key,
consumer_secret: config.keys.consumer_secret,
access_token: config.keys.access_token,
access_token_secret: config.keys.access_token_secret,
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
});

var options = {exclude_replies:true, include_rts:false, count: 1 };
Expand Down Expand Up @@ -42,7 +42,7 @@ function scrapeTweet(who) {
var tweetNumber = Math.floor(Math.random() * tweets.length);
resolve({text:tweets[tweetNumber], bot: who});
},function(error) {
reject('Can\t scrape tweets. Maybe the user is private or doesn\'t exist?');
reject('Can\'t scrape tweets. Maybe the user is private or doesn\'t exist?');
});
});
}
Expand Down

0 comments on commit d349d8d

Please sign in to comment.