Jamments

Jamments

new Jamments(options)

Source:
Create the API object
Parameters:
Name Type Description
options Object The options object
Properties
Name Type Description
endpoint String The API's full address (ex. https://comments.my-blog.net)
cachedFilesURI String URI path to get to static files (without slashes, ex. static)

Methods

(static) escapeHtml(text) → {String}

Source:
Escape html to avoid xss
Parameters:
Name Type Description
text String
Returns:
Type
String

(static) parseMd(text) → {String}

Source:
Create HTML from Markdown (just a subset: links, *italicized*, **bold**, `code`, ```codeblock``` and paragraph)
Parameters:
Name Type Description
text String
Returns:
Type
String

deleteComment(commentId, secret) → {Promise}

Source:
Delete a comment
Parameters:
Name Type Description
commentId String
secret String
Returns:
Type
Promise

getCommentById(id) → {Object}

Source:
Get a comment from cached comments
Parameters:
Name Type Description
id String
Returns:
Type
Object

getComments(slug) → {Promise|Promise.resolve.<Array>|Promise.reject.<Error>}

Source:
Return all comments sorted chronogically. Children comments are contained inside their parents (chrono sorted too)
Parameters:
Name Type Description
slug String
Returns:
  • Type
    Promise
  • array of comments sorted chronologically
    Type
    Promise.resolve.<Array>
  • Type
    Promise.reject.<Error>

getSiteInfos() → {Promise}

Source:
Get global site info (nbr of comments for each article & md5 of admin user)
Returns:
Type
Promise

postComment(slug, comment, name, email, parentId) → {Promise}

Source:
Post a new comment
Parameters:
Name Type Description
slug String
comment String
name String
email String
parentId String
Returns:
Type
Promise

updateComment(commentId, comment, secret) → {Promise}

Source:
Update a comment
Parameters:
Name Type Description
commentId String
comment String
secret String
Returns:
Type
Promise

updateNewCommentsSubscription(articleId, userId, secret, subscribe) → {Promise}

Source:
Update user notification preferences for an article
Parameters:
Name Type Description
articleId String
userId String
secret String
subscribe Bool
Returns:
Type
Promise

validateComment(commentId, secret) → {Promise}

Source:
Validate comment by sending validation data to API and refresh commentlist after that
Parameters:
Name Type Description
commentId String
secret String
Returns:
Type
Promise