summaryrefslogtreecommitdiffstats
path: root/doc/user/src/approach.md
blob: 21cd41b6ece80b3fa708ab643ded8ba6cd5a6d84 (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
# The Approach

The approach "imag" takes on solving this problem is to store content in a
plain text storage (the "store") on the filesystem and persisting content in a
unified way.

## The Store

The imag "store" is nothing more than a directory on the filesystem, ususally
`~/.imag/store`.
Imag stores each "entry" under a unique "StoreId" which is nothing more than a
part of the path of the actual file on disk:


```
/home/user/.imag/store/some/entry
|               |     ||        |
 \             /     /  \      /
  -------------      |   ------
|   "RTP"            |    "Id"
 \                  /
  ------------------
    "Store path"
```

* The "RTP" is the Runtimepath of imag, where imag looks for the config file
  (`~/.imag/imagrc.toml`) and the `store` directory.

* The "Store path" is where imag looks for the store root. The "Store path" can
  be set explicitely in the imag commandline, but end-users normally don't need
  to do this.

* The "StoreId" (abbreviated with "Id") is what the user uses when referring to
  an entry of the store.


## Entry

One imag entry contains two parts: The Header and the Content part. The header,
which is stored in
[TOML](https://en.wikipedia.org/wiki/TOML),
contains structured data. This data is most of the time generated by imag
itself, depending on the module that stores the data.
An imag entry contains always a version information header part:

```
[imag]
version = "0.10.1"
```

Each imag module is free to store data under its own header section, where the
name of the section is defined by the module storing it. Thus, "imag-diary"
stores its data in `[diary]`.
A module may store arbitrary textual data.
Of course, imag provides utility commandline tools for querying this data.

An example imag entry could look like this:

```
---
[habit.instance]
comment = 'Eat one fruit per day'
date = '2019-06-28'
is_habit_instance = true
name = 'eat_fruit'

[imag]
version = '0.10.1'

[links]
internal = ['habit/template/eat_fruit']
---
```