1. 程式人生 > WINDOWS開發 >Zotero: add a history feature for paper viewing

Zotero: add a history feature for paper viewing

During my time with Zotero,I‘ve really enjoyed its various features and the 300MB of file sync space is able to be extended by modifying the path to a synchronized folder under oneDrive or dropBox. reference: Extending Zotero‘s syncing folder size by DropBox

However,I often get lost when jumping between papers. After jumping from paper A to paper B,I am unable to go back to paper A if I forget its name.

I wish I could write an extension to add a history feature for paper viewing. In the official documentation,I didn‘t find a way to build extension (how to generate a .zoteroplugin from source code?) for Zotero 5.0. And I failed at compiling and installing the the source code for the hello-world-zotero

extension,on Zotero 5.0.

Fortunately,with Zotero 5.0‘s javascript API,I‘ve managed to implement a way of Manually logs the history of the papers viewed. It‘s not quite user friendly yet,but it barely works.

If you know how to do this via extension,drop me a comment,thanks!


我在使用Zotero期間,非常喜歡它的各種功能,並且300MB的檔案同步空間也可以通過修改路徑擴充套件到oneDrive或dropBox等檔案同步伺服器上。

但是,我在論文間跳轉時,常常會迷失方向。從A論文跳轉到B論文後,無法回退至A論文。

我希望可以寫一個擴充套件程式來增加論文檢視的歷史記錄功能。由於我並沒有在官方文件中找到Zotero5.0的擴充套件程式build方法,我失敗於將hello-world-zotero擴充套件的原始碼進行編譯並安裝進Zotero5.0.

還好,我通過 Zotero 5.0 的 javascript API,勉強實現了一個手動的記錄所瀏覽的paper的歷史記錄。它還不太友好,但勉強能用。

如果你知道如何通過擴充套件來實現,請給我留言,謝謝!

使用環境:

Zotero v5.0.87
tested on Mac OSX 10.15.4
windows user can try the same way and comment on how it works. thx!

使用方法:

Zotero -> Tools -> Develop -> Run javascript

step1. 先執行第1段程式碼,進行變數的初始化:Initialize the variable by executing the first patch of code:

//=== initialize the history ====
var items = Zotero.getActiveZoteroPane().getSelectedItems();
var cur_itemKey = items[0].key;
var tmp_key = cur_itemKey;
var key_paper_list = ‘List of keys of papers your selected:\n‘;
cur_itemKey += ‘\n‘;

step2. 然後將第1段程式碼替換成第2段程式碼: then replace the first patch of code with the below.

//==== run above once,and modify above 5 lines into: ====
items = Zotero.getActiveZoteroPane().getSelectedItems();
cur_itemKey = items[0].key + ‘\n‘;
if(items[0].key !=tmp_key){
	tmp_key = items[0].key;
	key_paper_list += cur_itemKey;
}
else{
    key_paper_list += ‘‘;
}

step3. 回到Zotero主介面,進行論文瀏覽,每切換一次論文,就回到Run javascript介面執行一次第2段程式碼,進行歷史記錄。Return to the Zotero main screen and browse papers,returning to Run every time you switch papers. The javascript interface executes the 2nd code once to make a history.

step4. 通過搜尋,直接輸入key即可回溯瀏覽記錄。go back through the browsing history by searching and entering the key directly.

Tips:

on Mac OSX,use Command+` to switch between javascript running interface and Zotero paper viewing interface.

參考:Reference:

Zotero JavaScript API
Zotero Source Code