Commit graph

43 commits

Author SHA1 Message Date
Dan Stillman
2cea1a50f5 Fix Translate.ItemGetter test
All we care about is whether annotations were excluded, so don't bother
counting all items.
2021-03-03 09:08:08 -05:00
Dan Stillman
79950ecfe5 Exclude annotations from library export
We'll want to support this eventually, but for now they would just break
translation.
2021-03-02 18:10:44 -05:00
Dan Stillman
55c6de23ba Add "Include Annotations" checkbox to export options dialog
This changes the attachment saveFile() function in translators to be
async. In order for errors to be properly caught, translators will need
to be changed to make doExport() async and await on saveFile() calls.
(The translation architecture theoretically already allows doExport() to
be async.)
2021-03-02 17:58:28 -05:00
Dan Stillman
4142f4b316 Replace occurrences of .getNote() with .note 2021-03-02 17:36:05 -05:00
Dan Stillman
b3220e83b1 Don't pass nested collections to translators as top-level collections
While we need to pass all items from descendant collections to
translators, only the immediate child collections of the selected
library or collection should be returned from Zotero.nextCollection().

I'm not sure how long we've been doing this wrong, but it resulted in
duplicated subcollections when round-tripping Zotero RDF. (TEI is the
only other translator that uses nextCollection(), so its exports were
probably similarly incorrect.)

https://forums.zotero.org/discussion/87135/export-import-creates-numerous-duplicate-subcollections
2021-01-25 03:58:04 -05:00
Dan Stillman
10ca05e22e Return array instead of iterator for Collection.getChildCollections(true) 2021-01-25 03:58:04 -05:00
Dan Stillman
433794916a Fx60: Remove instances of nsILocalFile
nsILocalFile was merged into nsIFile, so either replace it with that or
switch to Zotero.File.pathToFile().
2019-08-27 00:47:39 -04:00
Dan Stillman
9b82373f70 Add ability for Scaffold to provide alternative translators
Zotero.Translate::setTranslatorProviderMethods(methods) can be used to
provide custom 'get' and 'getAllForType' methods that override the
default Zotero.Translators methods.
2019-07-24 04:31:11 -04:00
Dan Stillman
04779d8d1c Add import option for storing or linking files
This allows files in Mendeley imports to be stored and files in
RIS/BibTeX/etc. to be linked.

Closes #329
2019-03-02 06:24:33 -05:00
Dan Stillman
8b4bb62efc Don't load linked URLs during import
Regression from 5a6a772ca2, I think
2019-01-26 00:20:26 -05:00
Dan Stillman
0d5abb018a Ignore invalid paths during export
Invalid paths, including Windows UNC paths on other OSes, caused exports
to fail. Now they're ignored, which is what we do for other missing
attachment files.

Fixes #1622
2019-01-12 02:34:31 -05:00
Dan Stillman
5a6a772ca2 Fix linked-URL attachments not being saved to groups without files
It looks like this may have been broken for years.
2019-01-08 03:45:26 -05:00
Dan Stillman
819be60796 Switch to XMLHttpRequest for processDocuments()
processDocuments() now uses an XHR 'document' request, wrapped to
provide a 'location' property, and uses promises for a simpler call
signature (though the old one will continue to work, for existing
translators). 'done' and 'exception' can now be handled via promises,
and in the translator sandbox an optional noCompleteOnError argument
instructs it not to automatically cancel the translation process with an
error (e.g., for supplementary materials).

Since we do need a hidden browser in some situations (e.g., for saving
snapshots), the old hidden-browser-based processDocuments() is still
available as Zotero.HTTP.loadDocuments().

This hopefully also fixes various problems with document property access
in translation-server.
2017-10-05 17:18:42 -04:00
Dan Stillman
0d3d4323b5 Fix relations import via translators
Fixes #1282
2017-09-22 01:02:50 -04:00
Dan Stillman
d80aa97ebd Restore related-items tests for Zotero.Translate.ItemGetter 2017-09-22 00:59:33 -04:00
Dan Stillman
6673c64ac6 Fix accessDate when translators set CURRENT_TIMESTAMP
(But it also seems like we always do that automatically for web
translators, so I'm not sure why so many translators set that.)
2017-08-19 15:21:57 +02:00
Dan Stillman
f7c1c56d7d Use 'async' configOptions property to indicate promisified translators
Instead of >"2017-07-05"

Addresses https://github.com/zotero/translators/issues/1353
2017-07-05 15:29:13 -04:00
Dan Stillman
198bd70b59 Make 909b4b31c8 apply to search translators too, and fix tests
Addresses https://github.com/zotero/translators/issues/1353
2017-07-05 09:15:12 -04:00
Dan Stillman
f12ae67c47 Test for e1986b460e (export with empty attachment path) 2017-05-14 05:26:39 -04:00
Dan Stillman
7c25093ca2 Fix various error propagation issues during translation
As noted in 27cb099c82, import translators should be rewritten to return
a promise from doImport() and wait for promises from successive
item.complete() calls. They should then be marked as minVersion: "5.0"
to be handled properly by this new code.

(But this tries to account, albeit with somewhat worse behavior, for
translators that haven't been rewritten and sandboxes without Promise
(which is currently the case with child sandboxes in the client).)

(Oh, and I haven't tested this at all in the connectors.)
2017-03-03 04:51:01 -05:00
Dan Stillman
4d56191f0c Fix importing of files using relative paths 2017-01-27 20:51:12 -05:00
Adomas Ven
747c11c917 Improves proxy support (#1129)
Improves proxy support

- Automatically detect and dehyphenise https proxies which use EZProxy
  HttpsHyphens
- Web translators now pass around Zotero.Proxy instances which can
  proxify/deproxify urls passed to `translate.setLocation()` before calling
  `translate.getTranslators()`/ translate.detect()`. The proxy passing is
  done within connector background/injected processes and between
  standalone and connectors.
- Proxy protocol unified with connectors. Connectors can now pass
  proxies to `/connector/save_items`. The proxies will be used to resolve
  true item and attachment urls when saving.

Closes zotero/zotero#578, zotero/zotero#721

Relevant zotero/zotero#34, zotero/zotero#556
2016-12-12 14:29:59 +02:00
Dan Stillman
78b1d2ee35 Import translation improvements
- Don't block the UI with a progress meter during imports. Instead, show
  a popup in the bottom right when the import is done that shows how
  many items were saved.
- Fix hang when importing some files
- Fix various problems with asynchronous operations/transactions
    - Use the save queue for imports instead of creating concurrent
      transactions that can time out
    - Wait for the save to finish before returning from the translate()
      promise. All save modes now use the save queue, so code that
      handled the non-save-queue process can probably be removed.
    - Serialize child attachments instead of running them concurrently.
      This might make multi-attachment saves a little slower, since they
      can't download at the same time, but it avoids problems with
      concurrent transactions. We might be able to improve this to allow
      concurrent downloads, or allow concurrent saves for a limited
      number of items (e.g., from web saving) if not for larger imports.
- Change collection handling during import, since UI is now active
  - Select the root collection at the beginning of the import
  - Assign items and collections to the root during the import instead
    of at the end
  - Don't select other collections
- Change a few ItemSaver functions to use promises and remove
  unnecessary callbacks. (This includes some connector code that needs
  to be tested.)
- Change some `parentID` variables in ItemSaver to `parentItemID` for
  clarity, since collections are now handled in more places

To-do:

- Save items in smaller batches instead of doing all in the same
  transaction
- Show progress meter in a bottom-right popup during the import
2016-12-11 02:30:34 -05:00
Dan Stillman
9fbd84b27e Move ItemGetter test to correct section 2016-12-09 06:30:38 -05:00
Dan Stillman
c7700f2b96 Fix warning in translate test 2016-11-22 19:06:47 -05:00
Dan Stillman
341d3d69b3 Fix export failure on missing file attachments
This relies on synchronous file access, but making it async would require
rewriting all export translators that save files.
2016-10-25 02:36:13 -04:00
Adomas Venčkauskas
5d17ff3f53 Implements #1021 on Z4fx extension 2016-09-27 17:43:56 +03:00
Adomas Venčkauskas
7608e127f1 Fix nested translators that rely on child translator tags 2016-09-21 11:54:56 +03:00
Adomas Venčkauskas
e83bbbad4e Fix getTranslatorCode bugs
- /connector/getTranslatorCode used to respond with empty content
- CodeGetter froze connectors by issuing hundreds of simultanious XHR
  requests
2016-09-20 15:55:58 +03:00
Dan Stillman
dbd81528d3 Fix another intermittent test failure from translator initialization 2016-08-25 12:41:18 -04:00
Dan Stillman
42968949b6 Fix collection export
Closes #734, maybe?
2016-03-21 18:11:30 -04:00
Dan Stillman
51b286528c Fix export translation
This reverts Zotero.Translate.ItemGetter.prototype.nextItem() to being
synchronous post-deasyncification. This will need to be made to work
asynchronously in the future if _attachmentToArray(), which is called by
nextItem, is changed to use async file access (which might be required
at some point).

Addresses #734, [Async DB] Import/export fails
2016-03-20 23:39:12 -04:00
Dan Stillman
394aa8dded Update display title after item edit 2016-03-11 09:25:33 -05:00
Dan Stillman
daf4a8fe4d Deasyncification 🔙 😢
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).

What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.

The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).

If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 17:03:58 -05:00
Aurimas Vinckevicius
38b9bbc8c8 Fix Translate tests on Windows 2015-09-21 17:08:22 -05:00
Dan Stillman
037bc07a3c Fix timeout on Travis loading 'allTypesAndFields' data 2015-06-11 02:19:49 -04:00
Simon Kornblith
70f021f945 Use ISO 8601 accessDates everywhere
This uses ISO 8601 dates for generateAllTypesAndFieldsData (and
changes populateDBWithSampleData to use Item#fromJSON), and makes
translators expect ISO 8601 accessDates, although SQL accessDates are
still supported with a deprecation warning. Canonicalization happens in
Zotero.Translate, so I need to remember to update connectors as well.
2015-06-07 18:50:57 -04:00
Simon Kornblith
3fc38d750b Use Zotero.Item.fromJSON() for saving from translators
Also:
  - Move some canonicalization of items returned by translators to
    Zotero.Translate
  - Make Zotero.Translate#translate return a promise
  - Add tests
2015-06-07 17:30:41 -04:00
Dan Stillman
77f12527aa Fix NS_BASE_STREAM_CLOSED error, for real
The input stream produced by asyncFetch is closed automatically at EOL,
so the available() call throws this for an empty file.
2015-06-02 14:58:43 -04:00
Dan Stillman
ee777c5be6 Enable logging for NS_BASE_STREAM_CLOSED error 2015-06-02 05:11:40 -04:00
Dan Stillman
c2e7b8ccc0 A couple Zotero.Translate.ItemGetter test fixes 2015-06-01 06:12:11 -04:00
Simon Kornblith
9bb01d737c Merge branch '4.0' into sjk/659 2015-06-01 00:03:20 -04:00
Aurimas Vinckevicius
1d1eb74e57 Add tests for Zotero.Translate.ItemGetter.prototype.nextItem 2015-05-26 16:11:43 -05:00