https://github.com/zuphilip/bib
Translation and bibliography management for ZoteroBib
https://github.com/zuphilip/bib
Last synced: about 1 year ago
JSON representation
Translation and bibliography management for ZoteroBib
- Host: GitHub
- URL: https://github.com/zuphilip/bib
- Owner: zuphilip
- License: other
- Created: 2018-05-15T19:46:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-15T21:01:14.000Z (about 8 years ago)
- Last Synced: 2025-01-31T22:11:43.603Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://zbib.org
- Size: 3.82 MB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Zotero Bib
Overview
--------
Zotero Bib is a library that can process URLs into CSL-JSON bibliography items. It uses a translation server to translate URLs into a Zotero Items, optionally persisting these items, while also providing functionality to translate Zotero Items to CSL items on-demand.
Quick start
-------------
1. Install and start (translation server)[https://github.com/zotero/translation-server]
2. Configure the library to work with the translation server
```
let bib = new ZoteroBib({
persist: false,
translateURL: 'http://my-translation.server.example.com:1234'
});
```
3. Translate some urls
```
const [myPaper] = await bib.translateUrl('http://example.com/paper');
```
In-memory Storage
-----------------
Normally each call to `translateUrl` returns an item and also caches it in memory. Cached items can be retrieved at any time, either as Zotero Items:
```
const [myPaper] = bib.itemsRaw;
```
Or in [CSL-JSON](https://github.com/citation-style-language/schema) format:
```
const [myPaperAsCSL] = bib.itemsCSL;
```
This behaviour can be prevented using second, optional argument to `bib.translate`, i.e. calling `bib.translateUrl(url, false)` will return a translated item but won't store it anywhere.
Persistence
-----------
In the example above, after refreshing the page (or restarting a node script), all previosly translated, cached items are lost. If that's not desired behaviour, ZoteroBib accepts any (Web Storage)[https://developer.mozilla.org/en/docs/Web/API/Storage] compatible container for persistance. In fact, by default, it will attempt to use (Local Storage)[https://developer.mozilla.org/en/docs/Web/API/Window/localStorage] for persistence.
If you're running ZoteroBib in node, you'll either need to disable persistence (as in the example above) or provide your own Web Storage compatible container (e.g. (node-localstorage)[https://github.com/lmaccherone/node-localstorage]):
```
const LocalStorage = require('node-localstorage').LocalStorage;
const fileStorage = new LocalStorage('./my-citations');
let bib = new ZoteroBib({
storage: fileStorage,
translateURL: 'http://my-translation.server.example.com:1234'
});
```