summaryrefslogtreecommitdiff
path: root/src/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2013-02-10 16:25:29 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2013-02-10 16:25:29 +0100
commit0cb2950ba336d6c291a1dc086ad2f3138f37e132 (patch)
tree799d0b2b419eb07ad6c598b4f5234001ac6e0c21 /src/generators.c
parent939408e9c730ceb43d9bfd49056b5eb26f081b26 (diff)
downloadcataract-0cb2950ba336d6c291a1dc086ad2f3138f37e132.tar.xz
Support theme-defined thumbnail for protected albums
Diffstat (limited to 'src/generators.c')
-rw-r--r--src/generators.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/generators.c b/src/generators.c
index ac641d4..2b0928b 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -274,6 +274,7 @@ write_html_album (TGallerySetup *setup,
FILE *fout;
gchar *line;
gchar *block;
+ gchar *templates_path;
gchar *s1, *s2, *s3, *s4, *s5;
TAlbum *parent;
TIndexItem *item;
@@ -284,6 +285,8 @@ write_html_album (TGallerySetup *setup,
int i;
unsigned int real_total_items;
unsigned long img_thumb_w, img_thumb_h;
+ int album_objects_count;
+ gboolean album_protected;
ReplaceTable *global_replace_table;
ReplaceTable *local_replace_table;
BlockParser *block_parser;
@@ -379,9 +382,8 @@ write_html_album (TGallerySetup *setup,
g_free (s1);
/* Supportfiles path */
- s1 = make_string ("../", level - 1);
- replace_table_add_key (global_replace_table, "TEMPLATES_PATH", setup->supplemental_files_use_common_root ? s1 : "");
- g_free (s1);
+ templates_path = setup->supplemental_files_use_common_root ? make_string ("../", level - 1) : g_strdup ("");
+ replace_table_add_key (global_replace_table, "TEMPLATES_PATH", templates_path);
/* META tags */
s1 = g_strdup_printf ("\t<meta name=\"generator\" content=\"%s v%s\" />\n", APP_NAME_FULL, VERSION);
@@ -462,7 +464,6 @@ write_html_album (TGallerySetup *setup,
continue;
}
- /* Generate images (preview, original, thumbnail) */
local_replace_table = replace_table_new ();
replace_table_set_defines (local_replace_table, defines);
s1 = NULL;
@@ -471,8 +472,27 @@ write_html_album (TGallerySetup *setup,
case INDEX_ITEM_TYPE_PICTURE:
/* Skip HTML code generation if it's a hidden item */
if (! item->hidden) {
+ album_protected = FALSE;
+ album_objects_count = 0;
+ if (items->type == GALLERY_TYPE_INDEX) {
+ s3 = g_build_filename (path_info->src_dir, item->path, "index.xml", NULL);
+ /* FIXME: doing additional I/O, port to global item tree */
+ get_album_info (s3, &album_objects_count, &album_protected);
+ g_free (s3);
+ replace_table_add_key_int (local_replace_table, "ALBUM_NUM_ITEMS", album_objects_count);
+ replace_table_add_key_printf (local_replace_table, "ALBUM_SUBPATH", "%s/%s", item->path, get_index_filename (items, theme, path_info, item));
+ }
+
img_thumb_w = img_thumb_h = 0;
- get_image_paths (setup, items, item, i, path_info, thumb_image_size, NULL, &s2, &s3);
+ if (album_protected && theme->album_protected_thumbnail != NULL) {
+ /* expecting both global and theme supplemental files are in place at this moment */
+ s2 = g_build_filename (path_info->dest_dir, templates_path, theme->album_protected_thumbnail, NULL);
+ s3 = g_strconcat (templates_path, theme->album_protected_thumbnail, NULL);
+ }
+ else {
+ get_image_paths (setup, items, item, i, path_info, thumb_image_size, NULL, &s2, &s3);
+ }
+
if (s2 != NULL)
get_image_sizes (s2, &img_thumb_w, &img_thumb_h, setup->autorotate);
@@ -499,12 +519,6 @@ write_html_album (TGallerySetup *setup,
replace_table_add_key (local_replace_table, "IMG_TITLE", item->title);
replace_table_add_key (local_replace_table, "IMG_DESCRIPTION", item->title_description);
replace_table_add_key_printf (local_replace_table, "IMG_LIST_ID", "i%d", i + 1);
- if (items->type == GALLERY_TYPE_INDEX) {
- s3 = g_build_filename (path_info->src_dir, item->path, "index.xml", NULL);
- replace_table_add_key_int (local_replace_table, "ALBUM_NUM_ITEMS", get_album_objects_count (s3));
- replace_table_add_key_printf (local_replace_table, "ALBUM_SUBPATH", "%s/%s", item->path, get_index_filename (items, theme, path_info, item));
- g_free (s3);
- }
}
break;
@@ -553,6 +567,7 @@ write_html_album (TGallerySetup *setup,
g_hash_table_destroy (defines);
replace_table_free (global_replace_table);
block_parser_free (block_parser);
+ g_free (templates_path);
return res;
}