diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6684c76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea +/node_modules diff --git a/README.md b/README.md index 36a2129..86db5ed 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -github-commit-ical -================== +## github-commit-ical diff --git a/app.coffee b/app.coffee new file mode 100644 index 0000000..7e1825d --- /dev/null +++ b/app.coffee @@ -0,0 +1,31 @@ +express = require 'express' +request = require 'request' +ical = require 'ical-generator' + +app = express() + +app.get '/:username', (req, res) -> + username = req.param 'username' + + request "https://api.github.com/users/#{username}/events", + headers: + 'User-Agent': 'github-commit-ical' + , (err, _res, body) -> + body = JSON.parse body + + cal = ical() + cal.setDomain('github-commit-ical').setName("#{username} Commit History"); + + for item in body + if item.type == 'PushEvent' + for commit in item.payload.commits + cal.addEvent + start: new Date item.created_at + end: new Date item.created_at + summary: "#{commit.message} (#{item.repo.name})" + url: commit.url + + res.header 'Content-Type', 'text/calendar; charset=utf-8' + res.status(200).end(cal.toString()) + +app.listen 3000 diff --git a/package.json b/package.json new file mode 100644 index 0000000..9b58aff --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "github-commit-ical", + "version": "0.1.0", + "description": "", + "homepage": "http://commit-calendar.newsbee.io/", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/hackplan/github-commit-ical.git" + }, + "contributors": [ + { + "name": "jysperm", + "email": "jysperm@gmail.com", + "url": "http://jysperm.me" + } + ], + "dependencies": { + "express": "*", + "request": "*", + "ical-generator": "*" + } +} \ No newline at end of file