diff options
| -rw-r--r-- | generators.c | 40 | ||||
| -rw-r--r-- | items.h | 3 | ||||
| -rw-r--r-- | sample/src/setup.xml | 6 | ||||
| -rw-r--r-- | setup.c | 5 | ||||
| -rw-r--r-- | setup.h | 1 | ||||
| -rw-r--r-- | templates/template-album.tmpl | 6 | ||||
| -rw-r--r-- | templates/template-index.tmpl | 6 |
7 files changed, 49 insertions, 18 deletions
diff --git a/generators.c b/generators.c index 4e36648..170c283 100644 --- a/generators.c +++ b/generators.c @@ -215,11 +215,11 @@ write_html_album (TGallerySetup *setup, gboolean in_img_separator; gboolean in_go_up_string; char *b; - char *s1, *s2, *s3, *s4; + char *s1, *s2, *s3, *s4, *s5; TAlbum *parent; TIndexItem *item; TIndexItem *tmp_item; - int level; + int level, old_parent_item_index; gboolean res; int i; unsigned long img_w, img_h; @@ -328,8 +328,14 @@ write_html_album (TGallerySetup *setup, in_go_up_string = FALSE; free (b); /* print the "Go Up" string if not toplevel */ - if (items->parent_index) + if (items->parent_index) { b = strdup (buf_go_up_string); + if (strstr (b, "$(GO_UP_LINK)")) { + s1 = setup->use_inpage_links ? g_strdup_printf ("../index.html#i%d", items->parent_item_index + 1) : g_strdup ("../index.html"); + str_replace (&b, "$(GO_UP_LINK)", s1, NULL); + g_free (s1); + } + } else continue; } if (in_go_up_string) { @@ -411,17 +417,21 @@ write_html_album (TGallerySetup *setup, if (strstr (b, "<!-- $(NAV_BAR) -->")) { s1 = g_strdup (items->ID); fix_entities (&s1); + old_parent_item_index = items->parent_item_index + 1; parent = items->parent_index; level = 1; while (parent) { s3 = make_string ("../", level); s4 = g_strdup (parent->ID); fix_entities (&s4); - s2 = g_strconcat ("<a href=\"", s3, "index.html\">", s4, "</a> > ", s1, NULL); + s5 = setup->use_inpage_links ? g_strdup_printf ("#i%d", old_parent_item_index) : g_strdup (""); + s2 = g_strdup_printf ("<a href=\"%sindex.html%s\">%s</a> > %s", s3, s5, s4, s1); free (s3); g_free (s1); g_free (s4); + g_free (s5); s1 = s2; + old_parent_item_index = parent->parent_item_index + 1; parent = parent->parent_index; level++; } @@ -496,13 +506,18 @@ write_html_album (TGallerySetup *setup, str_replace (&s1, "<!-- $(IMG_DESCRIPTION) -->", s2, NULL); g_free (s2); } - if (strstr(s1, "<!-- $(ALBUM_NUM_ITEMS) -->")) { + 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_LIST_ID) -->")) { + s2 = g_strdup_printf ("i%d", i + 1); + str_replace (&s1, "<!-- $(IMG_LIST_ID) -->", s2, NULL); + g_free (s2); + } if (strstr (s1, "<!-- $(IMG_THUMBNAIL) -->")) { s2 = g_strconcat (THUMBNAIL_DIR, "/", thumb, NULL); str_replace (&s1, "<!-- $(IMG_THUMBNAIL) -->", s2, NULL); @@ -601,12 +616,12 @@ write_html_image (TGallerySetup *setup, TIndexItem *tmp_item; TAlbum *parent; int i; - char *s1, *s2, *s3, *s4; + char *s1, *s2, *s3, *s4, *s5; char *imgname, *preload_imgname; char *title, *title_desc; char *b; gboolean res; - int level; + int level, old_parent_item_index; gboolean override_title_meta; @@ -785,11 +800,14 @@ write_html_image (TGallerySetup *setup, s3 = make_string ("../", level); s4 = g_strdup (parent->ID); fix_entities (&s4); - s2 = g_strconcat ("<a href=\"", s3, "index.html\">", s4, "</a> > ", s1, NULL); + s5 = setup->use_inpage_links ? g_strdup_printf ("#i%d", parent == parent_items ? item_index : old_parent_item_index) : g_strdup (""); + s2 = g_strdup_printf ("<a href=\"%sindex.html%s\">%s</a> > %s", s3, s5, s4, s1); free (s3); g_free (s1); g_free (s4); + g_free (s5); s1 = s2; + old_parent_item_index = parent->parent_item_index + 1; parent = parent->parent_index; level++; } @@ -984,7 +1002,8 @@ gboolean build_tree (TGallerySetup *setup, const char *src_tree, const char *dst_dir, - TAlbum *parent_index) + TAlbum *parent_index, + int parent_item_index) { char *idx_file; TAlbum *items; @@ -1034,6 +1053,7 @@ build_tree (TGallerySetup *setup, } g_free (idx_file); items->parent_index = parent_index; + items->parent_item_index = parent_item_index; /* Copy support files */ @@ -1125,7 +1145,7 @@ build_tree (TGallerySetup *setup, if (item->type == INDEX_ITEM_TYPE_PICTURE) { s1 = g_strconcat (src_tree, "/", item->path, "/", NULL); s2 = g_strconcat (dst_dir, "/", item->path, "/", NULL); - build_tree (setup, s1, s2, items); + build_tree (setup, s1, s2, items, i); g_free (s1); g_free (s2); } @@ -40,7 +40,8 @@ typedef struct { char *footnote; GPtrArray *items; char *base_dir; - void *parent_index; // pointer to the parent TAlbum structure + void *parent_index; /* pointer to the parent TAlbum structure */ + int parent_item_index; /* item index in the parent album */ int quality; unsigned long landscape_width; unsigned long landscape_height; diff --git a/sample/src/setup.xml b/sample/src/setup.xml index 22c6823..ca2c338 100644 --- a/sample/src/setup.xml +++ b/sample/src/setup.xml @@ -64,6 +64,12 @@ <add_copyright>This is custom copyright string added to every picture. And the second line.</add_copyright> </meta> + + <navigation> + <!-- enabled: jump to the parent item when going up in the structure --> + <!-- disabled: links will always go to the top of the parent page --> + <use_inpage_links value="yes" /> + </navigation> <footer><