Tutorial for developing zotero plugin

636 views
Skip to first unread message

林行众

unread,
Jan 9, 2020, 4:06:32 AM1/9/20
to zotero-dev

 Hi, I am a beginner in javascript and learning to develop a Zotero plugin. The Zotero is based on the Firefox platform, the documents about the Zotero plugin is out of date. At first, I try to use WebExtension to build a plugin, as I have posted a [thread](https://forums.zotero.org/discussion/80693/can-i-use-webextensions-to-build-a-plugin-for-zotero#latest). dstillman suggests me to use bootstrapped extension . I read the content in the above link and something about bootstrapped extension.  


Now I get stuck, I don't know how to build a toy plugin in XUL or bootstrapped. Can someone give me some links or references about developing Zotero plugin ? Some recommendations about development tools are also appreciated.


Best regards 

Lin

Emiliano Heyns

unread,
Jan 9, 2020, 10:00:37 AM1/9/20
to zotero-dev
If I recall correctly, bootstrapped extensions can't use xul. My own extensions are all xul based, mostly because how sample code looked when I got started, not because xul is intrinsically better than bootstrapped, there's pros and cons to both.

I have a yeoman generator that outputs a skeleton plugin + build tools, but it uses a javascript variant called typescript. This appeals to some (like me), not to others.

Dan Stillman

unread,
Jan 9, 2020, 10:27:08 AM1/9/20
to zoter...@googlegroups.com
On 1/9/20 4:06 AM, 林行众 wrote:

 Hi, I am a beginner in javascript and learning to develop a Zotero plugin. The Zotero is based on the Firefox platform, the documents about the Zotero plugin is out of date. At first, I try to use WebExtension to build a plugin, as I have posted a [thread](https://forums.zotero.org/discussion/80693/can-i-use-webextensions-to-build-a-plugin-for-zotero#latest). dstillman suggests me to use bootstrapped extension . I read the content in the above link and something about bootstrapped extension.  


Now I get stuck, I don't know how to build a toy plugin in XUL or bootstrapped. Can someone give me some links or references about developing Zotero plugin ? Some recommendations about development tools are also appreciated.


We'll try to update the Hello World plugin [1] (which is currently a XUL extension) soon to be a bootstrapped extension, but Zutilo [2] is an example of an existing bootstrapped extension.


[1] https://github.com/zotero/zotero-hello-world
[2] https://github.com/willsALMANJ/Zutilo

Emiliano Heyns

unread,
Jan 9, 2020, 11:29:01 AM1/9/20
to zotero-dev
Would there be a benefit (perhaps for the transition to electron) to convert to bootstrapped? If so, I need to run code when some panes load, how would I trigger that without using an overlay?

林行众

unread,
Jan 9, 2020, 8:21:57 PM1/9/20
to zotero-dev
I have downloaded Zutilo and Zotfile to figure out how to write a plugin. But I don't know Zutilo is a bootstrapped plugin. Thank you for your reply.

在 2020年1月9日星期四 UTC+8下午11:27:08,Dan Stillman写道:

林行众

unread,
Jan 9, 2020, 8:28:03 PM1/9/20
to zotero-dev
Thank you for your reply. I might as well try this Yeoman and how can I find a generator for Zotero plugin?

在 2020年1月9日星期四 UTC+8下午11:00:37,Emiliano Heyns写道:

Emiliano Heyns

unread,
Jan 10, 2020, 11:28:23 AM1/10/20
to zotero-dev
On Friday, January 10, 2020 at 2:28:03 AM UTC+1, 林行众 wrote:
Thank you for your reply. I might as well try this Yeoman and how can I find a generator for Zotero plugin?


The instructions on how to install and use it are on that page. After you do that, you can run "npm run build" and that will drop a read-to-install extension in the "xpi" directory. "npm version" will up the version number. There's more stuff in there to deploy beta and release builds automatically, but you needn't bother with that now.

Mind that this toolchain is very opinionated. You can use most npm modules, which I consider a plus, but it uses webpack and typescript, which is non-standard for Zotero plugins. It also does only XUL plugins right now. If you want to stay closer in line with the standard extension scaffolding, Dan's pointers (who is a Zotero developer; I am not affiliated with Zotero) are less opinionated.

林行众

unread,
Jan 13, 2020, 2:54:30 AM1/13/20
to zotero-dev
Thank you for the detial. I can not find some helpful development tools for bootstrapped addon. As a beginner, I wonder if there is something like scaffold, I can explore and test code, and then I found `Run JavaScript` in Zotero. Now I can try my JS code and get the result from the output.

在 2020年1月11日星期六 UTC+8上午12:28:23,Emiliano Heyns写道:
Reply all
Reply to author
Forward
0 new messages