From 01482f7632e86a12b9ee6d97eafa1dafa712f84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Sun, 16 Oct 2022 23:02:03 +0300 Subject: Re-render album html when album.ini changed --- include/components.h | 19 ++++++++++++------- include/fs.h | 3 +++ 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/components.h b/include/components.h index 4317187..88023cb 100644 --- a/include/components.h +++ b/include/components.h @@ -11,7 +11,7 @@ #include #include -#define PHOTO_THUMB_SUFFIX "_thumb" +#define THUMB_SUFFIX "_thumb" /* All data related to a single image's files, templates, and pages */ struct image { @@ -55,12 +55,19 @@ struct image { /* All data related to an album's images, templates, and pages */ struct album { struct site *site; + /* The album information, i.e. title, description */ struct album_config *config; + /* Modtime for the album.ini file; will be used to check whether we need to + * re-render the html for this album based on changes made to it. + */ + struct timespec modtime; + /* Whether the album.ini was updated */ + bool config_updated; /* The path to the source directory */ char *source; - /* The full url that will be used in the template */ + /* The full URL that will be used in the template */ char *url; - /* Pointer to the slug part in url that will be used for the new dir */ + /* Pointer to the slug part in the URL that will be used for the new dir */ const char *slug; /* Pointer to the human readable date of the earliest image */ const char *datestr; @@ -68,8 +75,7 @@ struct album { char year[8]; /* The date of the album is the date of the earliest image */ time_t tstamp; - /* - * List/vector with the images of this album to be sorted by from + /* List/vector with the images of this album to be sorted by from * older to newer. */ struct vector *images; @@ -77,8 +83,7 @@ struct album { 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 + /* Reference counted vector with refcounted hashmaps of image thumbnails to * be passed to the template. */ struct roscha_object *thumbs; diff --git a/include/fs.h b/include/fs.h index 00be8a1..71c566b 100644 --- a/include/fs.h +++ b/include/fs.h @@ -41,6 +41,9 @@ bool isimage(const char *fname); */ const char *delext(const char *restrict basename, char *restrict dest, size_t n); +#define TIMEQUAL(a, b) \ + ((a).tv_sec == (b).tv_sec && (a).tv_nsec == (b).tv_nsec) + /* * -1 if error; 0 if the timestamps are different; 1 if they are equal. */ -- cgit v1.2.3