[Jurism dev query] SingleFile and translator workflow

41 views
Skip to first unread message

Frank Bennett

unread,
Dec 1, 2020, 11:56:08 PM12/1/20
to zotero-dev
Before the new browser connectors came out, I added a translator-accessible utility function to Jurism for snipping an element out of the current DOM and building a fresh HTML attachment from it. IIRC the new connectors were unable to pass a DOM object through to Zotero's item save machinery, and the issue went on the todo list for future development.

Would the deployment of SingleFile for page saves now mean that saving a translator-generated DOM object is again possible?

Frank @ Jurism

Dan Stillman

unread,
Dec 4, 2020, 1:15:06 AM12/4/20
to zoter...@googlegroups.com
Yes, we now have a mechanism for passing arbitrary HTML. (We now save
the rendered DOM from the browser rather than redownloading the page in
Zotero. You can even now modify a webpage with another extension or the
devtools and save it to Zotero, and the snapshot will reflect the
modified DOM.)

Fletcher, who worked on the SingleFile integration, can say more on the
technical side of this, but I think the /connector/saveSingleFile
endpoint in server_connector.js is what you'd want to use.

Frank Bennett

unread,
Dec 4, 2020, 1:37:56 AM12/4/20
to zotero-dev
Excellent. Ideally I'd like to restore the helper method previously used by Jurism to clip content from primary source documents (law cases and statutes).

I'm still trying to get my head around the workflow for attachment saves, and I'm having some trouble getting Zotero.debug() comments to show up in browser or client logs. Any pointers on that, and on where the DOM can be modified, would be really helpful!

Frank

Dan Stillman

unread,
Dec 4, 2020, 5:19:35 AM12/4/20
to zoter...@googlegroups.com
On 12/4/20 1:37 AM, Frank Bennett wrote:
> I'm still trying to get my head around the workflow for attachment
> saves, and I'm having some trouble getting Zotero.debug() comments to
> show up in browser or client logs.

If you're referring to connector code, you need to view the background
page for the extension to see the debug output. (I find Chrome much
easier to work with here than Firefox, though it's possible in both. In
Chrome you can open it from the Extensions pane in developer mode.)

> Any pointers on that, and on where the DOM can be modified

I was just pointing out that we now capture the rendered DOM in the
browser, which implies sending arbitrary HTML, as opposed to
redownloading the webpage in the app. You can send whatever HTML you
want to the /connector/saveSingleFile endpoint.

Frank Bennett

unread,
Dec 4, 2020, 5:50:44 AM12/4/20
to zoter...@googlegroups.com
Thanks! I had shifted to Chrome, will push further.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/010001762d438fbb-ee337c65-e002-485b-a47e-64cc8f3c2db7-000000%40email.amazonses.com.

Fletcher Hazlehurst

unread,
Dec 4, 2020, 4:42:43 PM12/4/20
to zoter...@googlegroups.com
Hi,

Fletcher here. The workflow is a little bit weird because it went through a number of iterations, but generally you call either /connector/saveItems or /connector/saveSnapshot to save the top-level item and then call /connector/saveSingleFile to save the actual HTML content as an attachment to the first item saved. As it is written now, you need an existing session from one of those first two endpoints to save the attachment. There is also a little bit of communication in the response body of the first call to check whether both the connector side and the client side support saving in that manner.

Here is the saveSnapshot in the connector:


And here is saveItems:


Hopefully that helps a little. Let me know if you have any other questions.



On Fri, Dec 4, 2020 at 3:50 AM Frank Bennett <bierc...@gmail.com> wrote:
Thanks! I had shifted to Chrome, will push further.

On Friday, December 4, 2020, Dan Stillman <dsti...@zotero.org> wrote:
On 12/4/20 1:37 AM, Frank Bennett wrote:
I'm still trying to get my head around the workflow for attachment saves, and I'm having some trouble getting Zotero.debug() comments to show up in browser or client logs.

If you're referring to connector code, you need to view the background page for the extension to see the debug output. (I find Chrome much easier to work with here than Firefox, though it's possible in both. In Chrome you can open it from the Extensions pane in developer mode.)

Any pointers on that, and on where the DOM can be modified

I was just pointing out that we now capture the rendered DOM in the browser, which implies sending arbitrary HTML, as opposed to redownloading the webpage in the app. You can send whatever HTML you want to the /connector/saveSingleFile endpoint.

--
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.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/CAJgpGgDDaQzQhXsOqLmBcW_%2BL980ZeYuHz-G-Sh4%3DkMcW2%2BcoA%40mail.gmail.com.

Frank Bennett

unread,
Dec 4, 2020, 7:23:49 PM12/4/20
to zotero-dev
Dear Fletcher & Dan,

Thanks for this, it's now very clear.

(It will surprise no none that the local translator I was using for trials had a stupid error that caused it to bypass SingleFile altogether. Comments are coming through in the connector log just fine.)

Looking forward to getting the core Jurism US translators back in shape!

Frank
Reply all
Reply to author
Forward
0 new messages