summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c13
-rw-r--r--html.c10
-rw-r--r--main.c2
-rw-r--r--mastoapi.c2
-rw-r--r--snac.h3
5 files changed, 19 insertions, 11 deletions
diff --git a/data.c b/data.c
index 78de21b..e284696 100644
--- a/data.c
+++ b/data.c
@@ -2491,7 +2491,8 @@ void notify_clear(snac *snac)
/** searches **/
-xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int max_res, int *timeout)
+xs_list *content_search(snac *user, const char *regex,
+ int priv, int skip, int show, int max_secs, int *timeout)
/* returns a list of posts which content matches the regex */
{
if (regex == NULL || *regex == '\0')
@@ -2520,7 +2521,7 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i
xs_list_next(pub_tl, &pub_md5, &pub_c);
xs_list_next(priv_tl, &priv_md5, &priv_c);
- while (max_res > 0) {
+ while (show > 0) {
char *md5 = NULL;
enum { NONE, PUBLIC, PRIVATE } from = NONE;
@@ -2591,8 +2592,12 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i
xs *l = xs_regex_select_n(c, regex, 1);
if (xs_list_len(l)) {
- xs_set_add(&seen, md5);
- max_res--;
+ if (skip)
+ skip--;
+ else {
+ xs_set_add(&seen, md5);
+ show--;
+ }
}
}
diff --git a/html.c b/html.c
index 9eefeec..d50333a 100644
--- a/html.c
+++ b/html.c
@@ -2563,9 +2563,9 @@ int html_get_handler(const xs_dict *req, const char *q_path,
char *q = xs_dict_get(q_vars, "q");
if (q && *q) {
- /* search by content */
+ /** search by content **/
int to = 0;
- xs *tl = content_search(&snac, q, 1, skip ? 10 : 0, skip + show, &to);
+ xs *tl = content_search(&snac, q, 1, skip, show, skip ? 10 : 0, &to);
xs *title = NULL;
xs *page = xs_fmt("/admin?q=%s", q);
int tl_len = xs_list_len(tl);
@@ -2573,10 +2573,12 @@ int html_get_handler(const xs_dict *req, const char *q_path,
if (tl_len)
title = xs_fmt(L("Search results for '%s'"), q);
else
+ if (skip)
+ title = xs_fmt(L("No more matches for '%s'"), q);
+ else
title = xs_fmt(L("Nothing found for '%s'"), q);
- *body = html_timeline(&snac, tl, 0, 0, tl_len,
- (to || tl_len == skip + show), title, page, 1);
+ *body = html_timeline(&snac, tl, 0, skip, show, tl_len > 0, title, page, 1);
*b_size = strlen(*body);
status = 200;
}
diff --git a/main.c b/main.c
index 5e37340..819922f 100644
--- a/main.c
+++ b/main.c
@@ -379,7 +379,7 @@ int main(int argc, char *argv[])
int to;
/* 'url' contains the regex */
- xs *r = content_search(&snac, url, 1, 10, XS_ALL, &to);
+ xs *r = content_search(&snac, url, 1, 0, XS_ALL, 10, &to);
int c = 0;
char *v;
diff --git a/mastoapi.c b/mastoapi.c
index cbc965c..1071bfd 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2261,7 +2261,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (xs_is_null(type) || strcmp(type, "statuses") == 0) {
int to = 0;
int cnt = 40;
- xs *tl = content_search(&snac1, q, 1, 0, cnt, &to);
+ xs *tl = content_search(&snac1, q, 1, 0, cnt, 0, &to);
int c = 0;
char *v;
diff --git a/snac.h b/snac.h
index 579d149..64d48f2 100644
--- a/snac.h
+++ b/snac.h
@@ -179,7 +179,8 @@ 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);
void list_distribute(snac *user, const char *who, const xs_dict *post);
-xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int max_res, int *timeout);
+xs_list *content_search(snac *user, const char *regex,
+ int priv, int skip, int show, int max_secs, int *timeout);
int actor_add(const char *actor, xs_dict *msg);
int actor_get(const char *actor, xs_dict **data);