Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix \n\n CRLN from API for show in view #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
16 changes: 11 additions & 5 deletions dist/javascripts/bundle.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/*
Helper to parse query string params
*/
var formatMessage;

$.extend({
getUrlVars: function() {
var hash, hashes, i, vars;
Expand All @@ -22,6 +24,10 @@ $.extend({
}
});

formatMessage = function(msg) {
return msg.replace(/\n/g, "<br />");
};

$(function() {
var branch, callback, container, limit, params, repo, url, username;
params = $.getUrlVars();
Expand All @@ -31,20 +37,20 @@ $(function() {
branch = params.branch;
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>");
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\">" + (formatMessage(result.commit.message)) + "</a>\n </div>\n</li>");
}
})(index, result));
}
return _results;
return results;
};
container.find('h4').text("Latest Commits to " + username + "/" + repo);
url = "https://api.github.com/repos/" + username + "/" + repo + "/commits?callback=callback";
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.

6 changes: 5 additions & 1 deletion src/coffeescripts/github-latest-commits.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $.extend
getUrlVar: (name) ->
$.getUrlVars()[name]

formatMessage = (msg) ->
msg.replace(/\n/g, "<br />");

$ ->
params = $.getUrlVars()
# config parameters
Expand All @@ -44,7 +47,7 @@ $ ->
<br />
<b class="commit-date">#{$.timeago(result.commit.committer.date)}</b><br /><i class="commit-sha">SHA: #{result.sha}</i>
<br />
<a class="commit-message" href="https://github.com/#{username}/#{repo}/commit/#{result.sha}" target="_blank">#{result.commit.message}</a>
<a class="commit-message" href="https://github.com/#{username}/#{repo}/commit/#{result.sha}" target="_blank">#{formatMessage(result.commit.message)}</a>
</div>
</li>
""")
Expand All @@ -63,3 +66,4 @@ $ ->
type: "get"
).success (response) ->
callback(response)

16 changes: 11 additions & 5 deletions src/javascripts/github-latest-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/*
Helper to parse query string params
*/
var formatMessage;

$.extend({
getUrlVars: function() {
var hash, hashes, i, vars;
Expand All @@ -22,6 +24,10 @@ $.extend({
}
});

formatMessage = function(msg) {
return msg.replace(/\n/g, "<br />");
};

$(function() {
var branch, callback, container, limit, params, repo, url, username;
params = $.getUrlVars();
Expand All @@ -31,20 +37,20 @@ $(function() {
branch = params.branch;
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>");
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\">" + (formatMessage(result.commit.message)) + "</a>\n </div>\n</li>");
}
})(index, result));
}
return _results;
return results;
};
container.find('h4').text("Latest Commits to " + username + "/" + repo);
url = "https://api.github.com/repos/" + username + "/" + repo + "/commits?callback=callback";
Expand Down