From 0f3fcf7c383271a3762b52e38309bc18fca49aec Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 7 Mar 2009 21:46:27 +0100 Subject: Favicon support --- sample/src/apple-red.png | Bin 0 -> 3100 bytes sample/src/setup.xml | 5 +++++ src/generators.c | 28 ++++++++++++++++++++++++++++ src/setup.c | 7 +++++++ src/setup.h | 3 +++ templates/template-album.tmpl | 2 +- templates/template-index.tmpl | 2 +- templates/template-view_photo.tmpl | 2 +- 8 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 sample/src/apple-red.png diff --git a/sample/src/apple-red.png b/sample/src/apple-red.png new file mode 100644 index 0000000..f1bf9dd Binary files /dev/null and b/sample/src/apple-red.png differ diff --git a/sample/src/setup.xml b/sample/src/setup.xml index 84cc639..12bef08 100644 --- a/sample/src/setup.xml +++ b/sample/src/setup.xml @@ -69,6 +69,11 @@ This is custom copyright string added to every picture. And the second line. + + + + + apple-red.png diff --git a/src/generators.c b/src/generators.c index e07a880..992370a 100644 --- a/src/generators.c +++ b/src/generators.c @@ -356,6 +356,14 @@ write_html_album (TGallerySetup *setup, g_free (s1); s1 = s2; } + if (setup->favicon_file && strlen (setup->favicon_file) > 0) { + if (setup->favicon_type) + s2 = g_strdup_printf ("%s\t\n", s1, setup->favicon_type, setup->favicon_file); + else + s2 = g_strdup_printf ("%s\t\n", s1, setup->favicon_file); + g_free (s1); + s1 = s2; + } replace_table_add_key (global_replace_table, "CGG_META_TAGS", s1); g_free (s1); @@ -805,6 +813,14 @@ write_html_image (TGallerySetup *setup, g_free (s1); s1 = s2; } + if (setup->favicon_file && strlen (setup->favicon_file) > 0) { + if (setup->favicon_type) + s2 = g_strdup_printf ("%s\t\n", s1, setup->favicon_type, setup->favicon_file); + else + s2 = g_strdup_printf ("%s\t\n", s1, setup->favicon_file); + g_free (s1); + s1 = s2; + } replace_table_add_key (replace_table, "CGG_META_TAGS", s1); g_free (s1); @@ -950,6 +966,18 @@ build_tree (TGallerySetup *setup, g_free (s2); if (setup->verbose) printf (" done.\n"); + if (setup->favicon_file && strlen (setup->favicon_file) > 0) { + if (setup->verbose) printf ("Writing '%s' ...", setup->favicon_file); + s3 = g_path_get_dirname (setup->setup_xml_path); + s1 = g_strconcat (s3, "/", setup->favicon_file, NULL); + s2 = g_strconcat (dst_dir, "/", setup->favicon_file, NULL); + copy_file (s1, s2); + g_free (s1); + g_free (s2); + g_free (s3); + if (setup->verbose) printf (" done.\n"); + } + /* Prepare target thumbnail directory */ thumb_dir = g_strconcat (dst_dir, "/", THUMBNAIL_DIR, NULL); diff --git a/src/setup.c b/src/setup.c index 1481be6..31bd5ca 100644 --- a/src/setup.c +++ b/src/setup.c @@ -131,6 +131,9 @@ parse_setup_xml (const char *filename, TGallerySetup *setup) setup->nofullsize = xml_file_get_node_present (xml, "/gallery_setup/images/nofullsize"); + setup->favicon_file = xml_file_get_node_value (xml, "/gallery_setup/meta/favicon/text()"); + setup->favicon_type = xml_file_get_node_attribute (xml, "/gallery_setup/meta/favicon", "type"); + xml_parser_close (xml); #ifdef __DEBUG_ALL__ @@ -256,6 +259,10 @@ free_setup_data (TGallerySetup *setup) free (setup->site_title); if (setup->add_copyright) free (setup->add_copyright); + if (setup->favicon_file) + free (setup->favicon_file); + if (setup->favicon_type) + free (setup->favicon_type); free (setup); setup = NULL; } diff --git a/src/setup.h b/src/setup.h index 111e9b1..cba4278 100644 --- a/src/setup.h +++ b/src/setup.h @@ -73,6 +73,9 @@ typedef struct { char *site_title; char *add_copyright; gboolean use_inpage_links; + + char *favicon_file; + char *favicon_type; } TGallerySetup; diff --git a/templates/template-album.tmpl b/templates/template-album.tmpl index 75d55e5..616d6af 100644 --- a/templates/template-album.tmpl +++ b/templates/template-album.tmpl @@ -1,7 +1,7 @@ - + $(PAGE_TITLE) diff --git a/templates/template-index.tmpl b/templates/template-index.tmpl index edb583a..089e487 100644 --- a/templates/template-index.tmpl +++ b/templates/template-index.tmpl @@ -1,7 +1,7 @@ - + $(PAGE_TITLE) diff --git a/templates/template-view_photo.tmpl b/templates/template-view_photo.tmpl index 70c1dab..7c84919 100644 --- a/templates/template-view_photo.tmpl +++ b/templates/template-view_photo.tmpl @@ -1,7 +1,7 @@ - + $(PAGE_TITLE) -- cgit v1.2.3