diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-12-28 18:58:17 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-12-28 18:58:17 +0100 |
| commit | ad67f341ecec4b56dca28181b570036a1095ded6 (patch) | |
| tree | 72ff370ff1e46902a870a4d22c1db9064c79ec2b | |
| parent | aa30084b5af8cc8045b031c1714fd17cb57dc43a (diff) | |
| download | cataract-ad67f341ecec4b56dca28181b570036a1095ded6.tar.xz | |
Support for hidden items
| -rw-r--r-- | generators.c | 98 | ||||
| -rw-r--r-- | items.c | 4 | ||||
| -rw-r--r-- | items.h | 1 | ||||
| l--------- | sample/src/hidden/img_6802.jpg | 1 | ||||
| -rw-r--r-- | sample/src/hidden/index.xml | 17 | ||||
| -rw-r--r-- | sample/src/index.xml | 6 |
6 files changed, 81 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) @@ -136,6 +136,10 @@ parse_album_xml (const char *filename, TAlbum *index) item->nofullsize = (xml_file_get_node_present (xml, s) || item->path == NULL); g_free (s); + s = g_strdup_printf ("/gallery/items/*[%d]/hidden", i + 1); + item->hidden = (xml_file_get_node_present (xml, s)); + g_free (s); + if (item->path || item->preview) { g_ptr_array_add (index->items, item); @@ -61,6 +61,7 @@ typedef struct { gboolean nofullsize; char *border_style; TIndexItemType type; + gboolean hidden; } TIndexItem; diff --git a/sample/src/hidden/img_6802.jpg b/sample/src/hidden/img_6802.jpg new file mode 120000 index 0000000..9f4b2f7 --- /dev/null +++ b/sample/src/hidden/img_6802.jpg @@ -0,0 +1 @@ +../CIAF_1/img_6802.jpg
\ No newline at end of file diff --git a/sample/src/hidden/index.xml b/sample/src/hidden/index.xml new file mode 100644 index 0000000..d68f763 --- /dev/null +++ b/sample/src/hidden/index.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<gallery type="album"> + <general> + <ID>Hidden page</ID> + <title>Hidden page</title> + <description>This is a top-secret page which should not be linked from parent album. You should see "1 items" at the headline but no clickable thumbnail below.</description> + </general> + + <items> + <item src="img_6802.jpg"> + <hidden /> + <title>Hidden item</title> + <title_description></title_description> + </item> + + </items> +</gallery> diff --git a/sample/src/index.xml b/sample/src/index.xml index e7368ed..eecca3f 100644 --- a/sample/src/index.xml +++ b/sample/src/index.xml @@ -32,5 +32,11 @@ <thumbnail src="subdir/Tatry/img_7755.jpg" /> </item> + <item path="hidden"> + <hidden /> + <title>This should not be visible</title> + <title_description>hidden</title_description> + </item> + </items> </gallery> |
