summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-05-28 20:52:05 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-29 07:27:28 -0700
commit5b8f0dd4885b67dc11c3ff185a055c6f32caaf6d (patch)
tree84f4f64fbbc5fa9bb9f5c4d289cb0874c80b888b
parentecb5e15dabf26ab3d5eb6548acd67ea6441a2a78 (diff)
downloadsubsurface-5b8f0dd4885b67dc11c3ff185a055c6f32caaf6d.tar.gz
Export tags in json array
This will help in searching based on tags Also some minor coding-style fixes Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--save-html.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/save-html.c b/save-html.c
index 8f16fdfe8..7b86ab051 100644
--- a/save-html.c
+++ b/save-html.c
@@ -100,21 +100,23 @@ void put_HTML_watertemp(struct membuffer *b, struct dive *dive, const char *pre,
void put_HTML_tags(struct membuffer *b, struct dive *dive, const char *pre, const char *post)
{
put_string(b, pre);
+ put_string(b, "[");
struct tag_entry *tag = dive->tag_list;
if (!tag)
- put_string(b, "--");
+ put_string(b, "\"--\",");
- while(tag){
- put_format(b, "%s ", tag->tag->name);
+ while (tag) {
+ put_format(b, "\"%s\",", tag->tag->name);
tag = tag->next;
}
+ put_string(b, "]");
put_string(b, post);
}
void write_attribute(struct membuffer *b, const char *att_name, const char *value)
{
- if(!value)
+ if (!value)
value="--";
put_format(b, "\"%s\":\"%s\",", att_name, value);
}
@@ -136,7 +138,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no)
write_attribute(b, "buddy", dive->buddy);
write_attribute(b, "divemaster", dive->divemaster);
write_attribute(b, "suit", dive->suit);
- put_HTML_tags(b, dive, "\"tags\":\"", "\",");
+ put_HTML_tags(b, dive, "\"tags\":", ",");
put_HTML_notes(b, dive ,"\"notes\":\"" ,"\",");
put_string(b, "},\n");
(*dive_no)++;