summaryrefslogtreecommitdiff
path: root/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-01-03 15:20:58 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-01-03 15:20:58 +0100
commita90b52cda533af04dd8c827029d093cfde44090c (patch)
treecdc699fa562cdde28b2e04a4a476b7bf194cef9a /generators.c
parentf7168d75b60c4d36083529d1c465f58d14a48c03 (diff)
downloadcataract-a90b52cda533af04dd8c827029d093cfde44090c.tar.xz
Scroll to parent item when going up
Diffstat (limited to 'generators.c')
-rw-r--r--generators.c40
1 files changed, 30 insertions, 10 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> &gt; ", 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> &gt; %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> &gt; ", 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> &gt; %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);
}