diff --git a/src/main.c b/src/main.c index babeeec..c86383a 100644 --- a/src/main.c +++ b/src/main.c @@ -95,6 +95,10 @@ int main(void) { "/status/:/reply", status_reply }, { "/status/:", status_view }, { "/notice/:", notice_redirect }, + { "/search", content_search }, + { "/search/statuses", content_search }, + { "/search/accounts", content_search }, + { "/search/hashtags", content_search }, { "/lists/for/:", content_tl_list }, { "/lists", content_lists }, { "/federated", content_tl_federated }, diff --git a/src/query.c b/src/query.c index 74b37c7..779c196 100644 --- a/src/query.c +++ b/src/query.c @@ -36,7 +36,7 @@ char* read_query_data(struct get_values* query) // BEGIN Query references struct key_value_refs refs[] = { { "offset", &(query->offset), key_string }, - { "q", &(query->q), key_string }, + { "q", &(query->query), key_string }, }; // END Query references diff --git a/src/query.h b/src/query.h index 6d9244c..b575e89 100644 --- a/src/query.h +++ b/src/query.h @@ -57,10 +57,12 @@ struct query_values char* username; char* password; char* replyid; + char* visibility; + + // Navigation char* min_id; char* max_id; char* start_id; - char* visibility; struct file_array files; }; @@ -68,7 +70,7 @@ struct query_values struct get_values { char* offset; - char* q; + char* query; }; void key_files(char* val, struct form_props* form, void* arg); diff --git a/src/search.c b/src/search.c index edc4be0..a65796b 100644 --- a/src/search.c +++ b/src/search.c @@ -16,9 +16,40 @@ * along with this program. If not, see . */ +#include #include "search.h" +#include "easprintf.h" +#include "../config.h" +#include "string_helpers.h" +#include "base_page.h" + +// Pages +#include "../static/search.chtml" void content_search(struct session* ssn, mastodont_t* api, char** data) { - + char* out_data; + easprintf(&out_data, data_search_html, + config_url_prefix, + ssn->query.query, + "Statuses", + config_url_prefix, + ssn->query.query, + "Accounts", + config_url_prefix, + ssn->query.query, + "Hashtags", + "Nothing"); + + struct base_page b = { + .category = BASE_CAT_NONE, + .locale = L10N_EN_US, + .content = out_data, + .sidebar_left = NULL + }; + + // Output + render_base_page(&b, ssn, api); + + free(out_data); } diff --git a/static/search.html b/static/search.html index d106fc6..0aa44c0 100644 --- a/static/search.html +++ b/static/search.html @@ -4,7 +4,7 @@
@@ -13,7 +13,7 @@
@@ -22,7 +22,7 @@