Re: Adding an itemSaving handler for pre-flight duplicate detection

337 views
Skip to first unread message

adamsmith

unread,
Jun 30, 2012, 7:29:11 PM6/30/12
to zoter...@googlegroups.com
this is great!
I took it for a spin on FF 13.0.1 on Ubuntu 12.0.4 packaging and install work fine and it detects the duplicate I tried this with, but the window that pops up is unusable:
Sometimes it just has the "Possible Duplicate Found" bar on the top and the window is blank, sometimes it looks like this: http://imgur.com/Uj3oW
I'm happy to help debug this further if you tell me what info you need - I looked at Zotero's debug and couldn't find anything relevant.


On Thursday, June 28, 2012 4:33:54 PM UTC-6, Chris Johnson-Roberson wrote:
Hi all,

I've been working on a pre-flight duplicate detection plugin, using some of the suggestions made in this thread. Currently, my approach is to redefine the Zotero.Translate.Sandbox.Base._itemDone method and call a function that checks for duplicates and prompts the user if a potential match is found, just before the itemSaving handler is called. I suspect such redefinition is frowned upon in plugins, but I couldn't figure out how to add a default itemSaving handler, or where else to insert the check.

The code, such as it is, is up on github: https://github.com/chrisjr/zotero-prevent-duplicates

Please let me know if you have any suggestions, either regarding the matching method or the way it hooks into the rest of Zotero.

Thanks,
Chris

Christopher Johnson-Roberson

unread,
Jun 30, 2012, 8:49:17 PM6/30/12
to zoter...@googlegroups.com
Thanks for trying it out! It appears that, depending on the user's preferences for default citation style, Zotero.QuickCopy.getContentFromItems may return HTML even if you try to get plain text from it. However, the HTML should now be displayed correctly, and hopefully the Add/Cancel buttons should also appear in the dialog.

Please let me know if it works for you now. I'm upgrading to an SSD tonight and will install Ubuntu to facilitate testing of this and some other software.

Any input on where else to insert the check would still be welcome, since this method can't stop duplicates introduced via connectors or imports from RIS files, etc.

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/zotero-dev/-/8_fy2tjlPSIJ.

To post to this group, send email to zoter...@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.

Frank Bennett

unread,
Jun 30, 2012, 9:08:59 PM6/30/12
to zoter...@googlegroups.com
On Sun, Jul 1, 2012 at 9:49 AM, Christopher Johnson-Roberson
<chris.johns...@gmail.com> wrote:
> Thanks for trying it out! It appears that, depending on the user's
> preferences for default citation style, Zotero.QuickCopy.getContentFromItems
> may return HTML even if you try to get plain text from it. However, the HTML
> should now be displayed correctly, and hopefully the Add/Cancel buttons
> should also appear in the dialog.

I've filed a couple of pull requests in response to adamsmith's report.

display-title
The translator progress box in Zotero uses a getDisplayTitle()
method to identify items being translated. Using the same function in
the preventDuplicates popup would make the listing consistent, and
avoid shifts and possible corruption in the formatting of the item
cite depending on the default style selection in Zotero.

styling
Adding the stylesheets used by the Zotero translator progress box
resolves the transparency and font jaggie issues shown in adamsmith's
screenshot.

Frank Bennett

adamsmith

unread,
Jul 1, 2012, 1:26:03 AM7/1/12
to zoter...@googlegroups.com
thanks - works great for me now, I'll just keep this running and see if anything else comes up, but it's looking well so far.

If I understand Frank's comments correctly, this displayed a full citation before, now it's just a title?
It would be interesting to hear from more users, but I'd imagine that depending on what type of items people have, a full citation would be a lot more useful - for me personally the title is sufficient.

Being able to get this to work with connectors would be great - else it's of no use to Standalone users, maybe Simon has pointers on tat.

This plugin will make many people very happy, just today someone asked for exactly that on twitter:
https://twitter.com/DanielPaulOD/status/219152281428430848
>> zotero-dev+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/zotero-dev?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "zotero-dev" group.
> To post to this group, send email to zoter...@googlegroups.com.
> To unsubscribe from this group, send email to
> zotero-dev+unsubscribe@googlegroups.com.

Frank Bennett

unread,
Jul 1, 2012, 2:43:11 AM7/1/12
to zoter...@googlegroups.com
On Sun, Jul 1, 2012 at 2:26 PM, adamsmith <bst...@gmx.de> wrote:
> thanks - works great for me now, I'll just keep this running and see if
> anything else comes up, but it's looking well so far.
>
> If I understand Frank's comments correctly, this displayed a full citation
> before, now it's just a title?
> It would be interesting to hear from more users, but I'd imagine that
> depending on what type of items people have, a full citation would be a lot
> more useful - for me personally the title is sufficient.

No strong opinion here (I put forward the getDisplayTitle() patch at
the same time Chris was fixing the QuickCopy method).

If a more complete static description string is desired, items carry a
firstCreator field (used for the center panel listing), that stores
the author name in a display-friendly format, and could be prepended
to getDisplayTitle().

Frank
>> >> zotero-dev+...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/zotero-dev?hl=en.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "zotero-dev" group.
>> > To post to this group, send email to zoter...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > zotero-dev+...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/zotero-dev?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "zotero-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/zotero-dev/-/Eyu3mR5XZoUJ.
>
> To post to this group, send email to zoter...@googlegroups.com.
> To unsubscribe from this group, send email to
> zotero-dev+...@googlegroups.com.

Simon Kornblith

unread,
Jul 1, 2012, 11:01:08 AM7/1/12
to zotero-dev
On Jul 1, 1:26 am, adamsmith <bst...@gmx.de> wrote:
> thanks - works great for me now, I'll just keep this running and see if
> anything else comes up, but it's looking well so far.
>
> If I understand Frank's comments correctly, this displayed a full citation
> before, now it's just a title?
> It would be interesting to hear from more users, but I'd imagine that
> depending on what type of items people have, a full citation would be a lot
> more useful - for me personally the title is sufficient.
>
> Being able to get this to work with connectors would be great - else it's
> of no use to Standalone users, maybe Simon has pointers on tat.

There are three ways to save an item via the connectors, and four via
the bookmarklet. These are, in approximate order of how widely used I
think they are:

1. Translate in browser, save via Zotero Standalone
2. Translate in browser, save via server
3. Translate in Zotero Standalone
4. Translate on server (bookmarklet only)

Each of these cases will require its own implementation, and for
server-side translation we're probably limited to a post-save check. I
estimate that it's roughly an order of magnitude more work than
getting this to work in Firefox, which is the main reason I haven't
done it, even though I agree it's a great idea.

I can spec out exactly what I think this would look like if others are
interested in helping to implement it, but otherwise it's likely to
sit on my todo list for a while because of the amount of work
involved.

Simon

Christopher Johnson-Roberson

unread,
Jul 1, 2012, 2:11:16 PM7/1/12
to zoter...@googlegroups.com
I'd be happy to take on some/all of such an effort... I'm working for a historian through the Google Summer of Code, and have a fairly general mandate to develop tools that will facilitate her work and that of other scholars. Simon, if you have the time to spec out how it ought to work, I'd be appreciative.

Also, although I was initially persuaded by Frank Bennett's argument to use the display title for consistency's sake, I've restored the full citation as adamsmith suggests -- for several documents in my library, at least, the title alone doesn't give enough information to decide whether the new item is a duplicate.

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To post to this group, send email to zoter...@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.

Simon Kornblith

unread,
Jul 3, 2012, 8:17:22 PM7/3/12
to zotero-dev
Here's a 12-step plan for what would need to be done to get preflight
duplicate detection working in the connector:

https://gist.github.com/bb20fc75f26dfc976d40

There's no way this can be done as a plugin, since it requires too
many core code changes and changes to the connector, which a plugin
can't do. This is a lot of work, but if you're still interested, I'm
happy to advise.

Simon

On Jul 1, 2:11 pm, Christopher Johnson-Roberson

adamsmith

unread,
Jul 7, 2012, 5:29:43 PM7/7/12
to zoter...@googlegroups.com

Chris,
I've been using this for the last week or so and it works terrific, not-noticeable except for the couple of occasions where I actually wanted to safe a duplicate.
I haven't update for a while, but at least with the version I have, the add-on leads Zotero to fail for pages w/o a creator such as:
http://www.nytimes.com/2010/05/26/dining/26pretzelrex1.html
with
[JavaScript Error: "titleLastNameResults is undefined" {file: "chrome://preventduplicates/content/preventDuplicates.js" line: 116}]

Christopher Johnson-Roberson

unread,
Jul 7, 2012, 6:05:13 PM7/7/12
to zoter...@googlegroups.com
Sorry about that: it was a foolish error on my part, it should be fixed now.

Simon, thanks for the specification, it's nice and clear, and conforms better to Zotero's design. I'll fork the Zotero repository and get started in earnest in a few days.

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/zotero-dev/-/8mqWpMMk9m8J.
Message has been deleted

Christopher Johnson-Roberson

unread,
Aug 12, 2012, 3:16:53 PM8/12/12
to zoter...@googlegroups.com
Hi arggem,

I have continued to work on this off and on, but as Simon pointed out, there are too many ways to add items to a library for this to work as an extension. Therefore, I've focused my efforts on modifying Zotero's codebase roughly according to the plan laid out here, but have been forced to put it on the back burner for a while.

The main focus of my Google Summer of Code project is a Zotero extension that will allow one to run a variety of text mining processes (e.g. geoparsing and topic modeling) by right-clicking on a collection. That will be cleaned up for an initial release in the next few days, after which point I expect to dedicate some more attention to the duplicate prevention effort once again.

--Chris

On Tue, Aug 7, 2012 at 5:10 PM, arggem <arg...@gmail.com> wrote:
Chris!

This is great! I had just posted on Zotero.org about wanting this and some directed me here.

I have version 0.0.1 installed.  It seems a little quirky...sometimes works, sometimes doesn't etc. But I don't want to troubleshoot it if there is a more current version. Is there?

Thanks!

arggem
To unsubscribe from this group, send email to zotero-dev+unsubscribe@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+unsubscribe@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/zotero-dev/-/FaeybGZHABUJ.

Gary McCaman

unread,
Aug 14, 2012, 2:37:21 PM8/14/12
to zoter...@googlegroups.com
Thanks for the update!

Gurdas Sandhu

unread,
Oct 20, 2015, 4:19:26 PM10/20/15
to zotero-dev
Chris,

Can you please comment in this thread regarding the prevent-duplicates addon?
https://forums.zotero.org/discussion/52608/future-direction-of-zotero-firefox-addon/

I hope you can have the addon signed so that we may continue using it.

Thanks,
Gurdas
--Chris

To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.
On Saturday, July 7, 2012 6:05:13 PM UTC-4, Chris Johnson-Roberson wrote:
Sorry about that: it was a foolish error on my part, it should be fixed now.

Simon, thanks for the specification, it's nice and clear, and conforms better to Zotero's design. I'll fork the Zotero repository and get started in earnest in a few days.

On Sat, Jul 7, 2012 at 5:29 PM, adamsmith <bst...@gmx.de> wrote:

Chris,
I've been using this for the last week or so and it works terrific, not-noticeable except for the couple of occasions where I actually wanted to safe a duplicate.
I haven't update for a while, but at least with the version I have, the add-on leads Zotero to fail for pages w/o a creator such as:
http://www.nytimes.com/2010/05/26/dining/26pretzelrex1.html
with
[JavaScript Error: "titleLastNameResults is undefined" {file: "chrome://preventduplicates/content/preventDuplicates.js" line: 116}]


On Thursday, June 28, 2012 4:33:54 PM UTC-6, Chris Johnson-Roberson wrote:
Hi all,

I've been working on a pre-flight duplicate detection plugin, using some of the suggestions made in this thread. Currently, my approach is to redefine the Zotero.Translate.Sandbox.Base._itemDone method and call a function that checks for duplicates and prompts the user if a potential match is found, just before the itemSaving handler is called. I suspect such redefinition is frowned upon in plugins, but I couldn't figure out how to add a default itemSaving handler, or where else to insert the check.

The code, such as it is, is up on github: https://github.com/chrisjr/zotero-prevent-duplicates

Please let me know if you have any suggestions, either regarding the matching method or the way it hooks into the rest of Zotero.

Thanks,
Chris

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/zotero-dev/-/8mqWpMMk9m8J.

To post to this group, send email to zoter...@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.
On Saturday, July 7, 2012 6:05:13 PM UTC-4, Chris Johnson-Roberson wrote:
Sorry about that: it was a foolish error on my part, it should be fixed now.

Simon, thanks for the specification, it's nice and clear, and conforms better to Zotero's design. I'll fork the Zotero repository and get started in earnest in a few days.

On Sat, Jul 7, 2012 at 5:29 PM, adamsmith <bst...@gmx.de> wrote:

Chris,
I've been using this for the last week or so and it works terrific, not-noticeable except for the couple of occasions where I actually wanted to safe a duplicate.
I haven't update for a while, but at least with the version I have, the add-on leads Zotero to fail for pages w/o a creator such as:
http://www.nytimes.com/2010/05/26/dining/26pretzelrex1.html
with
[JavaScript Error: "titleLastNameResults is undefined" {file: "chrome://preventduplicates/content/preventDuplicates.js" line: 116}]


On Thursday, June 28, 2012 4:33:54 PM UTC-6, Chris Johnson-Roberson wrote:
Hi all,

I've been working on a pre-flight duplicate detection plugin, using some of the suggestions made in this thread. Currently, my approach is to redefine the Zotero.Translate.Sandbox.Base._itemDone method and call a function that checks for duplicates and prompts the user if a potential match is found, just before the itemSaving handler is called. I suspect such redefinition is frowned upon in plugins, but I couldn't figure out how to add a default itemSaving handler, or where else to insert the check.

The code, such as it is, is up on github: https://github.com/chrisjr/zotero-prevent-duplicates

Please let me know if you have any suggestions, either regarding the matching method or the way it hooks into the rest of Zotero.

Thanks,
Chris

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/zotero-dev/-/8mqWpMMk9m8J.

To post to this group, send email to zoter...@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
Reply all
Reply to author
Forward
0 new messages