Error handling
FossilOrigin-Name: dadb89e019730998cc09f3eb0a06d518cfcd154b42f965cb4df10d035adb5dd8
This commit is contained in:
parent
dd0bf855d1
commit
282b914e6c
7 changed files with 45 additions and 18 deletions
12
dist/treebird20.css
vendored
12
dist/treebird20.css
vendored
|
@ -159,6 +159,18 @@ table.present th, table.present td
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.error
|
||||
{
|
||||
display: block;
|
||||
border-radius: 4px;
|
||||
background-color: #fcb0b0;
|
||||
color: #000;
|
||||
border: 1px solid #bb1c1f;
|
||||
padding: 15px;
|
||||
margin: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* BUTTONS *
|
||||
*************************************************/
|
||||
|
|
|
@ -35,8 +35,8 @@ void render_base_page(struct base_page* page, mastodont_t* api)
|
|||
char* login_string = "<a href=\"login\" id=\"login-header\">Login / Register</a>";
|
||||
char* sidebar_str = NULL;
|
||||
// Mastodont, used for notifications sidebar
|
||||
struct mstdnt_storage storage;
|
||||
struct mstdnt_notification* notifs;
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
struct mstdnt_notification* notifs = NULL;
|
||||
size_t notifs_len;
|
||||
|
||||
if (!g_config.changed && cookie)
|
||||
|
@ -48,7 +48,7 @@ void render_base_page(struct base_page* page, mastodont_t* api)
|
|||
}
|
||||
|
||||
// Get / Show notifications on sidebar
|
||||
if (cookies.logged_in)
|
||||
if (cookies.logged_in && cookies.access_token)
|
||||
{
|
||||
struct mstdnt_get_notifications_args args = {
|
||||
.exclude_types = 0,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "../config.h"
|
||||
#include "account.h"
|
||||
#include "easprintf.h"
|
||||
#include "error.h"
|
||||
#include "status.h"
|
||||
#include "lists.h"
|
||||
#include "string_helpers.h"
|
||||
|
@ -71,17 +72,16 @@ void content_lists(mastodont_t* api, char** data, size_t size)
|
|||
|
||||
if (mastodont_get_lists(api, &lists, &storage, &size_list))
|
||||
{
|
||||
lists_format = "An error occured while fetching lists";
|
||||
lists_page = construct_error(storage.error, NULL);
|
||||
}
|
||||
else {
|
||||
lists_format = construct_lists(lists, size_list, NULL);
|
||||
if (!lists_format)
|
||||
lists_format = "Error in malloc!";
|
||||
cleanup = 1;
|
||||
lists_page = construct_lists_view(lists_format, NULL);
|
||||
}
|
||||
|
||||
lists_page = construct_lists_view(lists_format, NULL);
|
||||
|
||||
struct base_page b = {
|
||||
.locale = L10N_EN_US,
|
||||
.content = lists_page,
|
||||
|
|
|
@ -43,7 +43,7 @@ void content_config(mastodont_t* api, char** data, size_t size)
|
|||
struct base_page b = {
|
||||
.locale = L10N_EN_US,
|
||||
.content = data_config_html,
|
||||
.sidebar_left = NULL
|
||||
.sidebar_left = data_config_sidebar_html
|
||||
};
|
||||
|
||||
render_base_page(&b, api);
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#define STRING_HELPERS_H
|
||||
#include <stddef.h>
|
||||
|
||||
/** Returns str. If NULL, returns empty string */
|
||||
#define STR_NULL_EMPTY(str) ((str) ? (str) : "")
|
||||
|
||||
/**
|
||||
* Constructs a string based on a function
|
||||
*
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "reply.h"
|
||||
#include "navigation.h"
|
||||
#include "query.h"
|
||||
#include "string_helpers.h"
|
||||
|
||||
#include "../static/navigation.chtml"
|
||||
|
||||
|
@ -33,10 +34,12 @@ void tl_public(mastodont_t* api, int local)
|
|||
{
|
||||
int cleanup = 0;
|
||||
size_t status_count, statuses_html_count;
|
||||
struct mstdnt_status* statuses;
|
||||
struct mstdnt_status* statuses = NULL;
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
char* status_format, *post_box, *navigation_box;
|
||||
char* output = NULL;
|
||||
char* status_format = NULL,
|
||||
*post_box,
|
||||
*navigation_box = NULL,
|
||||
*output = NULL;
|
||||
char* start_id;
|
||||
|
||||
struct mstdnt_args args = {
|
||||
|
@ -63,16 +66,21 @@ void tl_public(mastodont_t* api, int local)
|
|||
cleanup = 1;
|
||||
}
|
||||
|
||||
// If not set, set it
|
||||
start_id = post.start_id ? post.start_id : statuses[0].id;
|
||||
|
||||
// Create post box
|
||||
post_box = construct_post_box(NULL, "", NULL);
|
||||
navigation_box = construct_navigation_box(start_id,
|
||||
statuses[0].id,
|
||||
statuses[status_count-1].id,
|
||||
NULL);
|
||||
easprintf(&output, "%s%s%s", post_box, status_format, navigation_box);
|
||||
if (statuses)
|
||||
{
|
||||
// If not set, set it
|
||||
start_id = post.start_id ? post.start_id : statuses[0].id;
|
||||
navigation_box = construct_navigation_box(start_id,
|
||||
statuses[0].id,
|
||||
statuses[status_count-1].id,
|
||||
NULL);
|
||||
}
|
||||
easprintf(&output, "%s%s%s",
|
||||
post_box,
|
||||
STR_NULL_EMPTY(status_format),
|
||||
STR_NULL_EMPTY(navigation_box));
|
||||
|
||||
struct base_page b = {
|
||||
.locale = L10N_EN_US,
|
||||
|
|
4
static/config_sidebar.html
Normal file
4
static/config_sidebar.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
<li>
|
||||
<a class="sidebarbtn-sub" href="%s/config/general">%s</a>
|
||||
<a class="sidebarbtn-sub" href="%s/config/appearance">%s</a>
|
||||
</li>
|
Loading…
Reference in a new issue