From c407aac8ce3df1dd28f925427251d020bebffa37 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Sat, 19 Mar 2022 03:59:20 +0000 Subject: [PATCH] Notifications base FossilOrigin-Name: 33576b114c13138c386df1a1c65c45a6e045586363edd398d78a4e84cdf10687 --- Makefile | 8 +++++ src/main.c | 4 +-- src/notifications.c | 50 ++++++++++++++++++++++++++++++++ src/notifications.h | 25 ++++++++++++++++ static/notification.html | 1 + static/notification_compact.html | 1 + static/notifications.html | 3 ++ static/notifications_page.html | 4 +++ 8 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/notifications.c create mode 100644 src/notifications.h create mode 100644 static/notification.html create mode 100644 static/notification_compact.html create mode 100644 static/notifications.html create mode 100644 static/notifications_page.html diff --git a/Makefile b/Makefile index 5b8342a..8242936 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,14 @@ $(PAGES_DIR)/emoji_reaction.chtml: $(PAGES_DIR)/emoji_reaction.html ./filec $< data_emoji_reaction_html > $@ $(PAGES_DIR)/test.chtml: $(PAGES_DIR)/test.html ./filec $< data_test_html > $@ +$(PAGES_DIR)/notifications_page.chtml: $(PAGES_DIR)/notifications_page.html + ./filec $< data_notifications_page_html > $@ +$(PAGES_DIR)/notifications.chtml: $(PAGES_DIR)/notifications.html + ./filec $< data_notifications_html > $@ +$(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 > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/src/main.c b/src/main.c index 2b2447c..396ca7a 100644 --- a/src/main.c +++ b/src/main.c @@ -32,12 +32,11 @@ #include "status.h" #include "lists.h" #include "timeline.h" +#include "notifications.h" #include "test.h" int main(void) { - // Content type is always HTML - // Global init mastodont_global_curl_init(); @@ -69,6 +68,7 @@ int main(void) { "/lists", content_lists }, { "/federated", content_tl_federated }, { "/local", content_tl_local }, + { "/notifications", content_notifications }, }; handle_paths(&api, paths, sizeof(paths)/sizeof(paths[0])); diff --git a/src/notifications.c b/src/notifications.c new file mode 100644 index 0000000..47d9f83 --- /dev/null +++ b/src/notifications.c @@ -0,0 +1,50 @@ +/* + * Treebird - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "notifications.h" +#include "base_page.h" +#include "string_helpers.h" +#include "easprintf.h" + +// Pages +#include "../static/notifications_page.chtml" + +static char* construct_notifications_voidwrap(void* passed, size_t index, int* res) +{ + return construct_notifications((struct mstdnt_notification*)passed + index, res); +} + +char* construct_notifications(struct mstdnt_notification* notifs, size_t size, size_t* ret_size) +{ + return construct_func_strings(construct_notifications_voidwrap, notifs, size, ret_size); +} + +void content_notifications(mastodont_t* api, char** data, size_t data_size) +{ + + + struct base_page b = { + .locale = L10N_EN_US, + .content = data_notifications_page_html, + .sidebar_right = NULL + }; + + // Output + render_base_page(&b); +} + diff --git a/src/notifications.h b/src/notifications.h new file mode 100644 index 0000000..26f5f97 --- /dev/null +++ b/src/notifications.h @@ -0,0 +1,25 @@ +/* + * Treebird - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef NOTIFICATIONS_H +#define NOTIFICATIONS_H +#include + +void content_notifications(mastodont_t* api, char** data, size_t data_size); + +#endif // NOTIFICATION_H diff --git a/static/notification.html b/static/notification.html new file mode 100644 index 0000000..07552d0 --- /dev/null +++ b/static/notification.html @@ -0,0 +1 @@ +notif diff --git a/static/notification_compact.html b/static/notification_compact.html new file mode 100644 index 0000000..dea51b2 --- /dev/null +++ b/static/notification_compact.html @@ -0,0 +1 @@ +notif_compact diff --git a/static/notifications.html b/static/notifications.html new file mode 100644 index 0000000..1de5c6a --- /dev/null +++ b/static/notifications.html @@ -0,0 +1,3 @@ +
    + +
diff --git a/static/notifications_page.html b/static/notifications_page.html new file mode 100644 index 0000000..8906585 --- /dev/null +++ b/static/notifications_page.html @@ -0,0 +1,4 @@ +
+

Notifications

+ %s +