Content not found

FossilOrigin-Name: 0847fd853e3fdaac04c00550d98d6429e39ba996e74efd574f1944029d0fdc71
This commit is contained in:
me@ow.nekobit.net 2022-03-23 14:52:25 +00:00
parent 9f7b4e7cd5
commit 16ba91984a
7 changed files with 39 additions and 3 deletions

View file

@ -62,6 +62,8 @@ $(PAGES_DIR)/notification.chtml: $(PAGES_DIR)/notification.html
./filec $< data_notification_html > $@
$(PAGES_DIR)/notification_compact.chtml: $(PAGES_DIR)/notification_compact.html
./filec $< data_notification_compact_html > $@
$(PAGES_DIR)/error_404.chtml: $(PAGES_DIR)/error_404.html
./filec $< data_error_404_html > $@
$(MASTODONT_DIR):
git clone $(MASTODONT_URL) || true

6
dist/treebird20.css vendored
View file

@ -626,6 +626,12 @@ ul li:first-child a.sidebarbtn
padding-left: 15px;
}
.simple-page p
{
margin-left: 10px;
margin-right: 10px;
}
/* Attachments */
.attachments img
{

View file

@ -15,11 +15,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "base_page.h"
#include "error.h"
#include "easprintf.h"
#include "l10n.h"
// Pages
#include "../static/error_404.chtml"
#include "../static/error.chtml"
char* construct_error(char* error, size_t* size)
@ -30,3 +33,20 @@ char* construct_error(char* error, size_t* size)
if (size) *size = s;
return error_html;
}
void content_not_found(mastodont_t* api, char* path)
{
char* page;
easprintf(&page,
data_error_404_html,
L10N[L10N_EN_US][L10N_PAGE_NOT_FOUND]);
struct base_page b = {
.locale = L10N_EN_US,
.content = page,
.sidebar_right = NULL
};
render_base_page(&b, api);
free(page);
}

View file

@ -18,8 +18,10 @@
#ifndef ERROR_H
#define ERROR_H
#include <mastodont.h>
#include <stddef.h>
char* construct_error(char* message, size_t* size);
void content_not_found(mastodont_t* api, char* path);
#endif // ERROR_H

View file

@ -32,8 +32,6 @@
void content_config(mastodont_t* api, char** data, size_t size)
{
(void)api; // No need to use this
if (post.theme)
{
g_config.theme = post.theme;

View file

@ -21,6 +21,7 @@
#include "path.h"
#include "index.h"
#include "account.h"
#include "error.h"
enum path_state
{
@ -127,5 +128,8 @@ void handle_paths(mastodont_t* api, struct path_info* paths, size_t paths_len)
if (parse_path(api, paths + i) == 0)
return;
}
// Fell out, return 404
content_not_found(api, path);
}
}

4
static/error_404.html Normal file
View file

@ -0,0 +1,4 @@
<div class="simple-page">
<h1>404</h1>
<p>%s</p>
</div>