first version

This commit is contained in:
jysperm
2014-07-27 09:22:55 +08:00
parent 0a2342d6a9
commit 9f714428b5
4 changed files with 57 additions and 2 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/.idea
/node_modules

View File

@@ -1,2 +1 @@
github-commit-ical
==================
## github-commit-ical

31
app.coffee Normal file
View File

@@ -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

23
package.json Normal file
View File

@@ -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": "*"
}
}