summaryrefslogtreecommitdiff
path: root/src/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-02-28 15:29:50 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-02-28 15:29:50 +0100
commitd9d50c1f90c623c94cdb3437b8ef925fd1e88881 (patch)
tree7e95fde2385e0da3a3cbb0ee5f6253cd6b47af59 /src/generators.c
parentd8c88d35f8f609110ac1871c1df7a83fd719ff7d (diff)
downloadcataract-d9d50c1f90c623c94cdb3437b8ef925fd1e88881.tar.xz
Support path holes (non-direct path jumps)
Diffstat (limited to 'src/generators.c')
-rw-r--r--src/generators.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/generators.c b/src/generators.c
index f311388..b4bdf9c 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -288,15 +288,24 @@ write_html_album (TGallerySetup *setup,
replace_table_add_key (global_replace_table, "DESCRIPTION", items->desc);
replace_table_add_key (global_replace_table, "FOOTNOTE", items->footnote);
replace_table_add_key (global_replace_table, "FOOTER", setup->footer);
- s1 = setup->use_inpage_links ? g_strdup_printf ("../index.html#i%d", items->parent_item_index + 1) : g_strdup ("../index.html");
- replace_table_add_key (global_replace_table, "GO_UP_LINK", s1);
- g_free (s1);
/* Navigation bar */
s1 = g_strdup (items->ID);
old_parent_item_index = items->parent_item_index + 1;
parent = items->parent_index;
level = 1;
+ if (parent) {
+ tmp_item = g_ptr_array_index (parent->items, old_parent_item_index - 1);
+ if (tmp_item && tmp_item->path && strlen (tmp_item->path) > 0)
+ level += count_dir_levels (tmp_item->path) - 1;
+ }
+ /* Go Up string */
+ s3 = make_string ("../", level);
+ s2 = setup->use_inpage_links ? g_strdup_printf ("#i%d", old_parent_item_index) : g_strdup ("");
+ replace_table_add_key_printf (global_replace_table, "GO_UP_LINK", "%sindex.html%s", s3, s2);
+ g_free (s2);
+ free (s3);
+
while (parent) {
s3 = make_string ("../", level);
s4 = g_strdup (parent->ID);
@@ -310,6 +319,11 @@ write_html_album (TGallerySetup *setup,
old_parent_item_index = parent->parent_item_index + 1;
parent = parent->parent_index;
level++;
+ if (parent) {
+ tmp_item = g_ptr_array_index (parent->items, old_parent_item_index - 1);
+ if (tmp_item && tmp_item->path && strlen (tmp_item->path) > 0)
+ level += count_dir_levels (tmp_item->path) - 1;
+ }
}
replace_table_add_key (global_replace_table, "NAV_BAR", s1);
g_free (s1);
@@ -715,6 +729,11 @@ write_html_image (TGallerySetup *setup,
old_parent_item_index = parent->parent_item_index + 1;
parent = parent->parent_index;
level++;
+ if (parent) {
+ tmp_item = g_ptr_array_index (parent->items, old_parent_item_index - 1);
+ if (tmp_item && tmp_item->path && strlen (tmp_item->path) > 0)
+ level += count_dir_levels (tmp_item->path) - 1;
+ }
}
replace_table_add_key (replace_table, "NAV_BAR", s1);
g_free (s1);
@@ -883,7 +902,7 @@ build_tree (TGallerySetup *setup,
return FALSE;
}
if (access (dst_dir, R_OK | W_OK | X_OK)) {
- if (mkdir (dst_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (g_mkdir_with_parents (dst_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error creating destination directory: %s\n", strerror (errno));
return FALSE;
}
@@ -932,7 +951,7 @@ build_tree (TGallerySetup *setup,
/* Prepare target thumbnail directory */
thumb_dir = g_strconcat (dst_dir, "/", THUMBNAIL_DIR, NULL);
if (access (thumb_dir, R_OK | W_OK | X_OK))
- if (mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (g_mkdir_with_parents (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error making target thumbnail directory: %s\n", strerror (errno));
g_free (thumb_dir);
free_album_data (items);
@@ -947,12 +966,12 @@ build_tree (TGallerySetup *setup,
img_big_dir = g_strconcat (dst_dir, "/", IMG_BIG_DIR, NULL);
img_orig_dir = g_strconcat (dst_dir, "/", IMG_ORIG_DIR, NULL);
if (access (img_big_dir, R_OK | W_OK | X_OK))
- if (mkdir (img_big_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (g_mkdir_with_parents (img_big_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error making target preview directory: %s\n", strerror (errno));
res = FALSE;
}
if (access (img_orig_dir, R_OK | W_OK | X_OK))
- if (mkdir (img_orig_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (g_mkdir_with_parents (img_orig_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error making target full size directory: %s\n", strerror (errno));
res = FALSE;
}