From 041868d2141906ec43ed7110b3de5d232c434a48 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Wed, 23 Feb 2022 20:19:29 +0000 Subject: [PATCH] Lists base FossilOrigin-Name: c2d8bf314f68cf17f732d9adc9e562ab1ae3c4895e8aae0463fc21ab9fa80ee0 --- Makefile | 4 +++ src/lists.c | 55 ++++++++++++++++++++++++++++++++++++++++++ src/lists.h | 26 ++++++++++++++++++++ src/main.c | 4 ++- src/status.c | 7 +++++- src/test/status_test.h | 16 ++++++++++++ static/list.html | 1 + static/lists.html | 6 +++++ 8 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 src/lists.c create mode 100644 src/lists.h create mode 100644 src/test/status_test.h create mode 100644 static/list.html create mode 100644 static/lists.html diff --git a/Makefile b/Makefile index dab9b70..5d303ad 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,10 @@ $(PAGES_DIR)/login.chtml: $(PAGES_DIR)/login.html ./filec $< data_login_html > $@ $(PAGES_DIR)/post.chtml: $(PAGES_DIR)/post.html ./filec $< data_post_html > $@ +$(PAGES_DIR)/list.chtml: $(PAGES_DIR)/list.html + ./filec $< data_list_html > $@ +$(PAGES_DIR)/lists.chtml: $(PAGES_DIR)/lists.html + ./filec $< data_lists_html > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/src/lists.c b/src/lists.c new file mode 100644 index 0000000..4ac03d1 --- /dev/null +++ b/src/lists.c @@ -0,0 +1,55 @@ +/* + * RatFE - 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 +#include +#include "base_page.h" +#include "../config.h" +#include "account.h" +#include "easprintf.h" +#include "status.h" +#include "lists.h" + +// Files +#include "../static/index.chtml" +#include "../static/account.chtml" +#include "../static/list.chtml" +#include "../static/lists.chtml" + +void construct_list(struct mstdnt_list* list, int* size) +{ + char* list_html; + size_t s = easprintf(&list_html, data_list_html, + ""); + if (size) *size = s; + return list_html; +} + +void content_lists(mastodont_t* api, char** data, size_t size) +{ + struct base_page b = { + .locale = L10N_EN_US, + .content = data_lists_html, + .sidebar_right = NULL + }; + + // Output + render_base_page(&b); + + // Cleanup +} diff --git a/src/lists.h b/src/lists.h new file mode 100644 index 0000000..826a8e2 --- /dev/null +++ b/src/lists.h @@ -0,0 +1,26 @@ +/* + * RatFE - 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 LISTS_H +#define LISTS_H +#include +#include + +void content_lists(mastodont_t* api, char** data, size_t size); + +#endif // LISTS_H diff --git a/src/main.c b/src/main.c index fb91069..1aaecf6 100644 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,7 @@ #include "cookie.h" #include "query.h" #include "status.h" +#include "lists.h" int main(void) { @@ -59,7 +60,8 @@ int main(void) { "/config", content_config }, { "/login", content_login }, { "/@:", content_account }, - { "/status/:", content_status } + { "/status/:", content_status }, + { "/lists", content_lists } }; handle_paths(&api, paths, sizeof(paths)/sizeof(paths[0])); diff --git a/src/status.c b/src/status.c index de2e40e..fe3bcdb 100644 --- a/src/status.c +++ b/src/status.c @@ -97,6 +97,7 @@ char* construct_status(struct mstdnt_status* status, int* size) status->favourited ? "nobutton-active" : "", config_url_prefix, status->id, + config_url_prefix, status->id); if (size) *size = s; return stat_html; @@ -150,13 +151,17 @@ void content_status(mastodont_t* api, char** data, size_t data_size) struct mstdnt_status* statuses_before, *statuses_after, status; size_t stat_before_len, stat_after_len; char* before_html = NULL, *stat_html = NULL, *after_html = NULL; - + +#ifdef _TEST_ +#include "test/status_test.h" +#else mastodont_status_context(api, data[0], &storage, &statuses_before, &statuses_after, &stat_before_len, &stat_after_len); mastodont_view_status(api, data[0], &status_storage, &status); before_html = construct_statuses(statuses_before, stat_before_len, NULL); stat_html = construct_status(&status, NULL); after_html = construct_statuses(statuses_after, stat_after_len, NULL); +#endif easprintf(&output, "%s%s%s", before_html != NULL ? before_html : "", diff --git a/src/test/status_test.h b/src/test/status_test.h new file mode 100644 index 0000000..78b9427 --- /dev/null +++ b/src/test/status_test.h @@ -0,0 +1,16 @@ +/* BEGIN Status_test */ + +struct mstdnt_status status_test = { + .account = { + .avatar = "/ratfe_logo.png", + .display_name = "Test user", + .acct = "user@test.com", + }, + .content = "Hello world

Hi", + +}; +before_html = construct_status(&status_test, NULL); +stat_html = construct_status(&status_test, NULL); +after_html = construct_status(&status_test, NULL); + +/* END Status_test */ diff --git a/static/list.html b/static/list.html new file mode 100644 index 0000000..8b7b968 --- /dev/null +++ b/static/list.html @@ -0,0 +1 @@ +
  • %s
  • diff --git a/static/lists.html b/static/lists.html new file mode 100644 index 0000000..480259b --- /dev/null +++ b/static/lists.html @@ -0,0 +1,6 @@ +

    Lists

    + +