summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/html.c b/html.c
index 05fa2cf..5774894 100644
--- a/html.c
+++ b/html.c
@@ -2972,6 +2972,48 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2972 const char *q = xs_dict_get(q_vars, "q"); 2972 const char *q = xs_dict_get(q_vars, "q");
2973 2973
2974 if (q && *q) { 2974 if (q && *q) {
2975 if (xs_regex_match(q, "^@?[a-zA-Z0-9_]+@[a-zA-Z0-9-]+\\.")) {
2976 /** search account **/
2977 xs *actor = NULL;
2978 xs *acct = NULL;
2979 xs *l = xs_list_new();
2980 xs_html *page = NULL;
2981
2982 if (valid_status(webfinger_request(q, &actor, &acct))) {
2983 xs *actor_obj = NULL;
2984
2985 if (valid_status(actor_request(&snac, actor, &actor_obj))) {
2986 actor_add(actor, actor_obj);
2987
2988 /* create a people list with only one element */
2989 l = xs_list_append(xs_list_new(), actor);
2990
2991 xs *title = xs_fmt(L("Search results for account %s"), q);
2992
2993 page = html_people_list(&snac, l, title, "wf", NULL);
2994 }
2995 }
2996
2997 if (page == NULL) {
2998 xs *title = xs_fmt(L("Account %s not found"), q);
2999
3000 page = xs_html_tag("div",
3001 xs_html_tag("h2",
3002 xs_html_attr("class", "snac-header"),
3003 xs_html_text(title)));
3004 }
3005
3006 xs_html *html = xs_html_tag("html",
3007 html_user_head(&snac, NULL, NULL),
3008 xs_html_add(html_user_body(&snac, 0),
3009 page,
3010 html_footer()));
3011
3012 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
3013 *b_size = strlen(*body);
3014 status = HTTP_STATUS_OK;
3015 }
3016 else
2975 if (*q == '#') { 3017 if (*q == '#') {
2976 /** search by tag **/ 3018 /** search by tag **/
2977 xs *tl = tag_search(q, skip, show + 1); 3019 xs *tl = tag_search(q, skip, show + 1);