mirror of
https://github.com/HackPlan/github-commit-ical.git
synced 2026-01-12 15:04:45 +08:00
first version
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/.idea
|
||||
/node_modules
|
||||
31
app.coffee
Normal file
31
app.coffee
Normal 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
23
package.json
Normal 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": "*"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user