Skip to content

tridoc/tridoc-backend

Repository files navigation

tridoc

Server-side infrastructure for tridoc: easy document management for individuals and small teams.

Table Of Contents

Setup

This will setup tridoc on port 8000 and fuseki avaliable on port 8001. Make sure you have docker-compose installed.

Replace YOUR PASSWORD HERE in the first command with your choice of password.

Unix/Linux/wsl:

export TRIDOC_PWD="YOUR PASSWORD HERE"
docker-compose build
docker-compose up

On windows, relpace the first line with:

$env:TRIDOC_PWD = "YOUR PASSWORD HERE"

For more Setup options see the DEV-README.md

Tag System

There are two types of tags: simple tags and parameterizable tags. Parameterizable tags need a parameter to become a parameterized tag wich can be added to a document.

Simple Tags

Simple tags can be created by POST to /tag. You need to send an JSON object like this:

{"label": "Inbox"}

Note: label must be unique.

The label must not contain any of the following: whitespace, /, \, #, ", ', ,, ;, :, ?;
The label must not equal . (single dot) or .. (double dot).

Tags can be added to a document by POST to /doc/{id}/tag. You need to send an JSON object like the one above.

Tags must be created before adding them to a document.

Parameterizable & Parameterized Tags

Parameterizable tags can be created by POST to /tag too. You need to send an JSON object like this:

{
    "label": "Amount",
    "parameter": {
        "type":"http://www.w3.org/2001/XMLSchema#decimal"
    }
}

Again, label must be unique.
parameter.type can either be http://www.w3.org/2001/XMLSchema#decimal or http://www.w3.org/2001/XMLSchema#date .

Parameterizable tags can only be added to a document with a value assigned. By POSTing a JSON object like the following to /doc/{id}/tag, a parameterized tag is created and added to the document.

{
    "label": "Amount",
    "parameter": {
        "type":"http://www.w3.org/2001/XMLSchema#decimal",
        "value":"12.50"
    }
}

A parameterizable tag with this label and parameter.type has to be created before.

Comments

Tags can be added to a document by POST to /doc/{id}/comment

You can either send an JSON document like the following

{
    "text": "This is a comment"
}

When getting a comment, a JSON array with objects of the following structure is provided:

{
    "text": "This is a comment",
    "created": "2020-03-12T10:07:20.493Z"
}

API

Address Method Description Request / Payload Response Implemented in Version
/count GET Count (matching) documents 1 3 Number 1.1.0
/doc POST Add / Store Document PDF5 - 1.1.0
/doc GET Get List of all (matching) documents 1 2 3 Array of objects with document identifiers and titles (where available) 1.1.0
/doc/{id} GET Get this document - PDF 1.1.0
/doc/{id} DELETE Deletes all metadata associated with the document. Document will not be deleted and is stays accessible over /doc/{id}. - - 1.1.0
/doc/{id}/comment POST Add comment to document Comment object / See above - 1.2.0
/doc/{id}/comment GET Get comments - Array of comment objects 1.2.0
/doc/{id}/tag POST Add a tag to document Tag object / See above - 1.1.0
/doc/{id}/tag GET Get tags of document - Array of tag objects 1.1.0
/doc/{id}/tag/{tagLabel} DELETE Remove tag from document - - 1.1.0
/doc/{id}/thumb GET Get document thumbnail - PNG (300px wide) 1.5.0
/doc/{id}/title PUT Set document title {"title": "the_Title"} - 1.1.0
/doc/{id}/title GET Get document title - {"title": "the_Title"} 1.1.0
/doc/{id}/title DELETE Reset document title - - 1.1.0
/doc/{id}/meta GET Get various metadata - {"title": "the_Title", "tags":[...], "comments": [...] ... } 1.1.0 | .comments & .created in 1.2.1
/raw/rdf GET Get all metadata as RDF. Useful for Backups 4 RDF, Content-Type defined over request Headers or ?accept. Fallback to text/turtle. 1.1.0
/raw/zip or /raw/tgz GET Get all data. Useful for backups - ZIP / TGZ containing blobs/ directory with all pdfs as stored within tridoc and a rdf.ttl file with all metadata. 1.3.0
/raw/zip PUT Replace all data with backup zip ZIP Replaces the metadata and adds the blobs from the zip 1.3.0
/tag POST Create new tag See above - 1.1.0
/tag GET Get (list of) all tags - - 1.1.0
/tag/{tagLabel} GET Get Documents with this tag. Same as /doc?tag={tagLabel} 1 2 Array of objects with document identifiers and titles (where available) 1.1.0
/tag/{tagLabel} DELETE Delete this tag - - 1.1.0
/version GET Get tridoc version - semver version number 1.1.0

URL-Parameters supported:

1 : ?text
2 : ?limit and ?offset

3 : ?tag and ?nottag
Since 1.4.4, filtering for Tag Ranges is possible with the following syntax: …={label};{min};{max}. min or max may be ommitted for unbounded search. Trailing semocolons may be omitted. Example:

…?tag=foo;;30&tag=bar;2020-01-01;2020-12-31

gives all that have tag foo with a value <= 30, and bar values within 2020.

Be aware that this may need replacing of the caracter ; by %3B.

4 : ?accept
5 : ?date followed by an ISO 8601 date string including time and timezone, seconds optional, sets creation date

Deleting / editing comments might be supported in the future