wshanks / Zutilo

Zotero plugin providing some additional editing features
Other
1.53k stars 72 forks source link

How to edit links in attachments in Zotero 5 standalone ? #70

Closed EmmanuelCharpentier closed 7 years ago

EmmanuelCharpentier commented 7 years ago

I may be misunderstanding what the "Modify paths to attachments" ("Modifier les chemins vers les pièces jointes" in French) is supposed to do.

I am using Zutilo 2.0.3 on Zotero standalone 5.0.17 on Debian testing.

I have a not inconsiderable number of references to which I attach a link to the original paper in PDF. Some of them are links to the original publications ; however, when the original publication was hard to reach (eg : scan of a paper version obtained via interlibrary loan, PDF behind a paywall, etc...), I save the PDF on a dedicated WebDAV directory on a server and attach a link to that. Works like a charm : members of the relevant Zotero group can access the papers directly...

My problem is as follows : we have lost the domain name of the server. Twice ! The server itself is still accessible through a new domain name, but older references still have links to the old server name(s). Furthermore, we envision yet another domain name move.

I tried to use the "Modify paths to attachments" in Zutilo by asking to replace "old.domain.name" with "new.domain.name", to no effect. Ditto when asking to replace "https://old.domain.name/WebDAV/" by "https://new.domain.name/WebDAV/".

  1. Is this function supposed to work with links to attachments ?
  2. Is this function supposed to work in Zotero 5 ?

If the answer to either of these questions is "No", could this question be considered as an enhancement suggestion ? Otherwise, could you give specific instructions on how to use "Modify paths to attachments" ?

Alternatively, since this is (probably) a "one-shot" attempt, could you suggest a way to do that directly in SQL in the zotero.sqlite file ? I know my way in SQL, bu I'm a bit confused by the Zotero database structure...

Sincerely,

gracile-fr commented 7 years ago

(It's "Modify attachment paths" in the English version.) Not tested with z 5.0, but did you read Usage and Commands?

EmmanuelCharpentier commented 7 years ago

Yes, I did read those docs. (And yes, I did try to use the "replace all instances" checkbox. To no avail...)

However, I am perfectly conscious that I may have misunderstood the docs... Do not hesitate to correct me.

The "Commands" documentation seems to imply that I should have used Zotfile to create and auto-manage those links. IIRC, this didn't exist back in 2010 (2009 ?) when I created this hack to avoid the storage limitations on the Zotero server (for various organizational reasons, I couldn't (and still can't) plan to store my docs on an international server...).

If I understand correctly, Zutilo can modify :

but not a link to an URI.

Is that correct ?

gracile-fr commented 7 years ago

To be clear, I had quickly skimmed your original question :-) The links I posted above are not easy to find! @willsALMANJ will have to confirm but I think you are right that a link to a URI cannot be modified by Zutilo (nor by Zotero). Maybe you can do it through the Javascript API (but with Z5, I don't know how).

(by the way Zotero devs advise against modifying the sqlite directly)

wshanks commented 7 years ago

I'm not sure if it is possible to modify URI attachments. I can check later. Here is the commit that limits operations to linked file attachments. You can see that URI's are accessed differently from file paths (.attachmentPath vs. .getField('url')): https://github.com/willsALMANJ/Zutilo/commit/44ee13272ed0a43de13e32fbed8e1505547b91a8

wshanks commented 7 years ago

Also, I'm open to suggestions if the documentation is unclear 😉

wshanks commented 7 years ago

It looks like it should be possible to change the attachment link using .setField('url') but I haven't tested it yet. It doesn't seem possible to change it from the Zotero UI that I could see.

I am not sure what you mean by "a path to an attached file" vs. "a link to a file". Zutilo only modifies linked file attachment paths.

Regarding the advice to use ZotFile, this suggestion is only helpful for individual users. For groups, linked file attachments are not supported by Zotero because that would require that every member of the group have access to the attachments at the exact same file paths on their computers. A while back I helped get relative attachment paths added to Zotero so that you can change the base path in Zotero's preferences without having to modify all the attachment paths. A few times I have been asked about adding similar support for group attachments. That would not be too hard to do -- mainly a UI issue of figuring out how to present the base paths for group attachments (one base path per group?) -- but I have limited time and I don't personally use Zotero groups, so I haven't been able to prioritize that. Probably the more promising direction is to run a personal Zotero server. That can be done now but is a pain. The developers have said that a Docker image for Zotero server will be provided in the future once some architectural changes are made that make that easy to do.

EmmanuelCharpentier commented 7 years ago

t looks like it should be possible to change the attachment link using .setField('url') but I haven't tested it yet. It doesn't seem possible to change it from the Zotero UI that I could see.

That's what I was afraid of...

Could you consider adding to Zutilo a "Modify links URI" function, analogous to "modify attachemt paths", but that would (possibly repeatedly) edit the URIs of the attached links ?

BTW : Zotero does not seem to have any possibility to edit such a link ; the only posibility seems to add a new link, then delete the old. Do you think that adding a "link editor" would be useful ?

wshanks commented 7 years ago

I added a function to modify URL's in 273d80cd6fae29be13f2994132bdb29dd5398477 . I'm not sure when I'll have a chance to create a new release, but I am attaching the xpi here for now (change the file name from zutilo.zip to zutilo.xpi -- GitHub doesn't allow xpi's to be attached). zutilo.zip

EmmanuelCharpentier commented 7 years ago

Installed without a hitch. A limited test (a collection with 34 documents in my local library) was successfull.

This will be helpful. Massive reorganizations such as moving a website or re-organizing a large directory do happen from time to time. To be able to act on URLs as we do on local trees is a serious help in that task.

Thank you very much !

I plan to try that on a group library, then try on libraries as a whole I have probably about 10-12000 urls to update...). I'll kep you posted in case of problems, but I don't foresee any.

wshanks commented 7 years ago

Great. I hope it goes smoothly. I am curious how long it will take to update that many URL's. The current code modifies each URL with a separate transaction with the database. It could instead bundle all or a large chunk of URL's into one transaction. I don't know how much of a difference that makes with performance.

EmmanuelCharpentier commented 7 years ago

1) updating my ca. 10 000 links took no measurable time (three uses, since those were dispatched in three collections). Synchronizing to zotero.org was a horse of another color ;-)... 2) This version of zutilo did solve my problem withut a hitch. IMHO, all that is lacking for release is a) the translation of "Modify URLs" to the various languages supported for the UI, and b) documenting this facility somewhere

I think that this issue could be now closed, unless you want me to proceed to some other tests (hich I would happily do...).

Again, thank you very much for your work and your (impressive !) reactivity.

wshanks commented 7 years ago

Okay, thanks. I won't worry about the transactions then. I will close this issue after I have a chance to test in Zotero 4.0. I think I might have broken the function there with this change, and I'd like to keep backwards compatibility for a little bit longer.

wshanks commented 7 years ago

With 774d71ba99f464672f1a0f9c36560707b7d14ce2, this can now be closed.