https://github.com/bumi/travels
my travel log as git commits
https://github.com/bumi/travels
Last synced: 4 months ago
JSON representation
my travel log as git commits
- Host: GitHub
- URL: https://github.com/bumi/travels
- Owner: bumi
- Created: 2016-02-21T19:38:43.000Z (over 10 years ago)
- Default Branch: gh-pages
- Last Pushed: 2017-11-20T16:44:08.000Z (over 8 years ago)
- Last Synced: 2025-03-21T22:03:12.635Z (about 1 year ago)
- Language: HTML
- Homepage: http://michaelbumann.com/post/139921224122/travel-location-tracker-using-gitgithub-as-a-time
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.mdown
Awesome Lists containing this project
README
# [where.is.michaelbumann.com](http://where.is.michaelbumann.com)
my location log stored in [git commits](https://github.com/bumi/travels/commits/locations) (in the locations branch). Have a look at [where.is.michaelbumann.com](http://where.is.michaelbumann.com) for a nice map and list of recent places.
Got a recommendation for a place I should visit? Please create an [issue](https://github.com/bumi/travels/issues/new).
## Development
### All in one:
adds location entries to an `ul.location-list`, fills `.current-location` and `.next-locaton`
```javascript
$.get('https://api.github.com/repos/bumi/travels/commits?sha=locations', function(commits) {
var max = commits.length;// > 11 ? 11 : commits.length;
var future = [];
var past = [];
commits = commits.sort(function(c1, c2) {
var d1 = new Date(c1.commit.author.date);
var d2 = new Date(c2.commit.author.date);
if(d1 < d2) { return 1; }
if(d1 > d2) { return -1; }
return 0;
});
for(var i=0; i < max; i++) {
try {
var c = commits[i].commit;
var commitMessage = c.message.split("\n");
var data = JSON.parse(commitMessage[commitMessage.length-1]);
var arrival = new Date(c.author.date);
var area = data.city || data.state || 'somewhere';
var message = area + ', ' + data.country;
if(arrival > new Date()) {
$('.next-location').html('Planned: ' + message + ' (' + arrival.toDateString() + ')'); // assumin the last commit in the future is the next stop. which is wrong, needs to get smarter and calculate the nearest in the future
$('.location-list').append('
future.push(c);
} else {
if(past.length === 0) {
$('.current-location').html(message); // assuming the first in the past is the current location
}
$('.location-list').append('
past.push(c);
}
$('.location').show();
} catch(e) {
// ignore
}
};
});
```
### Get latest location:
```javascript
$.get('https://api.github.com/repos/bumi/travels/commits?sha=locations', function(commits) {
for(var i=0; i < commits.length; i++) {
try {
var c = commits[i].commit;
var commitMessage = c.message.split("\n");
var data = JSON.parse(commitMessage[commitMessage.length-1]);
var area = data.city || data.state || 'somewhere';
$('.current-location').html(area + ' in ' + data.country);
$('.location').show();
return true;
} catch(e) {
}
};
});
```
### Get list of locations:
```javascript
$.get('https://api.github.com/repos/bumi/travels/commits?sha=locations', function(commits) {
commits.forEach(function(commit) {
try {
var c = commit.commit;
var commitMessage = c.message.split("\n");
var data = JSON.parse(commitMessage[commitMessage.length-1]);
var area = data.city || data.state || 'somewhere';
$('.location-list').append('
$('.location').show();
return true;
} catch(e) {
}
});
});
```