Web translator: detectWeb and single page apps

22 views
Skip to first unread message

Dan Michael O. Heggø

unread,
Oct 15, 2017, 6:49:41 AM10/15/17
to zotero-dev
Hi,

I'm trying to fix the translator for www.nb.no after the site was revamped into a single page app. Now all the metadata is loaded using XHR requests and there's nothing embedded in the HTML initially to be scraped.

For doWeb I'm fine since I can do my own XHR requests there, but with detectWeb I'm having a hard time detecting the document type. Eventually metadadata is injected into meta tags in the page by JavaScript, but I'm not sure if this either happens after detectWeb runs or just that the page fails to load within Scaffold. At least, pages don't render correctly in Scaffold.

Could I give up the type detection in detectWeb, making it always return "document", and then leave it to doWeb to find the correct document type? In Scaffold, this causes "Detection returned wrong item type" when running tests, so I'm a bit discouraged by that. Is there some other way in detectWeb to tell Zotero that "there is some kind of document here, but we don't yet know the type"? Or perhaps I could attack this in a different way?



Dan Michael


Sebastian Karcher

unread,
Oct 15, 2017, 10:20:24 AM10/15/17
to zoter...@googlegroups.com
I haven't looked at the page, but are you aware of Z.monitorDOMChanges as used here? https://github.com/zotero/translators/blob/52b86a9c23cb5b37210505caa594ebdb3a0464c2/Engineering%20Village.js#L16
 
that sounds like it'd work her. Otherwise (though very much second best), yes, we'd accept a translator that detects a generic item type even if that's not always correct. Given that it's a library, book would seem like the obvious choice and you could just pick test cases for books so the tests go through -- not ideal, but it'd at least detect general breakage.
 
Gesendet: Sonntag, 15. Oktober 2017 um 06:49 Uhr
Von: "Dan Michael O. Heggø" <d.m....@ub.uio.no>
An: zotero-dev <zoter...@googlegroups.com>
Betreff: Web translator: detectWeb and single page apps
--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To post to this group, send email to zoter...@googlegroups.com.
Visit this group at https://groups.google.com/group/zotero-dev.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages