Search functions
FossilOrigin-Name: 1079a61c79c7ade533027a59b1bcc3641b50604851f13dbc82aeed9d9c044c7d
This commit is contained in:
parent
aa08c964d6
commit
657b648938
7 changed files with 45 additions and 38 deletions
|
@ -38,7 +38,6 @@
|
|||
#include "../static/bookmarks_page.chtml"
|
||||
|
||||
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
|
||||
#define MAKE_FOCUSED_IF(tab, test_tab) ((tab) == test_tab ? "focused" : "")
|
||||
|
||||
char* load_account_info(struct mstdnt_account* acct,
|
||||
size_t* size)
|
||||
|
|
|
@ -85,7 +85,6 @@ int main(void)
|
|||
{ "/login", content_login },
|
||||
{ "/test", content_test },
|
||||
{ "/user/:/action/:", content_account_action },
|
||||
{ "/search", content_search },
|
||||
{ "/@:/scrobbles", content_account_scrobbles },
|
||||
{ "/@:/pinned", content_account_pinned },
|
||||
{ "/@:/media", content_account_media },
|
||||
|
@ -95,10 +94,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 },
|
||||
{ "/search/statuses", content_search_statuses },
|
||||
{ "/search/accounts", content_search_accounts },
|
||||
{ "/search/hashtags", content_search_hashtags },
|
||||
{ "/search", content_search_statuses },
|
||||
{ "/lists/for/:", content_tl_list },
|
||||
{ "/lists", content_lists },
|
||||
{ "/federated", content_tl_federated },
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#include "query.h"
|
||||
#include "mime.h"
|
||||
|
||||
struct query_values post = { 0 };
|
||||
struct get_values query = { 0 };
|
||||
|
||||
char* read_query_data(struct get_values* query)
|
||||
{
|
||||
struct http_query_info info;
|
||||
|
|
24
src/search.c
24
src/search.c
|
@ -26,20 +26,23 @@
|
|||
// Pages
|
||||
#include "../static/search.chtml"
|
||||
|
||||
void content_search(struct session* ssn, mastodont_t* api, char** data)
|
||||
void search_page(struct session* ssn, mastodont_t* api, enum search_tab tab, char* content)
|
||||
{
|
||||
char* out_data;
|
||||
easprintf(&out_data, data_search_html,
|
||||
config_url_prefix,
|
||||
ssn->query.query,
|
||||
MAKE_FOCUSED_IF(tab, SEARCH_STATUSES),
|
||||
"Statuses",
|
||||
config_url_prefix,
|
||||
ssn->query.query,
|
||||
MAKE_FOCUSED_IF(tab, SEARCH_ACCOUNTS),
|
||||
"Accounts",
|
||||
config_url_prefix,
|
||||
ssn->query.query,
|
||||
MAKE_FOCUSED_IF(tab, SEARCH_HASHTAGS),
|
||||
"Hashtags",
|
||||
"Nothing");
|
||||
content);
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_NONE,
|
||||
|
@ -51,5 +54,20 @@ void content_search(struct session* ssn, mastodont_t* api, char** data)
|
|||
// Output
|
||||
render_base_page(&b, ssn, api);
|
||||
|
||||
free(out_data);
|
||||
free(out_data);
|
||||
}
|
||||
|
||||
void content_search_statuses(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
search_page(ssn, api, SEARCH_STATUSES, "statuses");
|
||||
}
|
||||
|
||||
void content_search_accounts(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
search_page(ssn, api, SEARCH_ACCOUNTS, "accounts");
|
||||
}
|
||||
|
||||
void content_search_hashtags(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
search_page(ssn, api, SEARCH_HASHTAGS, "hashtags");
|
||||
}
|
||||
|
|
13
src/search.h
13
src/search.h
|
@ -21,6 +21,17 @@
|
|||
#include <mastodont.h>
|
||||
#include "session.h"
|
||||
|
||||
void content_search(struct session* ssn, mastodont_t* api, char** data);
|
||||
enum search_tab
|
||||
{
|
||||
SEARCH_STATUSES,
|
||||
SEARCH_ACCOUNTS,
|
||||
SEARCH_HASHTAGS,
|
||||
};
|
||||
|
||||
void search_page(struct session* ssn, mastodont_t* api, enum search_tab tab, char* content);
|
||||
|
||||
void content_search_statuses(struct session* ssn, mastodont_t* api, char** data);
|
||||
void content_search_accounts(struct session* ssn, mastodont_t* api, char** data);
|
||||
void content_search_hashtags(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
#endif /* SEARCH_H */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
/** Returns str. If NULL, returns empty string */
|
||||
#define STR_NULL_EMPTY(str) ((str) ? (str) : "")
|
||||
#define MAKE_FOCUSED_IF(tab, test_tab) ((tab) == test_tab ? "focused" : "")
|
||||
|
||||
#define CAT_TEXT(cat, cfg_cat) ((cat) == (cfg_cat)) ? "focused" : ""
|
||||
|
||||
|
|
|
@ -1,31 +1,13 @@
|
|||
<table class="search-tabs ui-table">
|
||||
<table class="tabs ui-table">
|
||||
<tr>
|
||||
<td class="search-tab btn">
|
||||
<form action="%s/search/statuses" method="get">
|
||||
<label class="pointer">
|
||||
<input type="hidden" name="q" value="%s">
|
||||
<span class="search-tab-btn">%s</span>
|
||||
<input type="submit" class="hidden">
|
||||
</label>
|
||||
</form>
|
||||
<td>
|
||||
<a href="%s/search/statuses?q=%s"><input class="tab-btn btn %s" type="button" value="%s"></a>
|
||||
</td>
|
||||
<td class="nav-prev btn">
|
||||
<form action="%s/search/accounts" method="get">
|
||||
<label class="pointer">
|
||||
<input type="hidden" name="q" value="%s">
|
||||
<span class="search-tab-btn">%s</span>
|
||||
<input type="submit" class="hidden">
|
||||
</label>
|
||||
</form>
|
||||
<td>
|
||||
<a href="%s/search/accounts?q=%s"><input class="tab-btn btn %s" type="button" value="%s"></a>
|
||||
</td>
|
||||
<td class="nav-next btn">
|
||||
<form action="%s/search/hashtags" method="get">
|
||||
<label class="pointer">
|
||||
<input type="hidden" name="q" value="%s">
|
||||
<span class="search-tab-btn">%s</span>
|
||||
<input type="submit" class="hidden">
|
||||
</label>
|
||||
</form>
|
||||
<td>
|
||||
<a href="%s/search/hashtags?q=%s"><input class="tab-btn btn %s" type="button" value="%s"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue