mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
timeline_top_level() works.
This commit is contained in:
parent
159a591f45
commit
2ad703e520
3 changed files with 18 additions and 17 deletions
24
data.c
24
data.c
|
@ -1039,12 +1039,10 @@ int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
d_char *timeline_top_level(snac *snac, const char *index)
|
d_char *timeline_top_level(snac *snac, d_char *list)
|
||||||
/* returns the top level entries from this index */
|
/* returns the top level md5 entries from this index */
|
||||||
{
|
{
|
||||||
int max = 256;
|
d_char *tl = xs_list_new();
|
||||||
xs *list = index_list_desc(index, max);
|
|
||||||
xs *tl = xs_list_new();
|
|
||||||
xs_set seen;
|
xs_set seen;
|
||||||
char *p, *v;
|
char *p, *v;
|
||||||
|
|
||||||
|
@ -1061,15 +1059,13 @@ d_char *timeline_top_level(snac *snac, const char *index)
|
||||||
xs *fn = _object_fn_by_md5(line);
|
xs *fn = _object_fn_by_md5(line);
|
||||||
fn = xs_replace_i(fn, ".json", "_p.idx");
|
fn = xs_replace_i(fn, ".json", "_p.idx");
|
||||||
|
|
||||||
/* if it doesn't have a parent, we got it */
|
/* if it doesn't have a parent, use this */
|
||||||
if (index_first(fn, line2, strlen(line2)) == 0) {
|
if (index_first(fn, line2, sizeof(line2)) == 0)
|
||||||
strcpy(line, line2);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
xs *pfn = _object_fn_by_md5(line2);
|
xs *pfn = _object_fn_by_md5(line2);
|
||||||
|
|
||||||
/* well, there is a parent... if it's not here, we're done */
|
/* well, there is a parent... but if it's not there, use this */
|
||||||
if (mtime(pfn) == 0.0)
|
if (mtime(pfn) == 0.0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1077,12 +1073,8 @@ d_char *timeline_top_level(snac *snac, const char *index)
|
||||||
strcpy(line, line2);
|
strcpy(line, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xs_set_add(&seen, line) == 1) {
|
if (xs_set_add(&seen, line) == 1)
|
||||||
xs *obj = NULL;
|
tl = xs_list_append(tl, line);
|
||||||
|
|
||||||
if (valid_status(object_get(line, &obj, NULL)))
|
|
||||||
tl = xs_list_append(tl, obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xs_set_free(&seen);
|
xs_set_free(&seen);
|
||||||
|
|
9
main.c
9
main.c
|
@ -156,12 +156,21 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(cmd, "timeline") == 0) {
|
if (strcmp(cmd, "timeline") == 0) {
|
||||||
|
#if 0
|
||||||
xs *list = local_list(&snac, XS_ALL);
|
xs *list = local_list(&snac, XS_ALL);
|
||||||
xs *body = html_timeline(&snac, list, 1);
|
xs *body = html_timeline(&snac, list, 1);
|
||||||
|
|
||||||
printf("%s\n", body);
|
printf("%s\n", body);
|
||||||
user_free(&snac);
|
user_free(&snac);
|
||||||
srv_free();
|
srv_free();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
xs *idx = xs_fmt("%s/private.idx", snac.basedir);
|
||||||
|
xs *list = index_list_desc(idx, 256);
|
||||||
|
xs *tl = timeline_top_level(&snac, list);
|
||||||
|
|
||||||
|
xs *j = xs_json_dumps_pp(tl, 4);
|
||||||
|
printf("%s\n", j);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -76,7 +76,7 @@ d_char *timeline_list(snac *snac, int max);
|
||||||
int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);
|
int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);
|
||||||
void timeline_admire(snac *snac, char *id, char *admirer, int like);
|
void timeline_admire(snac *snac, char *id, char *admirer, int like);
|
||||||
|
|
||||||
d_char *timeline_top_level(snac *snac, const char *index);
|
d_char *timeline_top_level(snac *snac, d_char *list);
|
||||||
|
|
||||||
d_char *local_list(snac *snac, int max);
|
d_char *local_list(snac *snac, int max);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue