Document-Level Comments
<#include
"components/comments/documentCommentThread.ftl"/>
to those pages.The entire file is wrapped in <#if hasSecurity &&
portal.hasFeature('docLevelComments')>
. This will ensure that Document-level
comments will appear in secured portals that have enabled document-level comments.
Both of these
attributes can be configured in the Portal Administration page.
This template includes the following code:
<#if !user??> <#assign pluginUser = {'id': -1, 'userName': 'Anonymous'}> <#else> <#assign pluginUser = user> </#if>
This code creates a pluginUser
variable which is later passed as an option to
titaniaAnnotate()
. It assigns a dummy user to that variable if a user is
not logged in (<#if !user??>
). Otherwise, it assigns the currently
logged-in user.
To enable Document-level commenting, Titania Delivery passes the following options to the Titania Comment Manager:
$('#commentContainer').titaniaAnnotate({ serverUrl: HARPPortal.getPortalRpcUrl('comments'), siteKey: '${portal.commentManagerSiteKey?js_string}', pageId: 'document:${itemData.item.projectKey?js_string}${itemData.item.projectPath?js_string}', author: { name: '${pluginUser.userName?js_string}', id: '${pluginUser.id?js_string}' }, targetId: 'data-itemKey', metadata: { xtrf: $('#viewerContent').find('[data-xtrf]').attr('data-xtrf'), xtrc: 'root', itemKey: '${itemData.item.key?js_string}', itemName: '${itemData.item.label?js_string}', projectKey: '${itemData.item.projectKey?js_string}', portalName: '${portal.name?js_string}', portalKey: '${portal.key?js_string}', <#if contextMetadata??> contextKey : '${contextMetadata.key}', contextName: '${contextMetadata.name}', </#if> modifiedDate: '${itemData.item.lastModified?datetime?iso_utc?js_string}' }, showLoadingIndicator: false, hoverClass: '', moderators: [<#list moderators as m>'${m?js_string}',</#list>], readOnly: ${(!user??)?string} });
Of note above:
- The values for the following options are given Titania Delivery-specific values and
should not be changed to preserve expected functionality:
serverUrl
siteKey
pageId
author
moderators
metadata
hoverClass
- As configured in the default themes, Document-level commenting is triggered by clicking a button. As such, it does not make sense to extra visual cues on mouse-over, so this option is left blank.targetId
- The unique identifier for the document being commented on is stored in thedata-itemKey
attribute. This can be changed in the markup inside this template. If that attribute changes, then this option should be changed accordingly.metadata
- The values provided to the metadata field are used to map a comment back to its source comment. It is not recommended to remove any of the given values. However, any other values may be added.readOnly
- The expression${(!user??)?string}
sets this value to true if a user is not logged in.metadata.contextKey
andmetadata.contextName
- These values are added to the metadata only if the document is being viewed within the context of a parent ditamap (<#if contextMetadata??>
).