summaryrefslogtreecommitdiff
path: root/generators.c
diff options
context:
space:
mode:
Diffstat (limited to 'generators.c')
-rw-r--r--generators.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/generators.c b/generators.c
index 810a0d9..59c28c3 100644
--- a/generators.c
+++ b/generators.c
@@ -442,52 +442,56 @@ write_html_album (TGallerySetup *setup,
img_h = 0;
img_src = NULL;
thumb = NULL;
+ s1 = NULL;
switch (item->type) {
case INDEX_ITEM_TYPE_PICTURE:
generate_image (setup, items, item, dst, &img_w, &img_h, &img_src, &thumb);
- /* Process HTML box code */
- if (img_w == 0 || img_h == 0 || (img_w / img_h) >= 1)
- s1 = strdup (buf_img_list_landscape);
- else
- s1 = strdup (buf_img_list_portrait);
-
- if (strstr (s1, "<!-- $(ALBUM_SUBPATH) -->")) {
- s2 = g_strconcat (item->path, "/index.html", NULL);
- str_replace (&s1, "<!-- $(ALBUM_SUBPATH) -->", s2, NULL);
- g_free (s2);
- }
- if (strstr (s1, "<!-- $(IMG_SUBPAGE) -->")) {
- s2 = g_strconcat (img_src, ".html", NULL);
- str_replace (&s1, "<!-- $(IMG_SUBPAGE) -->", s2, NULL);
- g_free (s2);
- }
- if (strstr (s1, "<!-- $(IMG_TITLE) -->") && item->title) {
- s2 = g_strdup (item->title);
- fix_entities (&s2);
- str_replace (&s1, "<!-- $(IMG_TITLE) -->", s2, NULL);
- g_free (s2);
+ /* Skip HTML code generation if it's a hidden item */
+ g_print ("item->hidden = %d\n", item->hidden);
+ if (! item->hidden) {
+ if (img_w == 0 || img_h == 0 || (img_w / img_h) >= 1)
+ s1 = strdup (buf_img_list_landscape);
+ else
+ s1 = strdup (buf_img_list_portrait);
+
+ if (strstr (s1, "<!-- $(ALBUM_SUBPATH) -->")) {
+ s2 = g_strconcat (item->path, "/index.html", NULL);
+ str_replace (&s1, "<!-- $(ALBUM_SUBPATH) -->", s2, NULL);
+ g_free (s2);
+ }
+ if (strstr (s1, "<!-- $(IMG_SUBPAGE) -->")) {
+ s2 = g_strconcat (img_src, ".html", NULL);
+ str_replace (&s1, "<!-- $(IMG_SUBPAGE) -->", s2, NULL);
+ g_free (s2);
+ }
+ if (strstr (s1, "<!-- $(IMG_TITLE) -->") && item->title) {
+ s2 = g_strdup (item->title);
+ fix_entities (&s2);
+ str_replace (&s1, "<!-- $(IMG_TITLE) -->", s2, NULL);
+ g_free (s2);
+ }
+ if (strstr (s1, "<!-- $(IMG_DESCRIPTION) -->") && item->title_description) {
+ s2 = g_strdup (item->title_description);
+ fix_entities (&s2);
+ str_replace (&s1, "<!-- $(IMG_DESCRIPTION) -->", s2, NULL);
+ g_free (s2);
+ }
+ if (strstr(s1, "<!-- $(ALBUM_NUM_ITEMS) -->")) {
+ s3 = g_strconcat (items->base_dir, "/", item->path, "/index.xml", NULL);
+ s2 = g_strdup_printf ("%d", get_album_objects_count(s3));
+ str_replace (&s1, "<!-- $(ALBUM_NUM_ITEMS) -->", s2, NULL);
+ g_free (s2);
+ g_free (s3);
+ }
+ if (strstr (s1, "<!-- $(IMG_THUMBNAIL) -->")) {
+ s2 = g_strconcat (THUMBNAIL_DIR, "/", thumb, NULL);
+ str_replace (&s1, "<!-- $(IMG_THUMBNAIL) -->", s2, NULL);
+ g_free (s2);
+ }
+ if (strstr (s1, "<!-- $(IMG_FILENAME) -->"))
+ str_replace (&s1, "<!-- $(IMG_FILENAME) -->", img_src, NULL);
}
- if (strstr (s1, "<!-- $(IMG_DESCRIPTION) -->") && item->title_description) {
- s2 = g_strdup (item->title_description);
- fix_entities (&s2);
- str_replace (&s1, "<!-- $(IMG_DESCRIPTION) -->", s2, NULL);
- g_free (s2);
- }
- if (strstr(s1, "<!-- $(ALBUM_NUM_ITEMS) -->")) {
- s3 = g_strconcat (items->base_dir, "/", item->path, "/index.xml", NULL);
- s2 = g_strdup_printf ("%d", get_album_objects_count(s3));
- str_replace (&s1, "<!-- $(ALBUM_NUM_ITEMS) -->", s2, NULL);
- g_free (s2);
- g_free (s3);
- }
- if (strstr (s1, "<!-- $(IMG_THUMBNAIL) -->")) {
- s2 = g_strconcat (THUMBNAIL_DIR, "/", thumb, NULL);
- str_replace (&s1, "<!-- $(IMG_THUMBNAIL) -->", s2, NULL);
- g_free (s2);
- }
- if (strstr (s1, "<!-- $(IMG_FILENAME) -->"))
- str_replace (&s1, "<!-- $(IMG_FILENAME) -->", img_src, NULL);
break;
case INDEX_ITEM_TYPE_SEPARATOR:
@@ -504,13 +508,15 @@ write_html_album (TGallerySetup *setup,
#ifdef __DEBUG_ALL__
printf("***** %s ******\n", s1);
#endif
- if (! fputs (s1, fout)) {
- fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno));
- res = FALSE;
+ if (s1) {
+ if (! fputs (s1, fout)) {
+ fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno));
+ res = FALSE;
+ free (s1);
+ break;
+ }
free (s1);
- break;
}
- free (s1);
if (img_src)
g_free (img_src);
if (thumb)