Coder Social home page Coder Social logo

angular-comments's Introduction

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:

  • setSiteId: Specify the site Id or forum name for your site
    • required
  • setForumName: Alias for setSiteId to confirm with Disqus terminology
  • setProvider: Specify which commenting platform you want to use (currently supported values: livefyre and disqus)
    • required
  • setDisplayOnLoad: Enable/disable whether or not to load comment thread immediately
    • optional
    • default: true
    • If you have multiple posts on a single page and your platform doesn't support showing multiple comment threads at once, only the first thread will be loaded
  • setShowCommentCount: Enable/disable display of comment count when thread is hidden
    • optional
    • default: true
    • If your platform includes a comment count as part of the thread, this paragraph will be hidden when the thread is visible
    • Note: Right now clicking on this comment count element is the only way to load a thread that isn't already visible, so be sure displayOnLoad is set to true if you use this
  • setBaseUrl: If no article URL is passed in, URL is calculated as baseUrl + articleId.
    • optional
    • default: $location.get('protocol') + '://' + $location.get('host') + '/'
  • setCommentTextMap: Specify text map for comment count display. Follows same pattern as ng-pluralize when attribute
    • optional
    • default: { '0' : 'No comments yet', '1' : 'One comment', 'other' : '{} comments' }
  • setLoadingText: Text to display while loading comment count/thread
    • optional
    • default: 'Loading comments...'
  • setCallback: Attach a callback function to an event
    • optional
    • supported callbacks:
      • onCommentPosted
        • Params: articleId, data (data is specific to each platform)
      • onCommentCountUpdated
        • Params: articleId, count
      • onThreadLoaded
        • Params: articleId, container (jqLite object of DOM element containing thread)
    • example:
commentConfig.setCallback('onCommentPosted', function (slug, data) {
    analytics.track('commentPosted', slug);
});

angular-comments's People

Stargazers

strongant avatar Manuel Romero avatar Andrey Stepanov avatar Seo Seokjin avatar Ihor avatar Adam Bedell avatar Manikanta Gade avatar Pedro de la Cruz Jr. avatar Masanori avatar Jason Gendron avatar Daniel Kanze avatar Konstantin Raev avatar  avatar

Watchers

James Cloos avatar Zack Yang avatar Alex Vanston avatar

Forkers

sanduhrs

angular-comments's Issues

Version mismatch

Upon running bower install angular-comments --save, I got the following returned to me:

bower angular-comments#*    not-cached git://github.com/mrvdot/angular-comments.git#*
bower angular-comments#*       resolve git://github.com/mrvdot/angular-comments.git#*
bower angular-comments#*      download https://github.com/mrvdot/angular-comments/archive/v1.2.0.tar.gz
bower angular-comments#*       extract archive.tar.gz
bower angular-comments#*      mismatch Version declared in the json (0.2.0) is different than the resolved one (1.2.0)
bower angular-comments#*      resolved git://github.com/mrvdot/angular-comments.git#1.2.0

The bower.json file says the version is 0.x.x, while you have one version in the releases that is 1.x.x, this causes bower to use that unless there is a newer version (which there is, but the first place is a 0 not 1, so it is determined to be lower).

A workaround is to use "angular-comments": "~0.2.2" in my projects bower.json file, but that's obviously not ideal.

Comments won't load after initial render

So when I first load a page with div comments="myVideoConfig", the comments load and work just fine. If I then navigate to a different route, and come back to that page with the comments, it just says No comments and won't load the comments drop-in. I've switched between disqus & livefyre, and both are displaying the behavior. I'm on the latest rc3 of Angular 1.2 & latest of ui-router.

Comments wont load on consecutive posts loaded from WP. Only first post loaded.

Hi, I just added it in my script load sequence, setup the config and module as per instructions and added the directive in the blog post template, that is being loaded with the $stateProvider. I've tried these 2 ways to get the comments to display 1) div comments="post.content.ID">" AND 2) div comments="post">" where post is pulled from wordpress and is an object on the scope holding only { slug: ..., title: ..., url: ...}. As far as the refresh I'm not sure at all how to go about that... I'm still learning angular. My config is: commentConfig
.setForumName("lasselarsen")//Specify our forum name/site id for this site
.setProvider('disqus')//Specify we want to use disqus
Where would I add the refresh function? In the controller, or...? What would be good practice? I'm trying to learn how to not do spaghetti code and keep things as dry as possible.

Its not refreshing when you switch between posts, and the post comments are the same for all posts, it doesnt seem like it knows to which post a comment belongs...
So after looking more into it, the comments are not registered, it just says "untitled" in disqus. I have created a separate object on the scope exactly like the $scope.article = {slug: ..., etc } in instructions but nothing seems to work.

It seems like "threadLoaded" never becomes true when I load a different post, as well as if I click the directive in the dom I get this JS error : Cannot call method 'appendChild' of null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.