summaryrefslogtreecommitdiff
path: root/README.md
blob: 2476df67cebd9956aadd0ed5eed308cc1dcf78b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# бирка-тян: электронная доска объявлений

_В вашем деле нет пометки об этом!_

бирка-тян (birka-tyan) is a lightweight Danbooru-style imageboard engine for the
purposes of self-hosting a tagged image gallery. It lacks many of the features
one would expect of such an application (particularly use rauthentication), so
if you have a use case other than being able to search through your pictures
when you are not at home, you would be better off looking at an established
solution such as [Danbooru](https://github.com/danbooru/danbooru).

## Features

- A command-line tool for interacting with the tag database.

## Usage

### Command-Line

There are two ways of interacting with бирка-тян: through the `birka-cli`
command-line tool (i), and through the web interface (ii).

The inclusion of (i) is in consideration for this being, essentially, a personal
image gallery. One likely has a loosely-organized collection of images already;
the command-line tool enables her to import images en masse with the full
capabilities of the Unix shell at her fingertips. A brief summary of the
command-line interface follows.

Images are introduced to the database with the `add` command, which takes zero
or more tags following the path of an image. The path is automatically
canonicalized, so relative names are perfectly acceptable.

```sh
$ birka-cli add Cat.jpeg animal cat cute
```

Ah, drat. We should have tagged that image with "photograph", too.

```sh
$ birka-cli add_tags Cat.jpeg photograph
```

On second thought, that wasn't a particularly cute picture.

```sh
$ birka-cli remove_tags Cat.jpeg cute
```

Now, let's see all of the photographs in the tag database tagged with
"photograph".

```sh
$ birka-cli query photograph
/home/jakob/Camera/Cat.jpeg
```

The `query` command outputs a line-separated list of paths to any images
satisfying the query string. The semantics are similar to that of Danbooru,
except that the logical disjunction operator ('~') is unsupported. As a
convenience, the 'query' command can be invoked without a query string, to list
all paths indexed by the database.

```sh
$ birka-cli query
...
```

### Web-Interface (API)

The web interface for бирка-тян exposes a RESTful API for remotely interacting
with the tag database. At the time of writing, this API is __not__ stabilized.
Expect to rewrite any code depending on this API in the near future, in part
because these will all be put behind a `/v1/` specifier.

Suppose we denote the following shape of JSON object as a `ImageResult`.

```
{
  "id": number,
  "filename": string,
  "thumb_filename": string,
  "orig_filename": string,
  "tags": [string, ...],
}
```

The images in the tag database can be enumerated with the 'posts' endpoint,
which takes two parameters: `tags`, a comma-separated list of zero or more
strings, and `last`, which is the last `ImageResult` identifier which was seen.
This endpoint will return, at most, 50 entries, which is why the `last`
parameter is necessary.

```
GET /api/posts?last=number,tags=[string, ...]

[zero or more ImageResult]
```

Information about a specific image in the database can be obtained with the
following endpoint, where `id` is the identifier (number) of the image in the
database:

```
GET /api/posts/[id]

ImageResult
```

To add tags to an image, POST a comma-separated list of new tags to the same
endpoint.

To upload an image to the database, post a multipart/form-data encoded message
to the following endpoint with the following fields: `tags`, a comma-separated
list of tags for the files, and `image`, the file to be uploaded.

```
POST /api/posts/[filename]
```