zotero / translation-server

A Node.js-based server to run Zotero translators
Other
122 stars 51 forks source link

Redirected URLs aren't used for target comparison or detectWeb()/doWeb() #21

Closed mvolz closed 6 years ago

mvolz commented 6 years ago

Doesn't get the right metadata from this url, probably has something to do with the fact that there's a redirect here. But it does get partial metadata (unlike translation-server, which won't get any) so the behaviour is different between the two.

curl -d '{ "query": "http://www.journals.cambridge.org/abstract_S0305004100013554" }' -H 'Content-Type: application/json' http://127.0.0.1:1969/search

[{"key":"R7QFA7AQ","version":0,"itemType":"webpage","creators":[{"firstName":"E.","lastName":"Schrödinger","creatorType":"author"}],"tags":[],"title":"Discussion of Probability Relations between Separated Systems","websiteTitle":"Mathematical Proceedings of the Cambridge Philosophical Society","url":"/core/journals/mathematical-proceedings-of-the-cambridge-philosophical-society/article/discussion-of-probability-relations-between-separated-systems/C1C71E1AA5BA56EBE6588AAACB9A222D","abstractNote":"<div class=\"abstract\" data-abstract-type=\"normal\">

The probability relations which can occur between two separated physical systems are discussed, on the assumption that their state is known by a representative in common. The two families of observables, relating to the first and to the second system respectively, are linked by at least one match between two definite members, one of either family. The word match is short for stating that the values of the two observables in question determine each other uniquely and therefore (since the actual labelling is irrelevant) can be taken to be equal. In general there is but one match, but there can be more. If, in addition to the first match, there is a second one between canonical conjugates of the first mates, then there are infinitely many matches, every function of the first canonical pair matching with the same function of the second canonical pair. Thus there is a complete one-to-one correspondence between those two branches (of the two families of observables) which relate to the two degrees of freedom in question. If there are no others, the one-to-one correspondence persists as time advances, but the observables of the first system (say) change their mates in the way that the latter, i.e. the observables of the second system, undergo a certain continuous contact-transformation.

","date":"1935/10","language":"en","accessDate":"CURRENT_TIMESTAMP","extra":"DOI: 10.1017/S0305004100013554"}]

dstillman commented 6 years ago

Yeah, this is because of the redirect, and the same thing happened in v1, so this isn't a blocker for v2. (v1 does get the same fallback metadata, by the way. I assume you're just testing with the very old version of translation-server in use at WMF, which didn't fall back to other translators.)

This isn't an issue in Zotero proper because the browser redirects before you can save, and it generally won't be an issue for most uses of translation-server either because most people will be pasting in URLs from a browser.

The NPM 'request' package that we're using in v2 follows redirects automatically by default, but the translator doesn't get any info on the new URL, so detection fails. We may be able to fix this by passing a function to the followRedirect option to get the new URL and then using that for target comparison and detectWeb()/doWeb().

adomasven commented 6 years ago

Whoops, closed the wrong issue

mtrojan-ub commented 6 years ago

It might not be a good idea to follow all meta redirects.

Some redirects could be a logout page: https://www.sitepoint.com/community/t/automatic-logout-after-inactive-for-15-minutes/3538/8 https://github.com/zotero/translation-server/commit/aa7179e3ced515ce104b5ad4a666941023da3aa9

What do you think about only following the redirect if the defined timespan is less than 100 seconds or so?

dstillman commented 5 years ago

@mtrojan-ub: Good call. https://github.com/zotero/translation-server/commit/5b60d9ba1bcc67cd2ff0243dbf58d2cbbf566f88