Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (60 sloc) 2.58 KB
{% assign issue_number = site.data.commentrefs[post.permalink] %}
{% raw %}
<div class="comments plain_links" ng-app="blog-comments" ng-controller="CommentsController">
<h2>Comments</h2>
<div ng-if="comments.length > 0 || isLoading">
<a ng-href="{{issueLink}}"><i class="fa fa-plus"></i> Add a comment</a> with your GitHub account
</div>
<div class="loading" ng-if="isLoading">
<i class="fa fa-spinner fa-2"></i> Loading comments...
</div>
<div ng-if="comments.length == 0 && !isLoading" class="no-comments">
No comments yet on this post. Why don't you <a ng-href="{{issueLink}}">be the first one</a>? By the way, you will need a GitHub account to comment.
</div>
<div ng-if="comments.length > 0 && !isLoading" ng-repeat="c in comments" class="comment">
<div class="comment-header">
<div class="comment-avatar">
<span class="dummy"></span>
<img ng-src="{{c.user.avatar_url}}" />
</div>
<a class="commenter" href="https://www.github.com/{{c.user.login}}">{{c.user.login}}</a>
<time datetime="{{c.created_at}}" title="{{dateTitle(c.created_at)}}">on {{c.created_at | date: "MMM dd, yyyy"}}</time>
</div>
<div class="comment-body" ng-bind-html="c.body_html | rawHtml">
</div>
</div>
</div>
{% endraw %}
<script type="text/javascript">
(function(ng){
function CommentsController($scope, $http, $filter){
$scope.isLoading = true;
$scope.comments = [];
$scope.issueLink = "https://github.com/zpbappi/zpbappi.github.io/issues/{{issue_number}}";
var apiLink = "https://api.github.com/repos/zpbappi/zpbappi.github.io/issues/{{issue_number}}/comments";
$scope.dateTitle = function(date){
return $filter("date")(date, "MMMM dd, yyyy '('hh:mm a 'GMT'Z')'")
};
function init(){
$http
.get(apiLink, {headers: {Accept: "application/vnd.github.full+json"}})
.then(function(res){
return $filter("orderBy")(res.data, "created_at");
})
.then(function(comments){
$scope.isLoading = false;
$scope.comments = comments;
});
};
init();
};
ng
.module("blog-comments", [])
.controller("CommentsController", ["$scope", "$http", "$filter", CommentsController])
.filter('rawHtml', ['$sce', function($sce){
return function(val) {
return $sce.trustAsHtml(val);
};
}]);
})(angular);
</script>