mirror of
https://github.com/resume/resume.github.com.git
synced 2024-10-05 16:07:24 +03:00
Add contributions repos
This commit is contained in:
parent
4bfb1800e9
commit
b7794c4582
@ -285,6 +285,10 @@ noscript {
|
||||
|
||||
#doc2 { padding-bottom: 70px }
|
||||
|
||||
.contributions {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 59.9em) {
|
||||
#inner {
|
||||
padding: 5 5 5 5;
|
||||
|
@ -75,6 +75,25 @@ var github_user_repos = function(username, callback, page_number, prev_data) {
|
||||
});
|
||||
}
|
||||
|
||||
var github_user_issues = function(username, callback, page_number, prev_data) {
|
||||
var page = (page_number ? page_number : 1),
|
||||
url = 'https://api.github.com/search/issues?q=type:pr+is:merged+author:' + username + '&per_page=500&callback=?'
|
||||
data = (prev_data ? prev_data : []);
|
||||
|
||||
if (page_number > 1) {
|
||||
url += '&page=' + page_number;
|
||||
}
|
||||
|
||||
$.getJSON(url, function(repos) {
|
||||
data = data.concat(repos.data.items);
|
||||
if (repos.data.total_count == 500) {
|
||||
github_user_issues(username, callback, page + 1, data);
|
||||
} else {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var github_user_orgs = function(username, callback) {
|
||||
$.getJSON('https://api.github.com/users/' + username + '/orgs?callback=?', callback);
|
||||
}
|
||||
@ -432,6 +451,59 @@ var run = function() {
|
||||
});
|
||||
});
|
||||
|
||||
github_user_issues(username, function(data) {
|
||||
var sorted = [],
|
||||
repos = {};
|
||||
|
||||
$.each(data, function(i, issue) {
|
||||
if(repos[issue.repository_url] === undefined) {
|
||||
repos[issue.repository_url] = { popularity: 1 }
|
||||
} else {
|
||||
repos[issue.repository_url].popularity += 1;
|
||||
}
|
||||
});
|
||||
|
||||
$.each(repos, function(repo, obj) {
|
||||
sorted.push({ repo: repo, popularity: obj.popularity});
|
||||
})
|
||||
|
||||
function sortByPopularity(a, b) {
|
||||
return b.popularity - a.popularity;
|
||||
};
|
||||
|
||||
sorted.sort(sortByPopularity);
|
||||
|
||||
$.ajax({
|
||||
url: 'views/contrib.html',
|
||||
dataType: 'html',
|
||||
success: function(response) {
|
||||
if (sorted.length > 0) {
|
||||
$('#contrib-jobs').html('');
|
||||
var view, template, html, repoUrl, repoName, commitsUrl;
|
||||
$.each(sorted, function(index, repo) {
|
||||
repoUrl = repo.repo.replace(/https:\/\/api\.github\.com\/repos/, 'https://github.com');
|
||||
repoName = repo.repo.replace(/https:\/\/api\.github\.com\/repos\//, '');
|
||||
commitsUrl = repoUrl + '/commits?author=' + username;
|
||||
view = {
|
||||
count: repo.popularity,
|
||||
username: username,
|
||||
repoUrl: repoUrl,
|
||||
repoName: repoName,
|
||||
commitsUrl: commitsUrl
|
||||
};
|
||||
|
||||
template = response;
|
||||
html = Mustache.to_html(template, view);
|
||||
|
||||
$('#contrib-jobs').append($(html));
|
||||
});
|
||||
} else {
|
||||
$('#contributions').remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
github_user_orgs(username, function(response) {
|
||||
var sorted = [];
|
||||
|
||||
|
6
views/contrib.html
Normal file
6
views/contrib.html
Normal file
@ -0,0 +1,6 @@
|
||||
<div class="contributions">
|
||||
<h2>
|
||||
<a href="{{repoUrl}}">{{repoName}}</a>
|
||||
</h2>
|
||||
<p>{{username}} has contributed for <a href="{{repoUrl}}">{{repoName}}</a> with <a href="{{commitsUrl}}">{{count}} commit(s)</a></p>
|
||||
</div>
|
@ -58,7 +58,6 @@
|
||||
<h2>Languages</h2>
|
||||
</div>
|
||||
<div class="yui-u" id="content-languages">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="repositories" class="yui-gf">
|
||||
@ -71,6 +70,16 @@
|
||||
</div><!--// .yui-u -->
|
||||
</div><!--// .yui-gf -->
|
||||
|
||||
<div id="contributions" class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<h2>Contributions</h2>
|
||||
</div><!--// .yui-u -->
|
||||
|
||||
<div class="yui-u" id="contrib-jobs">
|
||||
<span>Loading information...</span><img src="images/loader.gif" />
|
||||
</div><!--// .yui-u -->
|
||||
</div><!--// .yui-gf -->
|
||||
|
||||
<div class="yui-gf" id="organizations">
|
||||
<div class="yui-u first">
|
||||
<h2>Organizations</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user