mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
List timelines can now be (manually) navigated from the web UI.
URLs are {srv_baseurl}/{user}/list/{list_id} (you must know the list id).
This commit is contained in:
parent
c5ae10af86
commit
6b1721c977
4 changed files with 44 additions and 6 deletions
24
data.c
24
data.c
|
@ -1836,6 +1836,23 @@ xs_val *list_maint(snac *user, const char *list, int op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xs_list *list_timeline(snac *user, const char *list, int skip, int show)
|
||||||
|
/* returns the timeline of a list */
|
||||||
|
{
|
||||||
|
xs_list *l = NULL;
|
||||||
|
|
||||||
|
if (!xs_is_hex(list))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xs *fn = xs_fmt("%s/list/%s.idx", user->basedir, list);
|
||||||
|
|
||||||
|
if (mtime(fn) > 0.0)
|
||||||
|
l = index_list_desc(fn, skip, show);
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op)
|
xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op)
|
||||||
/* list content management */
|
/* list content management */
|
||||||
{
|
{
|
||||||
|
@ -1869,11 +1886,8 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /** list timeline **/
|
default:
|
||||||
fn = xs_replace_i(fn, ".lst", ".idx");
|
srv_log(xs_fmt("ERROR: list_content: bad op %d", op));
|
||||||
|
|
||||||
l = index_list_desc(fn, 0, 2048);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
html.c
23
html.c
|
@ -2658,6 +2658,29 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (xs_startswith(p_path, "list/")) { /** list timelines **/
|
||||||
|
if (!login(&snac, req)) {
|
||||||
|
*body = xs_dup(uid);
|
||||||
|
status = 401;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xs *l = xs_split(p_path, "/");
|
||||||
|
char *lid = xs_list_get(l, -1);
|
||||||
|
|
||||||
|
xs *list = list_timeline(&snac, lid, skip, show);
|
||||||
|
xs *next = list_timeline(&snac, lid, skip + show, 1);
|
||||||
|
|
||||||
|
if (list != NULL) {
|
||||||
|
xs *base = xs_fmt("/list/%s", lid);
|
||||||
|
|
||||||
|
*body = html_timeline(&snac, list, 0, skip, show,
|
||||||
|
xs_list_len(next), NULL, base, 0);
|
||||||
|
*b_size = strlen(*body);
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
if (xs_startswith(p_path, "p/")) { /** a timeline with just one entry **/
|
if (xs_startswith(p_path, "p/")) { /** a timeline with just one entry **/
|
||||||
if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE)
|
if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE)
|
||||||
return 403;
|
return 403;
|
||||||
|
|
|
@ -1669,7 +1669,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *l = xs_split(cmd, "/");
|
xs *l = xs_split(cmd, "/");
|
||||||
char *list = xs_list_get(l, -1);
|
char *list = xs_list_get(l, -1);
|
||||||
|
|
||||||
xs *timeline = list_content(&snac1, list, NULL, 3);
|
xs *timeline = list_timeline(&snac1, list, 0, 2048);
|
||||||
xs *out = xs_list_new();
|
xs *out = xs_list_new();
|
||||||
int c = 0;
|
int c = 0;
|
||||||
char *md5;
|
char *md5;
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -175,6 +175,7 @@ void tag_index(const char *id, const xs_dict *obj);
|
||||||
xs_list *tag_search(char *tag, int skip, int show);
|
xs_list *tag_search(char *tag, int skip, int show);
|
||||||
|
|
||||||
xs_val *list_maint(snac *user, const char *list, int op);
|
xs_val *list_maint(snac *user, const char *list, int op);
|
||||||
|
xs_list *list_timeline(snac *user, const char *list, int skip, int show);
|
||||||
xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
|
xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
|
||||||
void list_distribute(snac *user, const char *who, const xs_dict *post);
|
void list_distribute(snac *user, const char *who, const xs_dict *post);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue