aboutsummaryrefslogtreecommitdiff
path: root/include/render.h
blob: 9b5e9e2b0bce5228dc3d7e7f78b8527ba74129d3 (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
#ifndef REVELA_RENDER_H
#define REVELA_RENDER_H

#include "bstree.h"
#include "config.h"
#include "components.h"

#include "roscha.h"

#include <sys/stat.h>

/* Variables that are common to all templates */
struct base_template {
	/* Title of the gallery */
	struct roscha_object *title;
	/* The base url or index url of the gallery */
	struct roscha_object *index;
};

/* Variables of the index template */
struct index_template {
	/* vector of all albums */
	struct roscha_object *albums;
	/* hmap with the year "name" and a vector of albums (see album template) */
	struct roscha_object *years;
};

/* 
 * Variables for the album template and album elements in the albums vector of
 * the index template.
 */
struct album_template {
	/* The title of the album as stored in album.ini */
	struct roscha_object *title;
	/* The description of the album as stored in album.ini */
	struct roscha_object *desc;
	/* The url to the album */
	struct roscha_object *link;
	/* The date of the oldest photo in the album */
	struct roscha_object *date;
	/* The year of the oldest photo in the album */
	struct roscha_object *year;
	/* vector of n first thumbs; deprecated */
	struct roscha_object *previews;
	/* vector of all thumbs hmaps */
	struct roscha_object *thumbs;
};

/* Variables for the image template and thumb hashmap */
struct image_template {
	/* The date the image was taken/created */
	struct roscha_object *date;
	/* The url to the image file */
	struct roscha_object *source;
	/* The url to the previous image page */
	struct roscha_object *prev;
	/* The url to the next image page */
	struct roscha_object *next;
};

struct render {
	/* Roscha environment */
	struct roscha_env *env;
	struct base_template base;
	struct index_template index;
	/* Modification time for the templates dir */
	struct timespec modtime;
	/* Refcounted vector of years with album hmaps */
	struct roscha_object *years;
	/* Refcounted vector album hmaps */
	struct roscha_object *albums;
	/* Count of the albums that were updated */
	size_t albums_updated;
	/* Whether we should simulate rendering or actually render templates */
	bool dry_run;
};

bool render_make_index(struct render *, const char *path);

bool render_make_album(struct render *r, const char *path,
		const struct album *album);

bool render_make_image(struct render *r, const char *path,
		const struct image *image);

bool render_set_album_vars(struct render *, struct album *);

bool render_init(struct render *, const char *path, struct site_config *,
		struct bstree *albums);

void render_deinit(struct render *);

#endif