From 16ba91984a706306e0c646e0a40f66b719e7905f Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Wed, 23 Mar 2022 14:52:25 +0000 Subject: [PATCH] Content not found FossilOrigin-Name: 0847fd853e3fdaac04c00550d98d6429e39ba996e74efd574f1944029d0fdc71 --- Makefile | 2 ++ dist/treebird20.css | 6 ++++++ src/error.c | 22 +++++++++++++++++++++- src/error.h | 2 ++ src/page_config.c | 2 -- src/path.c | 4 ++++ static/error_404.html | 4 ++++ 7 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 static/error_404.html diff --git a/Makefile b/Makefile index 4356168..185aba3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dist/treebird20.css b/dist/treebird20.css index ac8595c..7eb52a5 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -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 { diff --git a/src/error.c b/src/error.c index d9c5c50..7ea3259 100644 --- a/src/error.c +++ b/src/error.c @@ -15,11 +15,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include +#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); +} diff --git a/src/error.h b/src/error.h index 8962553..4ac020f 100644 --- a/src/error.h +++ b/src/error.h @@ -18,8 +18,10 @@ #ifndef ERROR_H #define ERROR_H +#include #include char* construct_error(char* message, size_t* size); +void content_not_found(mastodont_t* api, char* path); #endif // ERROR_H diff --git a/src/page_config.c b/src/page_config.c index e4e9d4b..5610746 100644 --- a/src/page_config.c +++ b/src/page_config.c @@ -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; diff --git a/src/path.c b/src/path.c index 9bdb484..987d76a 100644 --- a/src/path.c +++ b/src/path.c @@ -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); } } diff --git a/static/error_404.html b/static/error_404.html new file mode 100644 index 0000000..06a5f02 --- /dev/null +++ b/static/error_404.html @@ -0,0 +1,4 @@ +
+

404

+

%s

+