mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-26 01:03:37 +00:00
Tags can now be searched for from the server base URL.
This commit is contained in:
parent
895cf82a7d
commit
55d3ef5024
4 changed files with 21 additions and 5 deletions
5
data.c
5
data.c
|
@ -1575,7 +1575,6 @@ void tag_index(const char *id, const xs_dict *obj)
|
|||
xs_list *tags = xs_dict_get(obj, "tag");
|
||||
|
||||
if (is_msg_public(obj) && xs_type(tags) == XSTYPE_LIST && xs_list_len(tags) > 0) {
|
||||
xs *md5_id = xs_md5_hex(id, strlen(id));
|
||||
xs *g_tag_dir = xs_fmt("%s/tag", srv_basedir);
|
||||
|
||||
mkdirx(g_tag_dir);
|
||||
|
@ -1596,7 +1595,7 @@ void tag_index(const char *id, const xs_dict *obj)
|
|||
mkdirx(tag_dir);
|
||||
|
||||
xs *g_tag_idx = xs_fmt("%s/%s.idx", tag_dir, md5_tag);
|
||||
index_add(g_tag_idx, md5_id);
|
||||
index_add(g_tag_idx, id);
|
||||
|
||||
FILE *f;
|
||||
xs *g_tag_name = xs_replace(g_tag_idx, ".idx", ".tag");
|
||||
|
@ -1605,7 +1604,7 @@ void tag_index(const char *id, const xs_dict *obj)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
srv_debug(0, xs_fmt("tagged %s #%s (%s #%s)", id, name, md5_id, md5_tag));
|
||||
srv_debug(0, xs_fmt("tagged %s #%s (#%s)", id, name, md5_tag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
html.c
2
html.c
|
@ -1574,7 +1574,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int
|
|||
continue;
|
||||
|
||||
/* if it's an instance page, discard private users */
|
||||
if (user == NULL) {
|
||||
if (user == NULL && xs_startswith(xs_dict_get(msg, "id"), srv_baseurl)) {
|
||||
const char *atto = xs_dict_get(msg, "attributedTo");
|
||||
xs *l = xs_split(atto, "/");
|
||||
const char *uid = xs_list_get(l, -1);
|
||||
|
|
15
httpd.c
15
httpd.c
|
@ -141,6 +141,21 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
|||
|
||||
/* is it the server root? */
|
||||
if (*q_path == '\0') {
|
||||
xs_dict *q_vars = xs_dict_get(req, "q_vars");
|
||||
char *t = NULL;
|
||||
|
||||
if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) {
|
||||
/* tag search query */
|
||||
int skip = xs_number_get(xs_dict_get(q_vars, "skip"));
|
||||
int show = xs_number_get(xs_dict_get(q_vars, "show"));
|
||||
|
||||
if (show == 0)
|
||||
show = 64;
|
||||
|
||||
xs *tl = tag_search(t, skip, show);
|
||||
*body = html_timeline(NULL, tl, 0, skip, show, 0);
|
||||
}
|
||||
else
|
||||
if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
|
||||
xs *tl = timeline_instance_list(0, 30);
|
||||
*body = html_timeline(NULL, tl, 0, 0, 0, 0);
|
||||
|
|
4
snac.h
4
snac.h
|
@ -69,7 +69,8 @@ double mtime_nl(const char *fn, int *n_link);
|
|||
#define mtime(fn) mtime_nl(fn, NULL)
|
||||
double f_ctime(const char *fn);
|
||||
|
||||
int index_add(const char *fn, const char *md5);
|
||||
int index_add_md5(const char *fn, const char *md5);
|
||||
int index_add(const char *fn, const char *id);
|
||||
int index_gc(const char *fn);
|
||||
int index_first(const char *fn, char *buf, int size);
|
||||
int index_len(const char *fn);
|
||||
|
@ -144,6 +145,7 @@ void hide(snac *snac, const char *id);
|
|||
int is_hidden(snac *snac, const char *id);
|
||||
|
||||
void tag_index(const char *id, const xs_dict *obj);
|
||||
xs_list *tag_search(char *tag, int skip, int show);
|
||||
|
||||
int actor_add(const char *actor, xs_dict *msg);
|
||||
int actor_get(const char *actor, xs_dict **data);
|
||||
|
|
Loading…
Reference in a new issue