Skip to content

Commit

Permalink
fix \n\n CRLN from API for show in view
Browse files Browse the repository at this point in the history
  • Loading branch information
roramirez committed Nov 7, 2015
1 parent 1fcd3ad commit 7e6b33b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
14 changes: 9 additions & 5 deletions dist/javascripts/bundle.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,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 All @@ -62,6 +62,10 @@ $(function() {
});
});

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

/**
* Timeago is a jQuery plugin that makes it easy to support automatically
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
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.

5 changes: 4 additions & 1 deletion src/coffeescripts/github-latest-commits.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 +63,6 @@ $ ->
type: "get"
).success (response) ->
callback(response)

formatMessage(msg) ->
msg.replace(/\n/g, "<br />");
14 changes: 9 additions & 5 deletions src/javascripts/github-latest-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,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 All @@ -61,3 +61,7 @@ $(function() {
return callback(response);
});
});

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

0 comments on commit 7e6b33b

Please sign in to comment.