diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/components.h | 45 | ||||
| -rw-r--r-- | include/fs.h | 8 | ||||
| -rw-r--r-- | include/render.h | 74 | ||||
| -rw-r--r-- | include/site.h | 2 | 
4 files changed, 99 insertions, 30 deletions
| diff --git a/include/components.h b/include/components.h index 9e568ee..f08d79a 100644 --- a/include/components.h +++ b/include/components.h @@ -1,16 +1,22 @@  #ifndef REVELA_COMPONENTS_H  #define REVELA_COMPONENTS_H +#include "config.h" + +#include "hmap.h" +#include "vector.h" +#include "object.h" +  #include <time.h>  #include <sys/stat.h>  #include <libexif/exif-data.h> -#include "config.h" -#include "hashmap.h" -  #define PHOTO_THUMB_SUFFIX "_thumb" +/* All data related to a single image's files, templates, and pages */  struct image { +	/* The albums this image belongs to */ +	struct album *album;  	/* The path to the source image file */  	char *source;  	/* Points to the basename in source */ @@ -35,14 +41,18 @@ struct image {  	char datestr[24];  	/* Same as date but in seconds for easier comparison. See image_set_date() */  	time_t tstamp; -	struct album *album; -	/* Hashmap with values to be passed to the image template */ -	struct hashmap *map; -	/* Hashmap with values to be passed to thumbs and previews vectors */ -	struct hashmap *thumb; +	/* Reference counted hashmap with values to be passed to the template */ +	struct roscha_object *map; +	/* hashmap with values to be passed to the thumbs vector */ +	struct roscha_object *thumb; +	/*  +	 * Whether this image was modified since the last time the gallery was +	 * generated. +	 */  	bool modified;  }; +/* All data related to an album's images, templates, and pages */  struct album {  	struct site *site;  	struct album_config *config; @@ -58,14 +68,21 @@ struct album {  	char year[8];  	/* The date of the album is the date of the earliest image */  	time_t tstamp; +	/*  +	 * Binary search tree with the images of this album sorted by date from +	 * older to newer. +	 */  	struct bstree *images;  	/* Files/dirs that belong to images and which shouldn't be deleted */ -	struct hashmap *preserved; -	/* Hashmap with values to be passed to the template */ -	struct hashmap *map; -	/* Vector with hashmaps of images to be passed to the templates */ -	struct vector *thumbs; -	struct vector *previews; +	struct hmap *preserved; +	/* Reference counted hashmap with values to be passed to the template */ +	struct roscha_object *map; +	/* +	 * Reference counted vector with refcounted hashmaps of image thumbnails to +	 * be passed to the template. +	 */ +	struct roscha_object *thumbs; +	/* Count of images that were actually updated */  	size_t images_updated;  }; diff --git a/include/fs.h b/include/fs.h index d48ac9f..00be8a1 100644 --- a/include/fs.h +++ b/include/fs.h @@ -4,7 +4,7 @@  #include <stdbool.h>  #include <sys/stat.h> -#include "hashmap.h" +#include "hmap.h"  typedef bool (*preremove_fn)(const char *path, void *data); @@ -55,11 +55,11 @@ bool rmentry(const char *path, bool dry);  /*    * Recursively deletes extaneous files from directory, keeping files in the - * preserved hashmap. Returns -1 on error, number of deleted entries on success. + * preserved hmap. Returns -1 on error, number of deleted entries on success.   * The number is not the total number of files on all subdirectories, but only   * the number of files/dirs deleted from the directory pointed by path.   */ -ssize_t rmextra(const char *path, struct hashmap *preserved, preremove_fn, +ssize_t rmextra(const char *path, struct hmap *preserved, preremove_fn,  		void *data, bool dry);  /*  @@ -70,6 +70,6 @@ ssize_t rmextra(const char *path, struct hashmap *preserved, preremove_fn,   * timestamps do not match.   */  bool filesync(const char *restrict srcpath, const char *restrict dstpath, -		struct hashmap *preserved, bool dry); +		struct hmap *preserved, bool dry);  #endif diff --git a/include/render.h b/include/render.h index ff83bab..9b5e9e2 100644 --- a/include/render.h +++ b/include/render.h @@ -1,25 +1,77 @@  #ifndef REVELA_RENDER_H  #define REVELA_RENDER_H -#include <sys/stat.h> -  #include "bstree.h"  #include "config.h" -#include "template.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 { -	/* Unja environment */ -	struct env *env; -	/* List of years with albums in each year */ -	struct vector *years; -	/* List of albums */ -	struct vector *albums; -	/* Hashmap used for all templates */ -	struct hashmap *common_vars; +	/* 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;  }; diff --git a/include/site.h b/include/site.h index db82517..e054730 100644 --- a/include/site.h +++ b/include/site.h @@ -31,7 +31,7 @@ struct site {  	size_t rel_content_dir;  	struct bstree *albums;  	/* Files/dirs that belong to albums and which shouldn't be deleted */ -	struct hashmap *album_dirs; +	struct hmap *album_dirs;  	struct render render;  	bool dry_run;  	size_t albums_updated; | 
