author | Mikael Berthe <mikael@lilotux.net> |
Sun, 07 May 2017 21:54:50 +0200 | |
changeset 95 | 4b80a5396961 |
parent 94 | 4c0206d283e5 |
child 98 | dd260cff924e |
permissions | -rw-r--r-- |
94 | 1 |
# Themes and Templates |
23 | 2 |
|
3 |
This folder contains sample templates to customize madonctl output. |
|
4 |
||
86 | 5 |
Feel free to contribute if you have nice templates or if you want to work on themes as well! |
6 |
||
7 |
## Configuration |
|
8 |
||
9 |
The template prefix directory can be set in the configuration file with the |
|
10 |
'template_directory' setting, or with the `MADONCTL_TEMPLATE_DIRECTORY` |
|
11 |
environment variable.\ |
|
12 |
If set, template files are looked up relatively from this repository first |
|
13 |
(unless they are absolute paths or start with "./" or "../"). |
|
14 |
||
15 |
The themes are located in the `themes` directory, inside the base template |
|
16 |
directory. |
|
17 |
A theme is a collection of templates grouped in a theme directory (the name of |
|
18 |
the directory is the name of the theme).\ |
|
19 |
E.g. `$template_directory/themes/ansi/` |
|
20 |
||
21 |
## Themes |
|
22 |
||
23 |
To use a theme, simply specify the theme name with the --theme flag (the |
|
24 |
--output=theme flag is implied): |
|
82
9ac2281c07d7
Add 'template_directory' setting
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
25 |
|
86 | 26 |
madonctl timeline --limit=2 --theme=ansi |
27 |
madonctl accounts statuses --limit 5 --theme ansi |
|
28 |
||
29 |
madonctl --theme=ansi accounts notifications --list |
|
30 |
madonctl --theme=ansi stream |
|
31 |
||
32 |
Currently, if a template is missing, madonctl will fall back to the _plain_ |
|
33 |
output format. (In the future it might just fail with an error message.) |
|
94 | 34 |
|
35 |
## Templates |
|
36 |
||
37 |
Here's an example using a template with ANSI color escape codes (for UNIX/Linux): |
|
38 |
||
39 |
madonctl timeline --limit 2 --template-file ansi-status.tmpl |
|
40 |
||
41 |
### Template development |
|
42 |
||
43 |
Here's a list of available commands (please check the Go template documentation for the built-in functions): |
|
44 |
- fromunix UNIXTIMESTAMP |
|
45 |
- fromhtml HTMLTEXT |
|
46 |
- wrap TEXT |
|
47 |
- trim TEXT |
|
48 |
- color COLORSPEC |
|
49 |
COLORSPEC is a string with the following format: `[FGCOLOR][,BGCOLOR[,STYLE]]` or `reset`. |
|
50 |
||
51 |
Examples: |
|
52 |
||
53 |
{{color "red"}}red text{{color "reset"}} |
|
54 |
{{color ",red"}}red background{{color "reset"}} |
|
55 |
{{color "white,,bold"}}bright white text{{color "reset"}} |
|
56 |
||
57 |
Message: {{color "blue"}}{{.content | fromhtml | wrap " " 80 | trim}}{{color "reset"}} |
|
58 |
||
59 |
Note that the _wrap_ implementation might change in the future; currently it is |
|
60 |
paragraph-based, not line-based, and the result can be surprising after |
|
61 |
_fromhtml_ (carriage returns are ignored). |