mrvdot / angular-comments

Multi Platform commenting component for AngularJS
MIT License
13 stars 2 forks source link

Angular Comments

Angular commenting component that allows you to easily integrate the Disqus and Livefyre commenting systems into your website. To read more about why this component was created and some of the problems it solves, see the original announcement post here.

Installation

To get started with Angular Comments, you can just use bower install angular-comments or clone it from here. Once installed, be sure to include the comments.js file in your page, require mvd.comments in your main app module, and then set your configuration values within the run block for your app. For example:

angular.module('myApp',['mvd.comments'])//require comments module
    .run(function (commentConfig) {
        commentConfig
        .setForumName("my-site")//Specify our forum name/site id for this site
        .setProvider('disqus')//Specify we want to use disqus
    ...
  });

Then, all we have to do is attach the comments directive to the appropriate element and pass in that post's metadata:

<div comments="article"></div>

Where article is a scoped variable that can be either a string representing the article ID itself (eg 'my-awesome-article') or a full object:

$scope.article = {
  slug : 'my-awesome-article',//ID used to uniquely identify this post for livefyre/disqus
  title : 'My awesome article',//Title string passed on to third-party service
  url : 'http://example.com/my-awesome-article'//URL to directly access this post
};

That's all there is to installing this component and getting a third-party commenting system up and running. The directive itself takes care of grabbing the necessary javascript files for Disqus/Livefyre and including them into your page when you need them.

Configuration

In addition to the basic settings necessary for connecting your site to Disqus/Livefyre, Angular Comments provides several other API options you can use to further customize your setup:

commentConfig.setCallback('onCommentPosted', function (slug, data) {
    analytics.track('commentPosted', slug);
});