[annotator-dev] How to query annotations created by current user only
Sarah Bird - Bonvaya
sarah at bonvaya.com
Tue Nov 25 05:46:08 UTC 2014
Hi Rick,
This is how I do something similar:
a.annotator('addPlugin', 'Store', {
prefix: 'http://annotateit.org/api',
annotationData: {
'project': PROJECTNAME,
'version': VERSION,
'uri': URI,
'siteuid': SITE_UNIQUE_ID,
'pageuid': PAGE_UNIQUE_ID
},
loadFromSearch: {
'pageuid': PAGE_UNIQUE_ID.toLowerCase(),
'limit': 1000
}
});
(
https://github.com/open-contracting/standard-collaborator/blob/master/django/website/main/templates/main/standard.html#L91
)
I am adding custom data, and searching based on that.
In your case, I imagine this should work:
a.annotator('addPlugin', 'Store', {
prefix: 'http://annotateit.org/api',
annotationData: {
"docId":that.data._id,
"userId":Meteor.userId()
},
loadFromSearch: {
'userId': Meteor.userId(),
'limit': 1000
}
});
Assuming your store endpoint has a search api working.
Best,
Bird
On Thu, Nov 20, 2014 at 5:47 PM, Rick <rmercer33 at gmail.com> wrote:
> Hi All,
>
> I'm using annotator.js v 1.2.9 and using the Store plugin with Meteor and
> MongoDB.
>
> I want only annotations created by the current user to be displayed.
>
> When annotator is first initialized it makes a GET request to receive all
> annotations. Rather than return all annotations I want to return only those
> created by the current user (on the current page).
>
> But the GET request does not include any user information that can be used
> to query the database. I tried using the annotationData option of the Store
> plugin but that info is not part of the GET request - but is part of the
> annotation json object in the body of a POST.
>
> that.$('#document').annotator()
> .annotator("addPlugin", 'Store', {
> prefix: '/api',
> annotationData: {"docId":that.data._id, "userId":Meteor.userId()}
> })
>
>
> I tried the Permissions plugin and can see how that prevents others from
> editing or deleting an annotation they did not create but It doesn't seem
> to work when I try to restrict readers to just the creator. Here's my code
> for that:
>
> var userInfo = {id:Meteor.userId(),
> email:Meteor.user().emails[0].address};
>
>
> .annotator("addPlugin", 'Permissions', {
> user: userInfo,
> userId: function(user) {
> if (user && user.id) {
> return user.id;
> }
> else
> return user
> },
> userString: function(user) {
> if (user && user.id) {
> return user.email;
> }
> else
> return user
> },
> permissions: {
> 'read': [userInfo.id],
> 'update': [userInfo.id],
> 'delete': [userInfo.id],
> 'admin': [userInfo.id]
> },
> showViewPermissionsCheckbox: false,
> showEditPermissionsCheckbox: false
> })
>
>
> I also tried the Auth plugin which adds an 'x-annotator-auth-token' key to
> the request header and I can use that token to obtain user info but, the
> token is not added to the GET request.
>
> So, I don't know how to proceed. All help is gratefully appreciated.
>
> Thanks in advance.
>
> Rick ;-)
>
> _______________________________________________
> annotator-dev mailing list
> annotator-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/annotator-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20141124/5ac0db78/attachment-0004.html>
More information about the annotator-dev
mailing list