Origami Frontend Components & Services

JSDoc: o-comment-api

o-comment-api has a support status of "dead". This means that there are no plans to fix any issues with this component, and it may stop working at any point. More information on the status of this component is available in the README. If you still rely on this component or have concerns, please contact the Origami team.

api

Global Property

Type

  • Object

Export of the SUDS and CCS APIs.

Links

cache

Global Property

Type

  • Object

Allows access to the cached values.

Links

livefyre

Global Property

Type

  • Object

Livefyre related SUDS endpoints.

Links

user

Global Property

Type

  • Object

User related SUDS endpoints.

Links

enableLogging

Global Function

Enables logging.

Returns

  • undefined

Links

disableLogging

Global Function

Disables logging.

Returns

  • undefined

Links

setLoggingLevel

Global Function

Sets logging level.

Returns

  • undefined

Links

setConfig(keyOrObject, value)

Global Function

This method sets additional or overrides current configuration options.

parameter type default description
keyOrObject string | object Key or actually an object with key-value pairs.
value anything Optional. Should be specified only if keyOrObject is actually a key (string).

Returns

  • undefined

Links

getAuth

Global Function

Verifies if there's a valid auth token (not expired) attached to the session ID provided.

Returns

  • String - Auth token

Links

removeAuth

Global Function

Removes the auth token from the local cache.

Returns

  • undefined

Links

cacheAuth(authObject)

Global Function

Saves the auth token into the local cache.

parameter type default description
authObject object Object which contains the following: - JWT token - displayName - settings (e.g. email preferences) - expires (timestamp like Date.getTime())

Returns

  • boolean - True if successfully saved or false if not.

Links

getInit(articleId)

Global Function

Returns the SUDS init object saved into the local cache.

parameter type default description
articleId string | number The ID of the article

Returns

  • object - Livefyre init object

Links

cacheInit(articleId, initObj)

Global Function

Saves the SUDS init object into the local cache.

parameter type default description
articleId string | number The ID of the article
initObj object SUDS init

Returns

  • undefined

Links

removeInit(articleId)

Global Function

Removes the SUDS init object from the local cache.

parameter type default description
articleId string | number The ID of the article

Returns

  • undefined

Links

clear

Global Function

Clears all entries created by the cache.

Returns

  • undefined

Links

getComments(conf, callback)

Global Function

Uses CCS.getComments endpoint, but it also embeds an optional caching layer for the authentication info.

parameter type default description
conf Object Configuration object: ### Configuration #### Mandatory fields: - articleId: ID of the article, any string - url: canonical URL of the page - title: Title of the page #### Optional fields: - stream: enable streaming of new comments - page: the page number to be fetched. By default it is 0. - section: Override the default mapping based on URL or CAPI with an explicit mapping. Section parameter should be a valid FT metadata term (Primary section) - tags: Tags which will be added to the collection in Livefyre
callback function function (err, data)

Returns

  • undefined

Links

postComment(conf, callback)

Global Function

Posts a comment into a given collection using the user's auth token.

Configuration

Mandatory fields

  • collectionId: ID of the collection to post the comment.
  • commentBody: actual content of the comment.
parameter type default description
conf Object Configuration object
callback function function (err, data)

Returns

  • undefined

Links

getXhrForUrl

Global Function

Determine XHR.

Links

trim(string)

Global Function

Wrapper and polyfill for String.prototype.trim

parameter type default description
string string The string to be trimmed.

Returns

  • string - The trimmed string.

Links

module.exports

Static Property

Type

  • Object

Export all endpoints.

Links

module.exports

Static Property

Type

  • js-env-config

Isolated copy of the configuration.

Links

livefyre.getInitConfig(conf, callback)

Static Method

Uses SUDS.livefyre.init endpoint, but it also embeds an optional caching layer.

parameter type default description
conf Object Configuration object ### Configuration #### Mandatory fields: - elId: ID of the HTML element in which the widget should be loaded - articleId: ID of the article, any string - url: canonical URL of the page - title: Title of the page #### Optional fields: - stream_type: livecomments, livechat, liveblog - force: has effect in combination with cache enabled. If force set to true, the data won't be readed from the cache even if a valid entry exists, but it will force the call to the webservice to happen. - section: Override the default mapping based on URL or CAPI with an explicit mapping. Section parameter should be a valid FT metadata term (Primary section) - tags: Tags which will be added to the collection in Livefyre
callback function function (err, data)

Returns

  • undefined

Links

user.getAuth(confOrCallback, callback)

Static Method

Uses SUDS.user.getauth endpoint, but it also embeds an optional caching layer.

Configuration

Optional fields:

  • force: has effect in combination with cache enabled. If force set to true, the data won't be readed from the cache even if a valid entry exists, but it will force the call to the webservice to happen.
parameter type default description
confOrCallback Object | function Configuration object following the fields from the description, or if it isn't relevant, callback function.
callback function Callback function if configuration is provided as well.

Returns

  • undefined

Links

user.updateUser(userSettings, callback)

Static Method

Saves the user's settings by making a call to SUDS.user.updateuser endpoint.

parameter type default description
userSettings Object Fields: pseudonym, emailcomments, emailreplies, emaillikes, emailautofollow
callback function function (err, data)

Returns

  • undefined

Links

module.exports

Static Property

Type

  • Object

Export all endpoints.

Links

Status
dead Origami v1 (Bower)
Switch component view

GitHub: o-comment-api

Install o-comment-api

If using the Build Service, add o-comment-api@^2.6.1 to your script tag.

If using the npm package manager for a Manual Build, run npm install --save-peer "@financial-times/o-comment-api@^2.6.1".

Help & Support

o-comment-api is maintained directly by the Origami team. If you have any questions about o-comment-api or Origami in general, we are happy to help. 😊

Slack: #origami-support
Email: origami.support@ft.com

Feedback / Issues

To report a bug or request features please create an issue on Github. For support or general feedback please get in touch 😊

Slack: #origami-support
Email: origami.support@ft.com