PubPeerFoundation / pubpeer_zotero_plugin

Plugin to show if references in Zotero have PubPeer comments
149 stars 2 forks source link

More thorough comments? #15

Closed dchawisher closed 2 weeks ago

dchawisher commented 4 years ago

Would you consider commenting the code in the content folder? I know that your time is very limited and this is a free project, and ordinarily I would not even ask. But yours is the only plugin of which I am aware that adds tabs to the item pane. I would like to write a similar plugin (albeit much simpler: I just want a tab that displays the full text of notes), but doing so from scratch is beyond my abilities, and I'm struggling to understand your code.

retorquere commented 4 years ago

This is actually a feature Zotero inherited from its Firefox base; to add a tab on its own, no code is needed:

  1. register an overlay in the chrome.manifest
  2. In that overlay, the toplevel elements of the XML file that [have an ID]( ) will be merged with the Zotero xul mentioned in the chrome.manifest that has the same ID. All items that don't have such IDs (such as the scripts) will be merged at the end of the top level.

You have to dig around the Zotero source to find what XUL pane you want to overlay, but in your case it's most likely the itemPane: https://github.com/zotero/zotero/blob/ba92d244aa51481944743bb0f49c7b70838920fe/chrome/content/zotero/itemPane.xul

Unfortunately this technology is being phased out, the Mozilla documentation for this has languished so it's pretty hard to find info (it would not surprise me the only groups with in-depth knowledge are Zotero and some select people within Mozilla -- certainly not me), and when Zotero moves to Electron, all the things that interact with the UI will have to be redone. There's nothing yet on what it will look like, but it is certain it will not be XUL overlays.

While XUL lasts, I spend a lot of time googling and digging through the Zotero code, and I have a copy of "Programming Firefox: Building Rich Internet Applications with XUL" at hand. I have a physical copy because that works best for me, and it's cheap through bookfinder. If you prefer digital formats, those are available too.

dchawisher commented 4 years ago

Thank you for the advice. That book sounds very helpful, and I think I may even have a digital copy already. I'll check it out.

I personally am very much looking forward to the eventual switch to Electron. My understanding is that the UI will be in React after the switch, and although I'm hopeless with XUL, I do understand React pretty well.

retorquere commented 4 years ago

I'm pretty productive in XUL these days, and as to React, well...

retorquere commented 4 years ago

That's aside the fact that there's still no word on how plugins will integrate with the UI in the React implementation. Doesn't seem as easy as overlays are. But it is what it is.

dchawisher commented 4 years ago

You're so right about boilerplates and the architecture of react apps. For a novice like me, it is unreasonably difficult to even get react and electron working together. The only up-to-date boilerplate is that typescript-based one that integrates redux, and I've even had trouble getting that to build.

Is there a reason you didn't consider Prime React? They have every one of your basic features. Their table w/ controls is especially nice, as is their dropdown w/ search. It has theming. It also has all of your infrastructure reqs.

retorquere commented 4 years ago

My search didn't turn it up when I wrote that.

dchawisher commented 4 years ago

Hey, thanks again for your advice. I wound up modifying the existing Notes tab rather than create a new tab. I'm very happy with how it turned out.