Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes zotero/translators#3124 by adding translator for TinRead #3223

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

franklindyer
Copy link
Contributor

See discussion of zotero/translators#3124. Added TinREAD.js which acts as a basic translator for TinRead records using exportable MARCXML files. Could probably still use some tweaking...

}

async function scrape(doc, _url = doc.location.href) {
doc.getElementById("DirectLink").click();
Copy link
Member

@dstillman dstillman Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't rely on direct interaction with the webpage. While that will work in some current environments, it won't work in all environments (e.g., translation-server) and generally won't be possible in browsers in the future. So for a case like this, you'd want to figure out what the click kicked off and replicate that in code (which would also avoid an unseemly hard-coded delay).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MARCXML export URL looks like /marcexport.svc?enc=UTF-8&fmt=xml&id=203393&items=none&marc=Current&type=bib, so we can probably just substitute in the current item ID, which is in the URL after /bibliographic_view/.

Copy link
Member

@AbeJellinek AbeJellinek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking good! Some comments/suggestions.

TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
}

async function scrape(doc, _url = doc.location.href) {
doc.getElementById("DirectLink").click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MARCXML export URL looks like /marcexport.svc?enc=UTF-8&fmt=xml&id=203393&items=none&marc=Current&type=bib, so we can probably just substitute in the current item ID, which is in the URL after /bibliographic_view/.

TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
TinREAD.js Show resolved Hide resolved
franklindyer added 2 commits January 11, 2024 13:34
- changed label to include "Library Catalog"
- improved regex for matching URL
- added a few lines to `detectWeb` to allow for early failure
- stylistic changes
@franklindyer
Copy link
Contributor Author

@AbeJellinek Thanks for all the feedback! I've implemented just about all of your suggestions, but the search page test is giving me a bit of trouble. I added a test, but it's currently failing with this opaque error message every time:

15:01:37 Translation using Library Catalog (TinREAD) failed: 
         Error: DOMParser error: loading data into data store failed
         
         Error: DOMParser error: loading data into data store failed
             parseDOMXML@chrome://zotero/content/xpcom/translate/src/translation/translate.js:2771:10
             getXML@chrome://zotero/content/xpcom/translate/src/translation/translate.js:2883:14
             importObject/attachTo[key]</<@chrome://zotero/content/xpcom/translation/translate_firefox.js:451:20
             doImport/<@chrome://zotero/content/xpcom/translation/translate_firefox.js line 425 > eval:59:13
             loadTranslator/safeTranslator.getTranslatorObject/promise<@chrome://zotero/content/xpcom/translate/src/translation/translate.js:414:21
         From previous event:
             loadTranslator/safeTranslator.translate@chrome://zotero/content/xpcom/translate/src/translation/translate.js:381:12
             scrape@chrome://zotero/content/xpcom/translation/translate_firefox.js line 425 > eval:100:8
         url => https://opac.biblioteca.ase.ro/opac/search?q=wirtschaftstheorie&max=0&view=&sb=relevance&ob=asc&level=all&material_type=all&do_file_type=all&location=0
         downloadAssociatedFiles => true
         automaticSnapshots => true

Not sure what this means, but I'll continue trying to troubleshoot.

It may be that I don't understand the search page tests very well in general. The example given in the docs here seems to suggest that a test case for a search page can consist of no more than a check that "multiple" was correctly returned as the detected type, but the desired functionality is to provide the user with a list of results from which to select, which is more than this kind of test case checks for. Is it normal to have this minimal of a test case for search pages?

@franklindyer
Copy link
Contributor Author

franklindyer commented Jan 18, 2024

Because of the debacle with issue #3225 I decided to try rerunning the search page test in Zotero 7 and... this time it worked! Huzzah!

Library Catalog (TinREAD).js Show resolved Hide resolved
Library Catalog (TinREAD).js Show resolved Hide resolved
Library Catalog (TinREAD).js Outdated Show resolved Hide resolved
franklindyer and others added 3 commits January 22, 2024 15:30
Co-authored-by: Abe Jellinek <jellinek@berkeley.edu>
Co-authored-by: Abe Jellinek <jellinek@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants