diff --git a/Makefile b/Makefile index 83ca8d3..5b8342a 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ $(PAGES_DIR)/emoji_reactions.chtml: $(PAGES_DIR)/emoji_reactions.html ./filec $< data_emoji_reactions_html > $@ $(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 > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/config.h b/config.h index 00a4c03..a1fe190 100644 --- a/config.h +++ b/config.h @@ -12,7 +12,7 @@ #define TRUE 1 /* - * String: config_canonical_name + * String: canonical_name * * The software's recognizable name. * @@ -23,7 +23,7 @@ static char* const config_canonical_name = "treebird"; /* - * String: config_instance_url + * String: instance_url * * The instances URL which all API calls will be sent to via mastodont-c. * This MUST include a slash at the end, and the protocol (like https://) at the @@ -34,7 +34,7 @@ static char* const config_canonical_name = "treebird"; static char* const config_instance_url = "https://desuposter.club/"; /* - * String: config_url_prefix + * String: url_prefix * * The prefix for all urls. * For most cases, when you are proxying the CGI paths to root, this will be left blank. @@ -56,4 +56,12 @@ static char* const config_url_prefix = "/treebird.cgi"; */ static const int config_experimental_lookup = TRUE; +/* + * Bool: test_page + * + * Enables the test page which dumps all CGI cookies, useful when + * setting up a reverse proxy + */ +static const unsigned config_test_page = TRUE; + #endif // CONFIG_H diff --git a/dist/treebird20.css b/dist/treebird20.css index 9e9c756..1806e3e 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -14,7 +14,7 @@ body } /* Cleans up most of the tables */ -td +table.ui-table td { padding: 0; margin: 0; @@ -121,6 +121,25 @@ td list-style-type: none; } +/************************************************* + * COMMON ELEMENTS * + *************************************************/ + +table.present +{ + border: 1px solid #cacaca; +} + +table.present th, table.present td +{ + padding: 2px 5px; +} + +#env-table +{ + margin-top: 5px; +} + /************************************************* * BUTTONS * *************************************************/ @@ -231,12 +250,12 @@ ul li:first-child a.sidebarbtn display: flex; } -.status .status-info > table +.status .status-info > table.ui-table { width: 100%; } -.status .status-info table, .status .status-info td, .status .status-info tr +.status .status-info table.ui-table, .status .status-info table.ui-table td, .status .status-info table.ui-table tr { border-collapse: collapse !important; padding: 0; @@ -293,13 +312,13 @@ ul li:first-child a.sidebarbtn margin: 8px 0 0 0; } -.status-interact table +.status-interact table.ui-table { border-collapse: collapse !important; padding: 0; } -.status-interact table tr +.status-interact table.ui-table tr { border-collapse: collapse !important; padding: 0; diff --git a/src/main.c b/src/main.c index f932c2d..2b2447c 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,7 @@ #include "status.h" #include "lists.h" #include "timeline.h" +#include "test.h" int main(void) { @@ -59,6 +60,7 @@ int main(void) struct path_info paths[] = { { "/config", content_config }, { "/login", content_login }, + { "/test", content_test }, { "/@:", content_account }, { "/status/:/interact", status_interact }, { "/status/:/reply", status_reply }, diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..4f5d6eb --- /dev/null +++ b/src/test.c @@ -0,0 +1,79 @@ +/* + * 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 +#include +#include "test.h" +#include "../config.h" +#include "base_page.h" +#include "easprintf.h" + +// Pages +#include "../static/test.chtml" + +#define ENV_NOT_FOUND "ENV Not Found" + +enum env_tbl_index +{ + ENV_HTTP_COOKIES = 0, + ENV_CONTEXT_PATH, + ENV_QUERY_STRING, + ENV_REQUEST_METHOD, + ENV_SCRIPT_NAME, + ENV_HTTP_REFERER, + ENV_HTTP_USER_AGENT, + ENV_CONTENT_LENGTH, +}; + +#define ENV_TBL_GET(index) (env_tbl[(index)] ? env_tbl[(index)] : ENV_NOT_FOUND) + +void content_test(mastodont_t* api, char** data, size_t data_size) +{ + char* env_tbl[] = { + getenv("HTTP_COOKIES"), + getenv("CONTEXT_PATH"), + getenv("QUERY_STRING"), + getenv("REQUEST_METHOD"), + getenv("SCRIPT_NAME"), + getenv("HTTP_REFERER"), + getenv("HTTP_USER_AGENT"), + getenv("CONTENT_LENGTH") + }; + + char* page; + easprintf(&page, + data_test_html, + ENV_TBL_GET(ENV_HTTP_COOKIES), + ENV_TBL_GET(ENV_CONTEXT_PATH), + ENV_TBL_GET(ENV_QUERY_STRING), + ENV_TBL_GET(ENV_REQUEST_METHOD), + ENV_TBL_GET(ENV_SCRIPT_NAME), + ENV_TBL_GET(ENV_HTTP_REFERER), + ENV_TBL_GET(ENV_HTTP_USER_AGENT), + ENV_TBL_GET(ENV_CONTEXT_PATH)); + + struct base_page b = { + .locale = L10N_EN_US, + .content = page, + .sidebar_right = NULL + }; + + // Output + render_base_page(&b); + if (page) free(page); +} diff --git a/src/test.h b/src/test.h new file mode 100644 index 0000000..57105b4 --- /dev/null +++ b/src/test.h @@ -0,0 +1,26 @@ +/* + * 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 TEST_H +#define TEST_H +#include +#include + +void content_test(mastodont_t* api, char** data, size_t data_size); + +#endif /* TEST_H */ diff --git a/static/index.html b/static/index.html index be08f29..5e4b234 100644 --- a/static/index.html +++ b/static/index.html @@ -21,7 +21,7 @@ - +