Bookmark Search Results

The Appkit Social module lets users bookmark search results:

JSP Expression Language functions are available for getting a user’s profile, the number of bookmarks the user has made, and whether a particular result has been bookmarked by a user.

Bookmark Action tag

The Bookmark Action tag displays controls for adding a new bookmark, in addition to statistics on the number of times a specified target document has been bookmarked.

Usage

The Bookmark Action tag is typically used within a Result List tag, to enable the user to bookmark a particular document in the result list:

<search:resultList response="${response}" >
    <search:result>
        <social:bookmarkAction target="${result.id}" url="${result.fields.url}" title="${result.fields.title" />
    </search:result>
</search:resultList>

Note that new bookmarks are always associated with the currently-authenticated user.

Required tag attributes

target (java.lang.String)
The ID of the document that should be bookmarked.

title (java.lang.String)
The title of the new bookmark.

Optional tag attributes

collection (java.lang.String)
The collection to which the target document belongs.

url (java.lang.String)
A URL which the new bookmark should link to.
Default: the bookmark target, if it is a URL

topic (twigkit.model.Topic)
A topic to which the new bookmark should belong.

label (java.lang.String)
Label for the bookmark link.
Default: "Bookmark"

tooltip (java.lang.String)
Tool tip for the bookmark link.
Default: "Bookmark this?"

activeLabel (java.lang.String)
Label to show when document has already been bookmarked by the current user.
Default: "Remove bookmark"

activeTooltip (java.lang.String)
Tool tip to show when document has already been bookmarked by the current user. Default: "You have bookmarked this."

singularLabel (java.lang.String)
Label for bookmark statistics (following the number of bookmarks for the document in question) when there is a single bookmark.
Default: ""

singularTooltip (java.lang.String)
Tool tip for bookmark statistics when there is a single bookmark.
Default: "person has bookmarked this."

pluralLabel (java.lang.String)
Label for bookmark statistics (following the number of bookmarks for the document in question) when there are multiple bookmarks.
Default: ""

pluralTooltip (java.lang.String)
Tool tip for bookmark statistics when there are multiple bookmarks.
Default: "people have bookmarked this."

Bookmark List tag

The Bookmark List tag retrieves and displays all bookmarks that have been created by a particular user, are within a given topic, or are linked to a particular document (or any combination of the three constraints).

Usage

The Bookmark List tag is typically used as follows:

<social:bookmarkList user="${social:getCurrentUserProfile()}" emptyText="You don't currently have any bookmarks." />

Tag attributes

user (twigkit.model.UserProfile)
Specifies the user whose bookmarks should be retrieved.

target (java.lang.String)
If set, only display bookmarks related to this target document.

topic (twigkit.model.Topic)
Optionally, bookmarks can be scoped to a particular topic. If this attribute is set, then the tag will list only those bookmarks that are linked to that topic.

collection (java.lang.String)
Optionally, bookmarks can be scoped to a particular collection, identified by a string ID. If this attribute is set, then the tag will list only those bookmarks that belong to the given collection.

format (java.lang.String)
Which date format to use.
Default: "relative"

deleteLabel (java.lang.String)
Label to display for the delete action.
Default: "x"

show (java.lang.Integer)
How many bookmarks should be displayed initially.
Default: 10

showMore (java.lang.Integer)
How many more bookmarks should be added to the list each time the user clicks 'Show more'.
Default: 10

showMoreLabel (java.lang.String)
Label to display for 'show more' action.
Default: "Show more bookmarks"

showLessLabel (java.lang.String)
Label to display for 'show fewer' action.
Default: "Show fewer"

emptyText (java.lang.String)
Text to display if the the user has not created any bookmarks.
Default: ""

urlPattern (java.lang.String)
A pattern which can be used to construct a custom URL action in the bookmark list. The pattern should be an expression that may include occurrences of the variable holder {{ target }} which will be replaced with the bookmark target at runtime.

JSP expressions

These Social Module methods are useful when working with bookmarks. They are accessible via JSP Expression Language functions. Sample expressions are shown.

twigkit.model.UserProfile getCurrentUserProfile()
Get the profile of the currently active user.
${social:getCurrentUserProfile()}

long isBookmarkedByUser(twigkit.model.UserProfile user, java.lang.String id)
Indicates (by a positive value) whether or not the item with the given ID has been bookmarked by the specified user.
${social:isBookmarkedByUser(social:getCurrentUserProfile(),result.id) > -1 ? 'bookmarked-by-you' : ''}

int getBookmarkCount(twigkit.model.UserProfile user, twigkit.model.Topic topic)
Returns the number of items that have been bookmarked by the user, within the scope of the topic specified (if the topic parameter is not null).
${social:getBookmarkCount(social:getCurrentUserProfile(), null)}