remove github events from feed

This commit is contained in:
Riku Rouvila
2017-10-26 15:12:42 +01:00
parent 1d4e03b15f
commit 0b4bfa67d2
2 changed files with 0 additions and 39 deletions

View File

@@ -23,7 +23,6 @@
"font-awesome": "^4.4.0",
"http-server": "^0.9.0",
"lodash": "^3.9.1",
"parse-github-event": "^0.2.0",
"prop-types": "^15.5.10",
"react": "^0.14.3",
"react-dom": "^0.14.3",

View File

@@ -1,47 +1,9 @@
'use strict';
var _ = require('lodash');
var githubEvent = require('parse-github-event');
var twitterText = require('twitter-text');
const isVisibleGithubEvent = ({type}) => type !== 'PushEvent' && type !== 'DeleteEvent';
module.exports = {
github(items) {
return items.filter(isVisibleGithubEvent).map((item) => {
_.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_type,
ref: item.payload.ref
});
var url = `https://github.com/${item.actor.login}`;
return {
user: item.actor.login,
userLink: url,
image: item.actor.avatar_url,
imageLink: url,
body: message,
timestamp: new Date(item.created_at),
url: message.url,
type: 'github'
};
});
},
twitter(items) {
return items.map((item) => {
if(item.retweeted) {