summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgg.c3
-rw-r--r--src/generators.c3
-rw-r--r--src/replace-table.c16
-rw-r--r--src/replace-table.h5
-rw-r--r--src/setup.h1
5 files changed, 27 insertions, 1 deletions
diff --git a/src/cgg.c b/src/cgg.c
index 7510d2e..5a4949a 100644
--- a/src/cgg.c
+++ b/src/cgg.c
@@ -44,6 +44,7 @@ static gchar *dst_dir = NULL;
static gboolean verbose = FALSE;
static gboolean update = FALSE;
static gboolean fullsize = FALSE;
+static gboolean dont_strip_unused_tags = FALSE;
static int jobs = 0;
@@ -68,6 +69,7 @@ parse_cmd (int argc, char *argv[])
NULL },
{ "update", 'u', 0, G_OPTION_ARG_NONE, &update, "Update the output structure", NULL },
{ "fullsize", 'f', 0, G_OPTION_ARG_NONE, &fullsize, "Override the nofullsize switch and generate full gallery", NULL },
+ { "debug-dont-strip-unused-tags", 0, 0, G_OPTION_ARG_NONE, &dont_strip_unused_tags, "Don't strip unused/unknown template tags", NULL },
{ NULL }
};
@@ -197,6 +199,7 @@ main (int argc, char* argv[])
setup->verbose = verbose;
setup->update_mode = update;
setup->override_nofullsize = fullsize;
+ setup->strip_unused_tags = ! dont_strip_unused_tags;
path_info = g_malloc0 (sizeof (TPathInfo));
path_info->templates_root = templates_basedir;
diff --git a/src/generators.c b/src/generators.c
index ead3fb6..41ca616 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -345,6 +345,7 @@ write_html_album (TGallerySetup *setup,
defines = clone_string_hash_table (theme->defines);
global_replace_table = replace_table_new ();
+ replace_table_set_strip_unused_tags (global_replace_table, setup->strip_unused_tags);
replace_table_set_defines (global_replace_table, defines);
block_parser = block_parser_new ();
block_parser_set_conditionals (block_parser, defines);
@@ -499,6 +500,7 @@ write_html_album (TGallerySetup *setup,
}
local_replace_table = replace_table_new ();
+ replace_table_set_strip_unused_tags (local_replace_table, setup->strip_unused_tags);
local_defines = clone_string_hash_table (defines);
replace_table_set_defines (local_replace_table, local_defines);
s1 = NULL;
@@ -719,6 +721,7 @@ write_html_image (TGallerySetup *setup,
defines = clone_string_hash_table (theme->defines);
replace_table = replace_table_new ();
+ replace_table_set_strip_unused_tags (replace_table, setup->strip_unused_tags);
replace_table_set_defines (replace_table, defines);
block_parser = block_parser_new ();
block_parser_set_conditionals (block_parser, defines);
diff --git a/src/replace-table.c b/src/replace-table.c
index 9c1b254..a36a83c 100644
--- a/src/replace-table.c
+++ b/src/replace-table.c
@@ -34,6 +34,7 @@ struct ReplaceTable {
GHashTable *table;
GHashTable *defines;
GHashTable *functions;
+ gboolean strip_unused_tags;
};
typedef struct {
@@ -50,6 +51,7 @@ replace_table_new ()
table = g_new0 (ReplaceTable, 1);
table->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
table->functions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ table->strip_unused_tags = TRUE; /* default */
return table;
}
@@ -66,6 +68,18 @@ replace_table_free (ReplaceTable *table)
/*
+ * replace_table_set_strip_unused_tags: set whether all unused/unknown tags should be stripped (default = TRUE)
+ *
+ */
+void
+replace_table_set_strip_unused_tags (ReplaceTable *table, gboolean value)
+{
+ g_return_if_fail (table != NULL);
+
+ table->strip_unused_tags = value;
+}
+
+/*
* replace_table_add_key: add tag/value pair to replace
*
* tag, value will be referenced inside
@@ -345,7 +359,7 @@ replace_table_process (gchar **buffer, ReplaceTable *table)
}
/* push the tag if not matched above */
- if (! handled)
+ if (! handled && ! table->strip_unused_tags)
g_string_append_len (dst, start, end - start + 1);
g_free (token);
diff --git a/src/replace-table.h b/src/replace-table.h
index 1a1c4ac..e5e80cd 100644
--- a/src/replace-table.h
+++ b/src/replace-table.h
@@ -35,6 +35,11 @@ ReplaceTable * replace_table_new ();
void replace_table_free (ReplaceTable *table);
+/*
+ * replace_table_set_strip_unused_tags: set whether all unused/unknown tags should be stripped (default = TRUE)
+ *
+ */
+void replace_table_set_strip_unused_tags (ReplaceTable *table, gboolean value);
/*
* replace_table_add_key: add tag/value pair to replace
diff --git a/src/setup.h b/src/setup.h
index 6d5316e..1fe6a53 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -44,6 +44,7 @@ typedef struct {
gboolean verbose;
gboolean update_mode;
gboolean override_nofullsize;
+ gboolean strip_unused_tags;
gchar *setup_xml_path;
TGalleryDesign *design;