diff options
| -rw-r--r-- | html.c | 24 |
1 files changed, 24 insertions, 0 deletions
| @@ -370,16 +370,37 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | 372 | ||
| 373 | d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level) | ||
| 374 | { | ||
| 375 | char *id = xs_dict_get(msg, "id"); | ||
| 376 | |||
| 377 | /* return if already seen */ | ||
| 378 | if (xs_set_add(seen, id) == 0) | ||
| 379 | return s; | ||
| 380 | |||
| 381 | return s; | ||
| 382 | } | ||
| 383 | |||
| 384 | |||
| 373 | d_char *html_timeline(snac *snac, char *list, int local) | 385 | d_char *html_timeline(snac *snac, char *list, int local) |
| 374 | /* returns the HTML for the timeline */ | 386 | /* returns the HTML for the timeline */ |
| 375 | { | 387 | { |
| 376 | d_char *s = xs_str_new(NULL); | 388 | d_char *s = xs_str_new(NULL); |
| 389 | xs_set *seen = xs_set_new(4096); | ||
| 390 | char *v; | ||
| 377 | 391 | ||
| 378 | s = html_user_header(snac, s, local); | 392 | s = html_user_header(snac, s, local); |
| 379 | 393 | ||
| 380 | if (!local) | 394 | if (!local) |
| 381 | s = html_top_controls(snac, s); | 395 | s = html_top_controls(snac, s); |
| 382 | 396 | ||
| 397 | while (xs_list_iter(&list, &v)) { | ||
| 398 | xs *msg = timeline_get(snac, v); | ||
| 399 | |||
| 400 | s = html_entry(snac, s, msg, seen, 0); | ||
| 401 | } | ||
| 402 | |||
| 403 | #if 0 | ||
| 383 | s = xs_str_cat(s, "<h1>HI</h1>\n"); | 404 | s = xs_str_cat(s, "<h1>HI</h1>\n"); |
| 384 | 405 | ||
| 385 | s = xs_str_cat(s, xs_fmt("len() == %d\n", xs_list_len(list))); | 406 | s = xs_str_cat(s, xs_fmt("len() == %d\n", xs_list_len(list))); |
| @@ -392,6 +413,9 @@ d_char *html_timeline(snac *snac, char *list, int local) | |||
| 392 | } | 413 | } |
| 393 | 414 | ||
| 394 | s = xs_str_cat(s, "</html>\n"); | 415 | s = xs_str_cat(s, "</html>\n"); |
| 416 | #endif | ||
| 417 | |||
| 418 | xs_set_free(seen); | ||
| 395 | 419 | ||
| 396 | return s; | 420 | return s; |
| 397 | } | 421 | } |