Test page

FossilOrigin-Name: a3e4e6962a41699e44210d466e1cd12a374cb6ce323f488256b025f9cd1043c6
This commit is contained in:
me@ow.nekobit.net 2022-03-18 23:48:07 +00:00
parent 53bfbe94a5
commit ab220ccae8
9 changed files with 200 additions and 12 deletions

View file

@ -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

View file

@ -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

29
dist/treebird20.css vendored
View file

@ -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;

View file

@ -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 },

79
src/test.c Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include "test.h"
#include "../config.h"
#include "base_page.h"
#include "easprintf.h"
// Pages
#include "../static/test.chtml"
#define ENV_NOT_FOUND "<span style=\"color:red;\">ENV Not Found</span>"
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);
}

26
src/test.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#ifndef TEST_H
#define TEST_H
#include <stddef.h>
#include <mastodont.h>
void content_test(mastodont_t* api, char** data, size_t data_size);
#endif /* TEST_H */

View file

@ -21,7 +21,7 @@
</form>
</div>
</header>
<table id="content">
<table id="content" class="ui-table">
<!-- Navigation -->
<tr>
<td id="leftbar" class="sidebar">

View file

@ -1,10 +1,10 @@
<table class="status">
<table class="status ui-table">
<tr>
<td class="pfp-td">
<img src="%s" width="56">
</td>
<td class="status-info">
<table>
<table class="ui-table">
<tr>
<td>
<div class="poster-stats">
@ -20,7 +20,7 @@
%s
%s
<div class="status-interact">
<table>
<table class="ui-table">
<tr>
<td>
<form action="%s/status/%s/reply" method="post">

52
static/test.html Normal file
View file

@ -0,0 +1,52 @@
<div class="simple-page">
<h1>Test page</h1>
<p>Test your nginx/apache and browser here</p>
<form action="test" method="get">
<input name="value" type="text">
<input type="submit" value="GET">
</form>
<form action="test" method="post">
<input name="value" type="text">
<input type="submit" value="POST">
</form>
<table id="env-table" class="present">
<tr>
<th><b>ENV</b></th>
<th><b>Value</b></th>
</tr>
<tr>
<td>HTTP_COOKIES</td>
<td>%s</td>
</tr>
<tr>
<td>CONTEXT_PATH</td>
<td>%s</td>
</tr>
<tr>
<td>QUERY_STRING</td>
<td>%s</td>
</tr>
<tr>
<td>REQUEST_METHOD</td>
<td>%s</td>
</tr>
<tr>
<td>SCRIPT_NAME</td>
<td>%s</td>
</tr>
<tr>
<td>HTTP_REFERER</td>
<td>%s</td>
</tr>
<tr>
<td>HTTP_USER_AGENT</td>
<td>%s</td>
</tr>
<tr>
<td>CONTEXT_PATH</td>
<td>%s</td>
</tr>
</table>
</div>