Skip to content

Commit 813d442

Browse files
committed
readme
1 parent 7464106 commit 813d442

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,85 @@
22

33
A tool to manage bibliography when collaboratively working on a LaTeX paper.
44

5+
# Setup
56

7+
TL;DR:
8+
* Create a Git repo containing `main.bib` and `tokens.json`, that can be pushed/pulled without credentials (e.g., using an access token)
9+
* Add a push webhook to notify your server on changes to the repo
10+
* Start the docker container with the server
11+
12+
## Client
13+
The client is a simple Python 3 script that only requires three dependencies: `bibtexparser`, `requests`, and `argparse`.
14+
They can simply be installed using pip: `pip3 install -r requirements.txt`.
15+
16+
## Bibliography
17+
The bibliography is stored in a Git-versioned repository to be able to track (and revert) changes.
18+
The repository also contains the access tokens required by the clients to interact with the server.
19+
20+
### Bibliography File
21+
The bibliography file has to be in a Git repository where the server can pull from and push to.
22+
The easiest way is to create an access token in GitHub, GitLab, or Gogs and use this access token to clone the repo over HTTPS (`git clone https://<token>@github.com/owner/repo.git`).
23+
The bibliography file has to be named `main.bib`.
24+
25+
### Authentication
26+
Authentication is handled via tokens defined in `tokens.json`. The file has the following format:
27+
```
28+
{
29+
"token1": {
30+
"search": true,
31+
"read": true,
32+
"write": true,
33+
"delete": true
34+
},
35+
"token2": {
36+
"search": true,
37+
"read": true,
38+
"write": false,
39+
"delete": false
40+
}
41+
}
42+
```
43+
For each request to the server, the client has to provide a token.
44+
The server can then check whether the client is allowed to perform the requested action.
45+
The permissions are:
46+
* `search`: Search for bibliography entries containing a certain string
47+
* `read`: Get a bibliography entry based on an identifier
48+
* `write`: Add or modify bibliography entries
49+
* `delete`: Delete bibliography entries
50+
51+
## Server
52+
The server runs inside a Docker container and works on a Git-versioned bibliography file outside the container.
53+
A webhook ensures that manual edits of the bibliography file and authentication-token file are propagated to the server.
54+
55+
### Webhook
56+
To allow manual changes to the bibliography file or the authentication tokens without having to restart the server, it is necessary to configure a webhook.
57+
The webhook has to send a notification to `<your bib server>/v1/webhook` on push events. There is no secret token required.
58+
59+
### Run Server
60+
* Build the Docker container: `docker build --tag bibtool .`
61+
* Start the Docker container: `docker run -p 5000:5000 -v <path to bibliography folder>:/data bibtool`
62+
63+
By default, the server runs on port 5000.
64+
65+
# Usage
66+
67+
The general workflow of using BibTool is the following.
68+
The client parses the TeX file to extract all citation keys, sends them to the server, and stores the corresponding bibliography entries in `main.bib`.
69+
70+
## Getting a bibliography file
71+
The client is simply invoked by running `python3 client.py get --server <your bib server>`.
72+
The name of the authentication token can either be stored in the file `token` in the same folder, or it can alternatively be provided using the `--token <tokenname>` parameter.
73+
The LaTeX file is assumed to be named `main.tex`. This can be changed with the `--tex <latex file>` parameter.
74+
75+
If a key is not found, and the bibliography file was not modified locally, the server returns suggestions for similar keys.
76+
In case the bibliography entry was added locally, the entry is added to the bibliography repository.
77+
If there is a collision, i.e., the same key exists locally and remotely, the user has to decide how to handle the situation (abort, overwrite server entry with local entry, discard local entry and get server entry).
78+
Hence, adding or modifying bibliography entries is as simple as adding or modifying them and rerunning the client.
79+
80+
## Searching for bibliography entries
81+
The client also supports searching for entries: `python3 client.py search --query <search query> --server <your bib server>`.
82+
If multiple queries are provided, all of them have to match.
83+
Note that each query has to be at least 3 characters long.
84+
85+
## Automatically Update
86+
The client supports automated updates. If the version number of the client is lower than the one provided by the server, the client automatically fetches the new client from the server and restarts itself.

0 commit comments

Comments
 (0)