summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-08-14 22:30:31 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-08-14 22:30:31 +0200
commit7dcce8c12fa693471efbae7f2fef8d7b102aacfb (patch)
tree3ee1a110e53a57afecb16dc5360877320a666b74
parent5a020e6640b2723a57176e6596ea665442d53672 (diff)
downloadcataract-7dcce8c12fa693471efbae7f2fef8d7b102aacfb.tar.xz
Treat meta tags in a cleaner way
-rw-r--r--generators.c46
-rw-r--r--sample/src/setup.xml3
-rw-r--r--setup.c4
-rw-r--r--setup.h2
-rw-r--r--templates/template-album.tmpl4
-rw-r--r--templates/template-index.tmpl4
-rw-r--r--templates/template-view_photo.tmpl4
7 files changed, 48 insertions, 19 deletions
diff --git a/generators.c b/generators.c
index 0a07eb8..904d407 100644
--- a/generators.c
+++ b/generators.c
@@ -327,13 +327,26 @@ write_html_album (TGallerySetup *setup,
str_replace (&b, "<!-- $(FOOTER) -->", s1, NULL);
g_free (s1);
}
- if (strstr (b, "<!-- $(META_GENERATOR) -->")) {
- s1 = g_strdup_printf ("Cataract Gallery Generator v%s", APP_VERSION);
- str_replace (&b, "<!-- $(META_GENERATOR) -->", s1, NULL);
+ if (strstr (b, "<!-- $(CGG_META_TAGS) -->")) {
+ s1 = g_strdup_printf ("\t<meta name=\"generator\" content=\"Cataract Gallery Generator v%s\" />\n", APP_VERSION);
+ if (setup->meta_author) {
+ s2 = g_strdup_printf ("%s\t<meta name=\"author\" content=\"%s\" />\n", s1, setup->meta_author);
+ g_free (s1);
+ s1 = s2;
+ }
+ if (setup->meta_description) {
+ s2 = g_strdup_printf ("%s\t<meta name=\"description\" content=\"%s\" />\n", s1, setup->meta_description);
+ g_free (s1);
+ s1 = s2;
+ }
+ if (setup->meta_keywords) {
+ s2 = g_strdup_printf ("%s\t<meta name=\"keywords\" content=\"%s\" />\n", s1, setup->meta_keywords);
+ g_free (s1);
+ s1 = s2;
+ }
+ str_replace (&b, "<!-- $(CGG_META_TAGS) -->", s1, NULL);
g_free (s1);
}
- if (strstr (b, "<!-- $(META_AUTHOR) -->") && setup->meta_author)
- str_replace (&b, "<!-- $(META_AUTHOR) -->", setup->meta_author, NULL);
if (strstr (b, "<!-- $(TOTAL_ITEMS) -->")) {
s1 = g_strdup_printf ("%d", items->items->len);
str_replace (&b, "<!-- $(TOTAL_ITEMS) -->", s1, NULL);
@@ -762,13 +775,26 @@ write_html_image (TGallerySetup *setup,
str_replace (&b, "<!-- $(FOOTER) -->", s1, NULL);
g_free (s1);
}
- if (strstr (b, "<!-- $(META_GENERATOR) -->")) {
- s1 = g_strdup_printf ("Cataract Gallery Generator v%s", APP_VERSION);
- str_replace (&b, "<!-- $(META_GENERATOR) -->", s1, NULL);
+ if (strstr (b, "<!-- $(CGG_META_TAGS) -->")) {
+ s1 = g_strdup_printf ("\t<meta name=\"generator\" content=\"Cataract Gallery Generator v%s\" />\n", APP_VERSION);
+ if (setup->meta_author) {
+ s2 = g_strdup_printf ("%s\t\t<meta name=\"author\" content=\"%s\" />\n", s1, setup->meta_author);
+ g_free (s1);
+ s1 = s2;
+ }
+ if (setup->meta_description) {
+ s2 = g_strdup_printf ("%s\t<meta name=\"description\" content=\"%s\" />\n", s1, setup->meta_description);
+ g_free (s1);
+ s1 = s2;
+ }
+ if (setup->meta_keywords) {
+ s2 = g_strdup_printf ("%s\t<meta name=\"keywords\" content=\"%s\" />\n", s1, setup->meta_keywords);
+ g_free (s1);
+ s1 = s2;
+ }
+ str_replace (&b, "<!-- $(CGG_META_TAGS) -->", s1, NULL);
g_free (s1);
}
- if (strstr (b, "<!-- $(META_AUTHOR) -->") && setup->meta_author)
- str_replace (&b, "<!-- $(META_AUTHOR) -->", setup->meta_author, NULL);
if (! fputs (b, fout)) {
fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno));
diff --git a/sample/src/setup.xml b/sample/src/setup.xml
index 5cca5d8..f9cb460 100644
--- a/sample/src/setup.xml
+++ b/sample/src/setup.xml
@@ -31,6 +31,9 @@
<!-- META tags in html head section -->
<meta>
<author>John Doe</author>
+ <description>CGG Sample gallery</description>
+ <!-- keywords are usually not needed at all -->
+ <keywords>cataract, sample, gallery</keywords>
</meta>
<footer><![CDATA[
diff --git a/setup.c b/setup.c
index 4eabf7c..a266e99 100644
--- a/setup.c
+++ b/setup.c
@@ -110,6 +110,8 @@ parse_setup_xml (const char *filename, TGallerySetup *setup)
setup->footer = xml_file_get_node_value (xml, "/gallery_setup/footer/text()");
setup->border_style = xml_file_get_node_attribute (xml, "/gallery_setup/images/border", "style");
setup->meta_author = xml_file_get_node_value (xml, "/gallery_setup/meta/author/text()");
+ setup->meta_description = xml_file_get_node_value (xml, "/gallery_setup/meta/description/text()");
+ setup->meta_keywords = xml_file_get_node_value (xml, "/gallery_setup/meta/keywords/text()");
xml_parser_close (xml);
@@ -133,6 +135,8 @@ parse_setup_xml (const char *filename, TGallerySetup *setup)
printf("setup: footer = '%s'\n", setup->footer);
printf("setup: border_style = '%s'\n", setup->border_style);
printf("setup: meta_author = '%s'\n", setup->meta_author);
+ printf("setup: meta_description = '%s'\n", setup->meta_description);
+ printf("setup: meta_keywords = '%s'\n", setup->meta_keywords);
#endif
return TRUE;
diff --git a/setup.h b/setup.h
index 2170a8a..bb988aa 100644
--- a/setup.h
+++ b/setup.h
@@ -37,6 +37,8 @@ typedef struct {
char *footer;
char *meta_author;
+ char *meta_description;
+ char *meta_keywords;
int thumbnail_quality;
unsigned long thumbnail_landscape_width;
diff --git a/templates/template-album.tmpl b/templates/template-album.tmpl
index 33a0af5..ead7eaa 100644
--- a/templates/template-album.tmpl
+++ b/templates/template-album.tmpl
@@ -4,9 +4,7 @@
<head>
<title>Browsing album "<!-- $(ID) -->"</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
- <meta name="generator" content="<!-- $(META_GENERATOR) -->" />
- <meta name="description" content="Photo album: <!-- $(ID) -->" />
- <meta name="author" content="<!-- $(META_AUTHOR) -->" />
+<!-- $(CGG_META_TAGS) -->
<link href="styles.css" type="text/css" rel="stylesheet" media="screen, print" />
<script type="text/javascript" src="scripts-general.js"> </script>
</head>
diff --git a/templates/template-index.tmpl b/templates/template-index.tmpl
index e6268c5..1feecf6 100644
--- a/templates/template-index.tmpl
+++ b/templates/template-index.tmpl
@@ -4,9 +4,7 @@
<head>
<title>Photo index: <!-- $(ID) --></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
- <meta name="generator" content="<!-- $(META_GENERATOR) -->" />
- <meta name="description" content="Photo index: <!-- $(ID) -->" />
- <meta name="author" content="<!-- $(META_AUTHOR) -->" />
+<!-- $(CGG_META_TAGS) -->
<link href="styles.css" type="text/css" rel="stylesheet" media="screen, print" />
<script type="text/javascript" src="scripts-general.js"> </script>
</head>
diff --git a/templates/template-view_photo.tmpl b/templates/template-view_photo.tmpl
index 2a1875f..8b54c4f 100644
--- a/templates/template-view_photo.tmpl
+++ b/templates/template-view_photo.tmpl
@@ -4,9 +4,7 @@
<head>
<title>Viewing photo "<!-- $(FILE_NAME) -->" [<!-- $(FILE_NO) -->/<!-- $(TOTAL_ITEMS) -->]</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
- <meta name="generator" content="<!-- $(META_GENERATOR) -->" />
- <meta name="description" content="Viewing photo '<!-- $(FILE_NAME) -->'" />
- <meta name="author" content="<!-- $(META_AUTHOR) -->" />
+<!-- $(CGG_META_TAGS) -->
<link href="styles.css" type="text/css" rel="stylesheet" media="screen, print" />
<script type="text/javascript" src="scripts-general.js"> </script>
</head>