From d928fd7db816c5eb6f57f90ebefb55779aebdcc9 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Wed, 31 Dec 2008 21:25:37 +0100 Subject: Make page titles intelligent --- generators.c | 28 +++++++++++++++++++++++++++- sample/src/setup.xml | 3 +++ setup.c | 4 ++++ setup.h | 2 ++ templates/template-album.tmpl | 2 +- templates/template-index.tmpl | 2 +- templates/template-view_photo.tmpl | 2 +- 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/generators.c b/generators.c index 6bcf637..d4b0cf9 100644 --- a/generators.c +++ b/generators.c @@ -342,6 +342,16 @@ write_html_album (TGallerySetup *setup, /* Simple placeholders */ + if (strstr (b, "")) { + if (items->parent_index == NULL || setup->site_title == NULL) + s1 = g_strdup (setup->site_title ? setup->site_title : items->ID); + else + s1 = g_strdup_printf ("%s | %s", items->title, setup->site_title); + s2 = g_markup_escape_text (s1, -1); + str_replace (&b, "", s2, NULL); + g_free (s2); + g_free (s1); + } if (strstr (b, "") && items->ID) { s1 = g_strdup (items->ID); fix_entities (&s1); @@ -727,7 +737,23 @@ write_html_image (TGallerySetup *setup, str_replace (&title_desc, "\n", "
", NULL); } } - + if (title) title = g_strstrip (title); + if (title_desc) title_desc = g_strstrip (title_desc); + + /* Page title */ + if (strstr (b, "")) { + s1 = (title && strlen (title) > 0) ? g_strdup_printf("%s | ", title) : NULL; + s2 = g_strdup_printf ("%s [%d/%d]", parent_items->title ? parent_items->title : parent_items->ID, real_item_index, real_total_items); + s3 = setup->site_title ? g_strdup_printf(" | %s", setup->site_title) : NULL; + s4 = g_strconcat (s1 ? s1 : "", s2, s3 ? s3 : "", NULL); + if (s1) g_free (s1); + if (s2) g_free (s2); + if (s3) g_free (s3); + s1 = g_markup_escape_text (s4, -1); + str_replace (&b, "", s1, NULL); + g_free (s4); + g_free (s1); + } /* Simple placeholders */ if (strstr (b, "")) str_replace (&b, "", imgname, NULL); diff --git a/sample/src/setup.xml b/sample/src/setup.xml index 234e8f0..2ebf0d0 100644 --- a/sample/src/setup.xml +++ b/sample/src/setup.xml @@ -54,6 +54,9 @@ + + +