Add favourites/bookmarks pages and sidebar stuff
FossilOrigin-Name: 0789f1476e6e7c83eba78a04c7f3691fd0c1c287f729c406a7d9c873c0f0b2da
This commit is contained in:
parent
7225e5244c
commit
8bc4ec0115
12 changed files with 179 additions and 10 deletions
4
Makefile
4
Makefile
|
@ -96,6 +96,10 @@ $(PAGES_DIR)/status_interaction_profile.chtml: $(PAGES_DIR)/status_interaction_p
|
|||
./filec $< data_status_interaction_profile_html > $@
|
||||
$(PAGES_DIR)/account_follow_btn.chtml: $(PAGES_DIR)/account_follow_btn.html
|
||||
./filec $< data_account_follow_btn_html > $@
|
||||
$(PAGES_DIR)/bookmarks_page.chtml: $(PAGES_DIR)/bookmarks_page.html
|
||||
./filec $< data_bookmarks_page_html > $@
|
||||
$(PAGES_DIR)/favourites_page.chtml: $(PAGES_DIR)/favourites_page.html
|
||||
./filec $< data_favourites_page_html > $@
|
||||
|
||||
$(MASTODONT_DIR):
|
||||
git clone $(MASTODONT_URL) || true
|
||||
|
|
136
src/account.c
136
src/account.c
|
@ -25,13 +25,17 @@
|
|||
#include "easprintf.h"
|
||||
#include "status.h"
|
||||
#include "http.h"
|
||||
#include "base_page.h"
|
||||
#include "scrobble.h"
|
||||
#include "string_helpers.h"
|
||||
#include "navigation.h"
|
||||
|
||||
// Files
|
||||
#include "../static/account.chtml"
|
||||
#include "../static/account_info.chtml"
|
||||
#include "../static/account_follow_btn.chtml"
|
||||
#include "../static/favourites_page.chtml"
|
||||
#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" : "")
|
||||
|
@ -346,3 +350,135 @@ void content_account_action(struct session* ssn, mastodont_t* api, char** data)
|
|||
|
||||
redirect(REDIRECT_303, referer);
|
||||
}
|
||||
|
||||
void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
size_t status_count = 0, statuses_html_count = 0;
|
||||
struct mstdnt_status* statuses = NULL;
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
char* status_format = NULL,
|
||||
*navigation_box = NULL,
|
||||
*output = NULL,
|
||||
*page = NULL;
|
||||
char* start_id;
|
||||
|
||||
struct mstdnt_bookmarks_args args = {
|
||||
.with_muted = 0,
|
||||
.max_id = ssn->post.max_id,
|
||||
.since_id = NULL,
|
||||
.min_id = ssn->post.min_id,
|
||||
.limit = 20,
|
||||
};
|
||||
|
||||
if (mastodont_get_bookmarks(api, &args, &storage, &statuses, &status_count))
|
||||
{
|
||||
status_format = construct_error(storage.error, E_ERROR, 1, NULL);
|
||||
}
|
||||
else {
|
||||
// Construct statuses into HTML
|
||||
status_format = construct_statuses(api, statuses, status_count, &statuses_html_count);
|
||||
if (!status_format)
|
||||
status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL);
|
||||
}
|
||||
|
||||
// Create post box
|
||||
if (statuses)
|
||||
{
|
||||
// If not set, set it
|
||||
start_id = ssn->post.start_id ? ssn->post.start_id : statuses[0].id;
|
||||
navigation_box = construct_navigation_box(start_id,
|
||||
statuses[0].id,
|
||||
statuses[status_count-1].id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
easprintf(&page, "%s%s",
|
||||
STR_NULL_EMPTY(status_format),
|
||||
STR_NULL_EMPTY(navigation_box));
|
||||
|
||||
easprintf(&output, data_bookmarks_page_html, page);
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_BOOKMARKS,
|
||||
.locale = L10N_EN_US,
|
||||
.content = output,
|
||||
.sidebar_left = NULL
|
||||
};
|
||||
|
||||
// Output
|
||||
render_base_page(&b, ssn, api);
|
||||
|
||||
// Cleanup
|
||||
mastodont_storage_cleanup(&storage);
|
||||
mstdnt_cleanup_statuses(statuses, status_count);
|
||||
if (status_format) free(status_format);
|
||||
if (navigation_box) free(navigation_box);
|
||||
if (output) free(output);
|
||||
if (page) free(page);
|
||||
}
|
||||
|
||||
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
size_t status_count = 0, statuses_html_count = 0;
|
||||
struct mstdnt_status* statuses = NULL;
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
char* status_format = NULL,
|
||||
*navigation_box = NULL,
|
||||
*output = NULL,
|
||||
*page = NULL;
|
||||
char* start_id;
|
||||
|
||||
struct mstdnt_timeline_args args = {
|
||||
.with_muted = 0,
|
||||
.max_id = ssn->post.max_id,
|
||||
.since_id = NULL,
|
||||
.min_id = ssn->post.min_id,
|
||||
.limit = 20,
|
||||
};
|
||||
|
||||
if (mastodont_get_favourites(api, &args, &storage, &statuses, &status_count))
|
||||
{
|
||||
status_format = construct_error(storage.error, E_ERROR, 1, NULL);
|
||||
}
|
||||
else {
|
||||
// Construct statuses into HTML
|
||||
status_format = construct_statuses(api, statuses, status_count, &statuses_html_count);
|
||||
if (!status_format)
|
||||
status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL);
|
||||
}
|
||||
|
||||
// Create post box
|
||||
if (statuses)
|
||||
{
|
||||
// If not set, set it
|
||||
start_id = ssn->post.start_id ? ssn->post.start_id : statuses[0].id;
|
||||
navigation_box = construct_navigation_box(start_id,
|
||||
statuses[0].id,
|
||||
statuses[status_count-1].id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
easprintf(&page, "%s%s",
|
||||
STR_NULL_EMPTY(status_format),
|
||||
STR_NULL_EMPTY(navigation_box));
|
||||
|
||||
easprintf(&output, data_favourites_page_html, page);
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_FAVOURITES,
|
||||
.locale = L10N_EN_US,
|
||||
.content = output,
|
||||
.sidebar_left = NULL
|
||||
};
|
||||
|
||||
// Output
|
||||
render_base_page(&b, ssn, api);
|
||||
|
||||
// Cleanup
|
||||
mastodont_storage_cleanup(&storage);
|
||||
mstdnt_cleanup_statuses(statuses, status_count);
|
||||
if (status_format) free(status_format);
|
||||
if (navigation_box) free(navigation_box);
|
||||
if (output) free(output);
|
||||
if (page) free(page);
|
||||
}
|
||||
|
|
|
@ -62,12 +62,11 @@ char* load_account_info(struct mstdnt_account* acct,
|
|||
size_t* size);
|
||||
|
||||
void content_account_statuses(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
void content_account_scrobbles(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
void content_account_pinned(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
void content_account_media(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
void content_account_action(struct session* ssn, mastodont_t* api, char** data);
|
||||
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data);
|
||||
void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
#endif // ACCOUNT_H
|
||||
|
|
|
@ -103,6 +103,12 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
|
|||
CAT_TEXT(page->category, BASE_CAT_LISTS),
|
||||
config_url_prefix,
|
||||
L10N[locale][L10N_LISTS],
|
||||
CAT_TEXT(page->category, BASE_CAT_FAVOURITES),
|
||||
config_url_prefix,
|
||||
L10N[locale][L10N_LISTS],
|
||||
CAT_TEXT(page->category, BASE_CAT_BOOKMARKS),
|
||||
config_url_prefix,
|
||||
L10N[locale][L10N_LISTS],
|
||||
CAT_TEXT(page->category, BASE_CAT_DIRECT),
|
||||
config_url_prefix,
|
||||
L10N[locale][L10N_DIRECT],
|
||||
|
|
|
@ -31,6 +31,8 @@ enum base_category
|
|||
BASE_CAT_FEDERATED,
|
||||
BASE_CAT_NOTIFICATIONS,
|
||||
BASE_CAT_LISTS,
|
||||
BASE_CAT_FAVOURITES,
|
||||
BASE_CAT_BOOKMARKS,
|
||||
BASE_CAT_DIRECT,
|
||||
BASE_CAT_CONFIG,
|
||||
};
|
||||
|
|
|
@ -34,6 +34,8 @@ enum l10n_string
|
|||
L10N_FEDERATED,
|
||||
L10N_NOTIFICATIONS,
|
||||
L10N_LISTS,
|
||||
L10N_FAVOURITES,
|
||||
L10N_BOOKMARKS,
|
||||
L10N_DIRECT,
|
||||
L10N_CONFIG,
|
||||
L10N_SEARCH_PLACEHOLDER,
|
||||
|
@ -132,6 +134,8 @@ static const char* const L10N[][_L10N_LEN] = {
|
|||
"Federated",
|
||||
"Notifications",
|
||||
"Lists",
|
||||
"Favorites",
|
||||
"Bookmarks",
|
||||
"Direct",
|
||||
"Config",
|
||||
"Search",
|
||||
|
@ -227,6 +231,8 @@ static const char* const L10N[][_L10N_LEN] = {
|
|||
"Federado",
|
||||
"Notificaciones",
|
||||
"Listas",
|
||||
"Favourites",
|
||||
"Bookmarks",
|
||||
"Directo",
|
||||
"Configuración",
|
||||
"Búsqueda",
|
||||
|
|
|
@ -100,6 +100,8 @@ int main(void)
|
|||
{ "/federated", content_tl_federated },
|
||||
{ "/direct", content_tl_direct },
|
||||
{ "/local", content_tl_local },
|
||||
{ "/bookmarks", content_account_bookmarks },
|
||||
{ "/favourites", content_account_favourites },
|
||||
{ "/notifications", content_notifications },
|
||||
};
|
||||
|
||||
|
|
6
static/bookmarks_page.html
Normal file
6
static/bookmarks_page.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div class="simple-page">
|
||||
<h1>Bookmarks</h1>
|
||||
</div>
|
||||
<div class="bookmarks-container">
|
||||
%s
|
||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||
<div class="simple-page">
|
||||
<h1>Direct Messages</h1>
|
||||
<div class="direct-container">
|
||||
%s
|
||||
</div>
|
||||
</div>
|
||||
<div class="direct-container">
|
||||
%s
|
||||
</div>
|
||||
|
|
6
static/favourites_page.html
Normal file
6
static/favourites_page.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div class="simple-page">
|
||||
<h1>Favorites</h1>
|
||||
</div>
|
||||
<div class="favourites-container">
|
||||
%s
|
||||
</div>
|
|
@ -34,6 +34,8 @@
|
|||
<li><a class="sidebarbtn %s" href="%s/federated/">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/notifications">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/lists">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/favourites">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/bookmarks">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/direct">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/config">%s</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="simple-page">
|
||||
<h1>Notifications</h1>
|
||||
<div class="notifications-container">
|
||||
%s
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifications-container">
|
||||
%s
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue