Last active
December 18, 2015 13:09
-
-
Save Jamedjo/5787449 to your computer and use it in GitHub Desktop.
LiveFyre comments system implemented as an angularjs service.
Navigating to to a new page generates a new comment config from the url. Buggy WIP, livefyre appears to be polling a url which is 404 Not Found until it eventually gets created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myapp.factory('Comments', function ($location) { | |
var isInitialized = false; | |
var comments = {}; | |
var getConfig = function(){ | |
var articleId = $location.path(); | |
var defaults = { | |
articleId: articleId, | |
collectionMeta: { | |
articleId: articleId, | |
url: fyre.conv.load.makeCollectionUrl(null, [], true) | |
} | |
}; | |
return defaults; | |
}; | |
var swapConfig = function(settings_object){}; | |
var init = function () { | |
isInitialized=true; | |
fyre.conv.load({ | |
el: 'livefyre-comments', | |
network: "livefyre.com", | |
siteId: "123456", | |
signed: false | |
}, [getConfig()], function callback(widget) { | |
swapConfig = widget.changeCollection; | |
}); | |
}; | |
var swap = function(){ | |
swapConfig(getConfig()); | |
}; | |
comments.run = function(){ | |
if(isInitialized){ | |
swap(); | |
} else { | |
init(); | |
} | |
} | |
return comments; | |
}); | |
function AppController($scope, Comments) { | |
Comments.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this!
Just in case anyone else is running into a problem like I did, I got it to work by changing
getConfig
to the following: