first version of working feed

This commit is contained in:
Riku Rouvila
2015-02-02 23:20:40 +02:00
parent ab8648920a
commit ae7b9541a5
3 changed files with 44 additions and 34 deletions

View File

@@ -1,19 +1,35 @@
'use strict';
var _ = require('lodash');
var githubEvent = require('parse-github-event');
var twitterText = require('twitter-text');
module.exports = {
github(item) {
var message = githubEvent.parse(item);
console.log(item);
console.log(message.data);
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
var template = _.template(githubEvent.parse(item).text);
var repository = `https://github.com/${item.repo.name}`;
var branch;
if(item.payload.ref) {
branch = item.payload.ref.replace('refs/heads/', '');
}
var message = template({
repository: `<a target="_blank" href="${repository}">${item.repo.name}</a>`,
branch: branch,
number: item.payload.number,
ref_type: item.payload.ref
});
return {
image: item.actor.avatar_url,
body: `${item.actor.login} ${message.text}`,
timestamp: item.created_at,
body: `${item.actor.login} ${message}`,
timestamp: new Date(item.created_at),
url: message.url,
highlights: message.data,
type: 'github'
};
},
@@ -21,7 +37,7 @@ module.exports = {
return {
image: item.user.profile_image_url,
body: twitterText.autoLink(item.text),
timestamp: item.created_at,
timestamp: new Date(item.created_at),
type: 'twitter'
};
}