mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-02-20 09:55:00 +00:00
first version of working feed
This commit is contained in:
@@ -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'
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user