Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Branch to pull commits from (default: master)
`limit`<br>
The maximum number of results to list (default: 10)

`author`<br>
GitHub login or email address by which to filter by commit author (optional)


Things to Note
-----------
Expand Down Expand Up @@ -74,4 +77,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
18 changes: 12 additions & 6 deletions dist/javascripts/bundle.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,40 @@ $.extend({
});

$(function() {
var branch, callback, container, limit, params, repo, url, username;
var author, branch, callback, container, limit, params, repo, title, url, username;
params = $.getUrlVars();
username = params.username;
repo = params.repo;
limit = params.limit;
branch = params.branch;
author = params.author;
container = $('#latest-commits-widget');
callback = function(response) {
var index, items, result, ul, _results;
var index, items, result, results, ul;
items = response.data;
ul = $('#commit-history');
ul.empty();
_results = [];
results = [];
for (index in items) {
result = items[index];
_results.push((function(index, result) {
results.push((function(index, result) {
if (result.author != null) {
return ul.append("<li class=\"clearfix\">\n <div class=\"left\">\n <img class=\"commit-avatar\" src=\"" + result.author.avatar_url + "\">\n </div>\n <div class=\"commit-author-info left\">\n <a href=\"https://github.com/" + result.author.login + "\"><b class=\"commit-author\">" + result.author.login + "</b></a>\n <br />\n <b class=\"commit-date\">" + ($.timeago(result.commit.committer.date)) + "</b><br /><i class=\"commit-sha\">SHA: " + result.sha + "</i>\n <br />\n <a class=\"commit-message\" href=\"https://github.com/" + username + "/" + repo + "/commit/" + result.sha + "\" target=\"_blank\">" + result.commit.message + "</a>\n </div>\n</li>");
}
})(index, result));
}
return _results;
return results;
};
container.find('h4').text("Latest Commits to " + username + "/" + repo);
title = "Latest Commits to " + username + "/" + repo;
url = "https://api.github.com/repos/" + username + "/" + repo + "/commits?callback=callback";
if (params.branch != null) {
url += "&sha=" + branch;
}
if (params.author != null) {
url += "&author=" + author;
title += " by " + author;
}
container.find('h4').text(title);
return $.ajax(url, {
data: {
per_page: limit
Expand Down
2 changes: 1 addition & 1 deletion dist/javascripts/bundle.min.js
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/coffeescripts/github-latest-commits.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $ ->
repo = params.repo
limit = params.limit
branch = params.branch
author = params.author
container = $('#latest-commits-widget')

callback = (response) ->
Expand All @@ -48,12 +49,18 @@ $ ->
</div>
</li>
""")

container.find('h4').text("Latest Commits to #{username}/#{repo}")


title = "Latest Commits to #{username}/#{repo}"
url = "https://api.github.com/repos/#{username}/#{repo}/commits?callback=callback"

if params.branch?
url += "&sha=#{branch}"
if params.author?
url += "&author=#{author}"
title += " by #{author}"

container.find('h4').text(title)

$.ajax(
url
Expand Down
18 changes: 12 additions & 6 deletions src/javascripts/github-latest-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,40 @@ $.extend({
});

$(function() {
var branch, callback, container, limit, params, repo, url, username;
var author, branch, callback, container, limit, params, repo, title, url, username;
params = $.getUrlVars();
username = params.username;
repo = params.repo;
limit = params.limit;
branch = params.branch;
author = params.author;
container = $('#latest-commits-widget');
callback = function(response) {
var index, items, result, ul, _results;
var index, items, result, results, ul;
items = response.data;
ul = $('#commit-history');
ul.empty();
_results = [];
results = [];
for (index in items) {
result = items[index];
_results.push((function(index, result) {
results.push((function(index, result) {
if (result.author != null) {
return ul.append("<li class=\"clearfix\">\n <div class=\"left\">\n <img class=\"commit-avatar\" src=\"" + result.author.avatar_url + "\">\n </div>\n <div class=\"commit-author-info left\">\n <a href=\"https://github.com/" + result.author.login + "\"><b class=\"commit-author\">" + result.author.login + "</b></a>\n <br />\n <b class=\"commit-date\">" + ($.timeago(result.commit.committer.date)) + "</b><br /><i class=\"commit-sha\">SHA: " + result.sha + "</i>\n <br />\n <a class=\"commit-message\" href=\"https://github.com/" + username + "/" + repo + "/commit/" + result.sha + "\" target=\"_blank\">" + result.commit.message + "</a>\n </div>\n</li>");
}
})(index, result));
}
return _results;
return results;
};
container.find('h4').text("Latest Commits to " + username + "/" + repo);
title = "Latest Commits to " + username + "/" + repo;
url = "https://api.github.com/repos/" + username + "/" + repo + "/commits?callback=callback";
if (params.branch != null) {
url += "&sha=" + branch;
}
if (params.author != null) {
url += "&author=" + author;
title += " by " + author;
}
container.find('h4').text(title);
return $.ajax(url, {
data: {
per_page: limit
Expand Down