Search page

FossilOrigin-Name: 7c1da191fc972aaa508401757243daeae5887b7202a979c293dfb62ceaf5d734
This commit is contained in:
me@ow.nekobit.net 2022-05-03 15:11:02 +00:00
parent af80738751
commit aa08c964d6
5 changed files with 44 additions and 7 deletions

View file

@ -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 },

View file

@ -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

View file

@ -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);

View file

@ -16,9 +16,40 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#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);
}

View file

@ -4,7 +4,7 @@
<form action="%s/search/statuses" method="get">
<label class="pointer">
<input type="hidden" name="q" value="%s">
<span class="search-tab-btn">Statuses</span>
<span class="search-tab-btn">%s</span>
<input type="submit" class="hidden">
</label>
</form>
@ -13,7 +13,7 @@
<form action="%s/search/accounts" method="get">
<label class="pointer">
<input type="hidden" name="q" value="%s">
<span class="search-tab-btn">Accounts</span>
<span class="search-tab-btn">%s</span>
<input type="submit" class="hidden">
</label>
</form>
@ -22,7 +22,7 @@
<form action="%s/search/hashtags" method="get">
<label class="pointer">
<input type="hidden" name="q" value="%s">
<span class="search-tab-btn">Hashtags</span>
<span class="search-tab-btn">%s</span>
<input type="submit" class="hidden">
</label>
</form>