mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:15:10 +00:00
[ADD/MOD/WIP] Mess with lander, try to get quotes
Still WIP-tier for the latter.
This commit is contained in:
parent
1103425912
commit
41a0ae20ea
3 changed files with 188 additions and 98 deletions
|
|
@ -6,110 +6,184 @@
|
|||
|
||||
#include <AS.h>
|
||||
|
||||
static bool
|
||||
HasAdmin(ParseeData *data)
|
||||
{
|
||||
DbRef *admins;
|
||||
HashMap *json;
|
||||
bool ret = false;
|
||||
|
||||
admins = DbLock(data->db, 1, "admins");
|
||||
if (!admins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
json = DbJson(admins);
|
||||
ret = ArraySize(JsonValueAsArray(HashMapGet(json, "admins")));
|
||||
|
||||
DbUnlock(data->db, admins);
|
||||
return ret;
|
||||
}
|
||||
|
||||
RouteHead(RouteRoot, arr, argp)
|
||||
{
|
||||
ParseeHttpArg *args = argp;
|
||||
const ParseeConfig *config = args->data->config;
|
||||
const char *quote = RandInt(2) ?
|
||||
"Kinda jealous of that, to be fair." :
|
||||
"Why look inward when you can challenge the mainstream media?";
|
||||
char *mxid, *jid;
|
||||
char *m_to;
|
||||
|
||||
mxid = ParseeMXID(args->data);
|
||||
m_to = ParseeGenerateMTO(mxid);
|
||||
jid = ParseeJID(args->data);
|
||||
|
||||
HttpResponseHeader(args->ctx, "Content-Type", "text/html");
|
||||
HttpSendHeaders(args->ctx);
|
||||
#define P(...) StreamPrintf(args->stream, __VA_ARGS__)
|
||||
P("<!DOCTYPE html>");
|
||||
P("<html lang='en'>");
|
||||
P(" <head>");
|
||||
P(" <title>%s Lander</title>", NAME);
|
||||
P(" <style>");
|
||||
P(" html {");
|
||||
P(" background-color: #222;");
|
||||
P(" color: #eee;");
|
||||
P(" font-family: sans-serif;");
|
||||
P(" }");
|
||||
P(" blockquote {");
|
||||
P(" border-left: 2px solid #ccc;");
|
||||
P(" margin: 1.5em 10px;");
|
||||
P(" background: #444;");
|
||||
P(" padding: 0.5em;");
|
||||
P(" }");
|
||||
P(" blockquote p {");
|
||||
P(" display: inline-block;");
|
||||
P(" }");
|
||||
P(" </style>");
|
||||
P(" </head>");
|
||||
P(" <body>");
|
||||
P(" <center><h1>");
|
||||
P(" Your %s is running!", NAME);
|
||||
P(" </h1></center>");
|
||||
P(" <hr/>");
|
||||
P(" <blockquote><i>");
|
||||
P(" %s", quote);
|
||||
P(" </i></blockquote>");
|
||||
P(" <p>");
|
||||
P(" Your homeserver now can interact with the bridge, with ");
|
||||
P(" the generated YAML file and Jabber component shared ");
|
||||
P(" secret.");
|
||||
P(" </p>");
|
||||
P(" <p>");
|
||||
P(" You may be interested in sending <code>!help</code> to ");
|
||||
P(" the Matrix <a href='%s'>%s bridge</a>, or pop out ", m_to, NAME);
|
||||
P(" <code>%s</code>'s command list on XMPP as a starter.", jid);
|
||||
P(" </p>");
|
||||
P(" <p>");
|
||||
P(" More information available at ");
|
||||
P(" <a");
|
||||
P(" href='https://kappach.at/parsee'");
|
||||
P(" >the actual page</a>.");
|
||||
P(" </p>");
|
||||
P(" <h2>Permissions?</h2>");
|
||||
P(" <p>");
|
||||
P(" If you have problems running commands, you may want to ");
|
||||
P(" look into if you have set yourself as an admin.");
|
||||
P(" <p>");
|
||||
P(" If you happen to have a build-from-source copy of %s,", NAME);
|
||||
P(" please build all utilities and run ");
|
||||
P(" <code>tools/out/adminify '%s' '[glob]'</code>.", config->db_path);
|
||||
P(" </p>");
|
||||
{
|
||||
P("<head>");
|
||||
{
|
||||
P("<title>%s Lander</title>", NAME);
|
||||
P("<style>");
|
||||
{
|
||||
P("html {");
|
||||
P("background-color: #222;");
|
||||
P("color: #eee;");
|
||||
P("font-family: sans-serif;");
|
||||
P("}");
|
||||
P("blockquote {");
|
||||
P("border-left: 2px solid #ccc;");
|
||||
P("margin: 1.5em 10px;");
|
||||
P("background: #444;");
|
||||
P("padding: 0.5em;");
|
||||
P("}");
|
||||
P("blockquote p {");
|
||||
P("display: inline-block;");
|
||||
P("}");
|
||||
P("a:visited {");
|
||||
P("color: #bedead;");
|
||||
P("}");
|
||||
P("a:link {");
|
||||
P("color: #fad;");
|
||||
P("}");
|
||||
}
|
||||
P("</style>");
|
||||
}
|
||||
P("</head>");
|
||||
|
||||
P(" <h2>Extra information</h2>");
|
||||
P(" <p>");
|
||||
P(" <h3>Dev documentations!!!!</h3>");
|
||||
P(" Developers may be interested into looking up the ");
|
||||
P(" <a href='https://at.kappach.at'>at.kappach.at</a> ");
|
||||
P(" page for extensions used by Parsee on Matrix. ");
|
||||
P(" </p>");
|
||||
P(" <p>");
|
||||
P(" <h3>Parsee statistics</h3>");
|
||||
P("<pre><code>");
|
||||
P("Software: %s (v%s/Cyto %s)\n", NAME, VERSION, CytoplasmGetVersionStr());
|
||||
P("Cytoplasm heap used: %d B\n", MemoryAllocated());
|
||||
P("</code></pre>");
|
||||
P(" </p>");
|
||||
P(" <p>");
|
||||
P(" Some clicky links relating to %s:", NAME);
|
||||
P(" <ul>");
|
||||
P(" <li><a href='%s'>Repository</a></li>", REPOSITORY);
|
||||
P(" <li><a href='%s'>Fediverse</a></li>", "https://ak.ari.lt/parsee");
|
||||
P(" <li>CC0 88x31: <img src='%s' /></li>", "https://kappach.at/parsee.gif");
|
||||
P(" </ul>");
|
||||
P(" </p>");
|
||||
P(" <blockquote><i>");
|
||||
P(" Good luck, and have fun! :D");
|
||||
P(" </i></blockquote>");
|
||||
P(" <p>— LDA</p>");
|
||||
P(" </body>");
|
||||
P("<body>");
|
||||
{
|
||||
P("<center><h1>");
|
||||
P("Your %s is running!", NAME);
|
||||
P("</h1></center>");
|
||||
P("<hr/>");
|
||||
P("<blockquote><i>");
|
||||
{
|
||||
const char *quote = RandInt(2) ?
|
||||
"Kinda jealous of that, to be fair." :
|
||||
"Why look inward when you can challenge the mainstream "
|
||||
"media?";
|
||||
P("%s", quote);
|
||||
}
|
||||
P("</i></blockquote>");
|
||||
|
||||
P("<p>");
|
||||
{
|
||||
P("Your homeserver now can interact with the bridge, with ");
|
||||
P("the generated YAML file and Jabber component shared ");
|
||||
P("secret.");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<p>");
|
||||
{
|
||||
char *mxid, *jid;
|
||||
char *m_to;
|
||||
|
||||
mxid = ParseeMXID(args->data);
|
||||
m_to = ParseeGenerateMTO(mxid);
|
||||
jid = ParseeJID(args->data);
|
||||
|
||||
P("You may be interested in sending <code>!help</code> to ");
|
||||
P("the Matrix <a href='%s'>%s bridge</a>, or pop out ", m_to, NAME);
|
||||
P("<code>%s</code>'s command list on XMPP as a starter.", jid);
|
||||
|
||||
Free(mxid);
|
||||
Free(m_to);
|
||||
Free(jid);
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<p>");
|
||||
{
|
||||
P("More information available at ");
|
||||
P("<a");
|
||||
P("href='https://kappach.at/parsee'");
|
||||
P(">the actual page</a>.");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<h2>Permissions?</h2>");
|
||||
P("<p>");
|
||||
{
|
||||
const char *perms = !HasAdmin(args->data) ?
|
||||
" <strong style='color: red;'>(which I know you do)</strong>" :
|
||||
"";
|
||||
|
||||
P("If you have problems running commands%s, you may want to ", perms);
|
||||
P("look into if you have set yourself as an admin.");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<p>");
|
||||
{
|
||||
P("If you happen to have a build-from-source copy of %s, ", NAME);
|
||||
P("please build all utilities and run ");
|
||||
P("<code>tools/out/adminify '%s' '[glob]'</code>.", config->db_path);
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<h2>Extra information</h2>");
|
||||
P("<p>");
|
||||
{
|
||||
P("<h3>Dev documentations!!!!</h3>");
|
||||
P("Developers may be interested into looking up the ");
|
||||
P("<a href='https://at.kappach.at'>at.kappach.at</a> ");
|
||||
P("page for extensions used by Parsee on Matrix. ");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<h3>Parsee statistics</h3>");
|
||||
P("<p>");
|
||||
{
|
||||
const char *cyto_ver = CytoplasmGetVersionStr();
|
||||
size_t alloc = MemoryAllocated();
|
||||
P("<pre><code>");
|
||||
P("Software: %s (v%s/Cyto %s)\n", NAME, VERSION, cyto_ver);
|
||||
P("Cytoplasm heap used: %d B\n", alloc);
|
||||
P("</code></pre>");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<p>");
|
||||
{
|
||||
P("Some clicky links relating to %s:", NAME);
|
||||
P("<ul>");
|
||||
{
|
||||
const char *fedi = "https://ak.ari.lt/parsee";
|
||||
const char *icon = "https://kappach.at/parsee.gif";
|
||||
P("<li><a href='%s'>Repository</a></li>", REPOSITORY);
|
||||
P("<li><a href='%s'>Fediverse</a></li>", fedi);
|
||||
P("<li>CC0 88x31: <img src='%s' /></li>", icon);
|
||||
}
|
||||
P("</ul>");
|
||||
}
|
||||
P("</p>");
|
||||
|
||||
P("<blockquote><i>");
|
||||
P("Good luck, and have fun! :D");
|
||||
P("</i></blockquote>");
|
||||
P("<p>— LDA</p>");
|
||||
}
|
||||
P("</body>");
|
||||
}
|
||||
P("</html>");
|
||||
#undef P
|
||||
|
||||
Free(mxid);
|
||||
Free(m_to);
|
||||
Free(jid);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue