Skip to content

Commit

Permalink
add list of fto authors. (publiclab#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh570 authored Jul 4, 2019
1 parent 15b983d commit b5b0225
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 23 deletions.
39 changes: 27 additions & 12 deletions dist/community-toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -81643,6 +81643,19 @@ module.exports = {
insertContributors: insertContributors,
};
},{}],400:[function(require,module,exports){
function insertFtoIssueAuthor(issueSet) {
let avatars=[];
for(let [key, value] of Object.entries(issueSet)) {
avatars.push(`<a href="https://github.com/${value.user.login}" title="${value.user.login}"><img width="100px" src="${value.user.avatar_url}"></a>`);
}
$('.fto-authors').append(avatars.join(' '));
}


module.exports = {
insertFtoIssueAuthor: insertFtoIssueAuthor
}
},{}],401:[function(require,module,exports){
var moment = require('moment');


Expand Down Expand Up @@ -81680,7 +81693,7 @@ module.exports = {
generateIssueHtml: generateIssueHtml,
insertIssue: insertIssue,
};
},{"moment":271}],401:[function(require,module,exports){
},{"moment":271}],402:[function(require,module,exports){
var insertRecentContributorsExec = false;


Expand All @@ -81705,7 +81718,7 @@ function insertRecentContributors(AllContributors){
module.exports = {
insertRecentContributors: insertRecentContributors,
};
},{}],402:[function(require,module,exports){
},{}],403:[function(require,module,exports){
let db;
let init = require('../models/initialize')

Expand Down Expand Up @@ -81810,7 +81823,7 @@ module.exports.getContentFromDb = getContentFromDb;
module.exports.deleteItemFromDb = deleteItemFromDb;
module.exports.populateDb = populateDb;

},{"../models/initialize":403}],403:[function(require,module,exports){
},{"../models/initialize":404}],404:[function(require,module,exports){
// This function is responsible for setting up the database
function dbInit() {
let db;
Expand Down Expand Up @@ -81873,7 +81886,7 @@ module.exports = {
}


},{}],404:[function(require,module,exports){
},{}],405:[function(require,module,exports){
var model = require('./crud');


Expand Down Expand Up @@ -81902,7 +81915,7 @@ module.exports.setItem = setItem;
module.exports.getItem = getItem;
module.exports.deleteItem = deleteItem;

},{"./crud":402}],405:[function(require,module,exports){
},{"./crud":403}],406:[function(require,module,exports){
// view-source:http://www.chartjs.org/samples/latest/charts/bar/vertical.html
function generateChart(args) {

Expand Down Expand Up @@ -81955,7 +81968,7 @@ function generateChart(args) {

module.exports = generateChart;

},{}],406:[function(require,module,exports){
},{}],407:[function(require,module,exports){

CommunityToolbox = function CommunityToolbox(org, repo) {

Expand All @@ -81972,6 +81985,7 @@ CommunityToolbox = function CommunityToolbox(org, repo) {
var recentContributorsUI = require('../UI/recentContributorsUI')
var recentContribsUtil = require('../utils/recentContribsUtil')
var autoCompleteUtil = require('../utils/autocomplete')
var ftoAuthorsUI = require('../UI/ftoAuthorsUI')

const requestP = require('request-promise')
var parse = require('parse-link-header')
Expand Down Expand Up @@ -82184,14 +82198,15 @@ CommunityToolbox = function CommunityToolbox(org, repo) {
showRepoContributors: showRepoContributors,
displayIssuesForRepo: displayIssuesForRepo,
initialize: initialize,
dropdownInit: dropdownInit
dropdownInit: dropdownInit,
ftoAuthorsUI: ftoAuthorsUI
}

}

module.exports = CommunityToolbox;

},{"../UI/contributorsUI":399,"../UI/issuesUI":400,"../UI/recentContributorsUI":401,"../models/crud":402,"../models/utils":404,"../utils/autocomplete":407,"../utils/contributorsUtil":408,"../utils/fetchRepoUtil":409,"../utils/recentContribsUtil":410,"./chart":405,"github-api-simple":151,"parse-link-header":278,"request-promise":323}],407:[function(require,module,exports){
},{"../UI/contributorsUI":399,"../UI/ftoAuthorsUI":400,"../UI/issuesUI":401,"../UI/recentContributorsUI":402,"../models/crud":403,"../models/utils":405,"../utils/autocomplete":408,"../utils/contributorsUtil":409,"../utils/fetchRepoUtil":410,"../utils/recentContribsUtil":411,"./chart":406,"github-api-simple":151,"parse-link-header":278,"request-promise":323}],408:[function(require,module,exports){
function generateAutocomplete(repos) {
let repoAlreadySelected = urlHash().getUrlHashParameter('r');

Expand Down Expand Up @@ -82226,7 +82241,7 @@ function generateAutocomplete(repos) {

module.exports.generateAutocomplete = generateAutocomplete;

},{}],408:[function(require,module,exports){
},{}],409:[function(require,module,exports){

var SimpleApi = require("github-api-simple")
var api = new SimpleApi()
Expand Down Expand Up @@ -82413,7 +82428,7 @@ module.exports = {
}


},{"../models/utils":404,"../utils/recentContribsUtil":410,"./fetchRepoUtil":409,"github-api-simple":151,"parse-link-header":278}],409:[function(require,module,exports){
},{"../models/utils":405,"../utils/recentContribsUtil":411,"./fetchRepoUtil":410,"github-api-simple":151,"parse-link-header":278}],410:[function(require,module,exports){
let model_utils = require('../models/utils')

// Fetches all the publiclab's repositories
Expand Down Expand Up @@ -82445,7 +82460,7 @@ function getAllRepos(org) {
// EXPORTS
module.exports.getAllRepos = getAllRepos;

},{"../models/utils":404}],410:[function(require,module,exports){
},{"../models/utils":405}],411:[function(require,module,exports){
var fetchRepoUtil = require('./fetchRepoUtil');
var model_utils = require('../models/utils');

Expand Down Expand Up @@ -82646,4 +82661,4 @@ module.exports = {
within_this_week: within_this_week
}

},{"../models/utils":404,"./fetchRepoUtil":409}]},{},[406]);
},{"../models/utils":405,"./fetchRepoUtil":410}]},{},[407]);
10 changes: 10 additions & 0 deletions examples/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ h1, h2, .section h3 {
background-color: rgba(221, 221, 255, 0.226);
}

.fto-authors {
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
}


@media only screen and (max-width: 569px) {
.links {
width: 25%;
Expand Down
34 changes: 24 additions & 10 deletions examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ document.addEventListener('DOMContentLoaded', function () {
if (repo === 'all') {

toolbox.getIssuesForOrg(org, { qs: { labels: ftoLabel } })
.then(displayIssues('.first-timers-only'));
.then(displayIssuesAndFtoAuthors('.first-timers-only'));

toolbox.getIssuesForOrg(org, { qs: { labels: candidateLabel } })
.then(displayIssues('.candidates'));
.then(displayIssuesAndFtoAuthors('.candidates'));

toolbox.initialize(org, repo).then((res)=> {
if(res) {
Expand All @@ -69,11 +69,11 @@ document.addEventListener('DOMContentLoaded', function () {

toolbox.api.Issues
.getIssuesForRepo(org, repo, { qs: { labels: ftoLabel } })
.then(displayIssues('.first-timers-only'));
.then(displayIssuesAndFtoAuthors('.first-timers-only'));

toolbox.api.Issues
.getIssuesForRepo(org, repo, { qs: { labels: candidateLabel } })
.then(displayIssues('.candidates'));
.then(displayIssuesAndFtoAuthors('.candidates'));

toolbox.initialize(org, repo).then((res)=> {
if(res) {
Expand All @@ -86,12 +86,26 @@ document.addEventListener('DOMContentLoaded', function () {
})
}

function displayIssues(selector) {
return function displayIssues(issues) {
if (typeof issues === "string") issues = JSON.parse(issues).items;
issues.forEach(function(issue) {
toolbox.issuesUI.insertIssue(issue, selector);
});
function displayIssuesAndFtoAuthors(selector) {
let ftoAuthorSet = new Set([]);
let ftoAuthArray=[];
return function displayIssuesAndFtoAuthors(issues) {
if (typeof issues === "string") issues = JSON.parse(issues).items;

issues.forEach(function(issue) {
toolbox.issuesUI.insertIssue(issue, selector);

issue.labels.forEach((ftoLabel) => {
if(ftoLabel.name==="first-timers-only" || ftoLabel.name==="fto") {
if(!ftoAuthorSet.has(issue.user.login)) {
ftoAuthorSet.add(issue.user.login);
ftoAuthArray.push(issue);
}

}
})
})
toolbox.ftoAuthorsUI.insertFtoIssueAuthor(ftoAuthArray);
}
}

Expand Down
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ <h2>You're now an expert on being a newcomer!</h2>

<hr />

<h2>FTO Authors</h2>

<p>These people took some time out of their busy schedule to help in welcoming newcomers by creating FTO issues: </p>

<div class="fto-authors"></div>


<h2 class="recent-contributors-head">Recent Contributors</h2>

Expand Down
12 changes: 12 additions & 0 deletions src/UI/ftoAuthorsUI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function insertFtoIssueAuthor(issueSet) {
let avatars=[];
for(let [key, value] of Object.entries(issueSet)) {
avatars.push(`<a href="https://github.com/${value.user.login}" title="${value.user.login}"><img width="100px" src="${value.user.avatar_url}"></a>`);
}
$('.fto-authors').append(avatars.join(' '));
}


module.exports = {
insertFtoIssueAuthor: insertFtoIssueAuthor
}
4 changes: 3 additions & 1 deletion src/scripts/community-toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CommunityToolbox = function CommunityToolbox(org, repo) {
var recentContributorsUI = require('../UI/recentContributorsUI')
var recentContribsUtil = require('../utils/recentContribsUtil')
var autoCompleteUtil = require('../utils/autocomplete')
var ftoAuthorsUI = require('../UI/ftoAuthorsUI')

const requestP = require('request-promise')
var parse = require('parse-link-header')
Expand Down Expand Up @@ -226,7 +227,8 @@ CommunityToolbox = function CommunityToolbox(org, repo) {
showRepoContributors: showRepoContributors,
displayIssuesForRepo: displayIssuesForRepo,
initialize: initialize,
dropdownInit: dropdownInit
dropdownInit: dropdownInit,
ftoAuthorsUI: ftoAuthorsUI
}

}
Expand Down

0 comments on commit b5b0225

Please sign in to comment.