mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
User search can also be done by tag.
This commit is contained in:
parent
281f934f74
commit
34311714ce
2 changed files with 38 additions and 19 deletions
21
html.c
21
html.c
|
@ -748,7 +748,7 @@ static xs_html *html_user_body(snac *user, int read_only)
|
||||||
xs_html_sctag("input",
|
xs_html_sctag("input",
|
||||||
xs_html_attr("type", "text"),
|
xs_html_attr("type", "text"),
|
||||||
xs_html_attr("name", "q"),
|
xs_html_attr("name", "q"),
|
||||||
xs_html_attr("title", L("Search posts by content (regular expression)")),
|
xs_html_attr("title", L("Search posts by content (regular expression) or #tag")),
|
||||||
xs_html_attr("placeholder", L("Content search")))));
|
xs_html_attr("placeholder", L("Content search")))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2588,6 +2588,24 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
||||||
char *q = xs_dict_get(q_vars, "q");
|
char *q = xs_dict_get(q_vars, "q");
|
||||||
|
|
||||||
if (q && *q) {
|
if (q && *q) {
|
||||||
|
if (*q == '#') {
|
||||||
|
/** search by tag **/
|
||||||
|
xs *tl = tag_search(q, skip, show + 1);
|
||||||
|
int more = 0;
|
||||||
|
if (xs_list_len(tl) >= show + 1) {
|
||||||
|
/* drop the last one */
|
||||||
|
tl = xs_list_del(tl, -1);
|
||||||
|
more = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xs *page = xs_fmt("/admin?q=%%23%s", q + 1);
|
||||||
|
xs *title = xs_fmt(L("Search results for tag %s"), q);
|
||||||
|
|
||||||
|
*body = html_timeline(&snac, tl, 0, skip, show, more, title, page, 0);
|
||||||
|
*b_size = strlen(*body);
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
else {
|
||||||
/** search by content **/
|
/** search by content **/
|
||||||
int to = 0;
|
int to = 0;
|
||||||
int msecs = atoi(xs_dict_get_def(q_vars, "msecs", "0"));
|
int msecs = atoi(xs_dict_get_def(q_vars, "msecs", "0"));
|
||||||
|
@ -2608,6 +2626,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
double t = history_mtime(&snac, "timeline.html_");
|
double t = history_mtime(&snac, "timeline.html_");
|
||||||
|
|
||||||
|
|
2
httpd.c
2
httpd.c
|
@ -202,7 +202,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xs *page = xs_fmt("?t=%s", t);
|
xs *page = xs_fmt("?t=%s", t);
|
||||||
xs *title = xs_fmt(L("Search results for #%s"), t);
|
xs *title = xs_fmt(L("Search results for tag #%s"), t);
|
||||||
*body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0);
|
*body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue