From 6796a96ba1c646699cf176130d0f668910c0fad9 Mon Sep 17 00:00:00 2001 From: onefang Date: Mon, 6 Jun 2022 19:21:58 +1000 Subject: Move SledjChisl header and footer to external SSI files. --- example/var/www/html/footer.html | 55 +++++++++++++ example/var/www/html/header.html | 16 ++++ example/var/www/html/headerDebug.html | 26 ++++++ src/sledjchisl/sledjchisl.c | 144 +++++++++------------------------- 4 files changed, 132 insertions(+), 109 deletions(-) create mode 100644 example/var/www/html/footer.html create mode 100644 example/var/www/html/header.html create mode 100644 example/var/www/html/headerDebug.html diff --git a/example/var/www/html/footer.html b/example/var/www/html/footer.html new file mode 100644 index 0000000..f514fb6 --- /dev/null +++ b/example/var/www/html/footer.html @@ -0,0 +1,55 @@ + +
+

Experimental account manager

+

This account manager system is currently experimental, and under heavy development.   + Which means it's not all written yet, and things may break.

+

To create an account, choose a name and password, type them in, click the 'create account' button.

+

On the next page, fill in all your details, then click on the 'confirm' button.

+

We follow the usual web site registration process, which sends a validation email, with a link to click.   + When you get that email, click on the link, or copy it into a web browser.

+

You will then be logged off.   Now you have to wait for an admin to approve your new account.   + They should check with the person you listed as vouching for you first.   They will tell you after they approve your account.

+

Missing bits that are still being written - editing accounts, listing accounts, deleting accounts.

+

Experimental chat thingy

+

In the bottom right corner is an experimental chat thingy, based on Jabber / XMPP.

+

Click on the 'Toggle chat' button to pop it up, then use your grid user name for the 'XMPP Address:' field.   + Your user name has to be in the format 'first.last', two words with a dot in the middle.   + Then put your grid account password in the 'Password' field and click the 'Log in' button.   +

Note that the chat windows can be resized by dragging their top or left edges, which I suggest you do, coz the default size is too small.

+

You can also use any other Jabber / XMPP client as well. So your JID for other clients is first.last@

+

Remember this is EXPERIMENTAL, I'll be changing things.   Next I'll make it so you don't have to log in to both this chat thingy and the account page separataly.

+

P.S.   Yes, I hate the default theme to.   lol

+
+
+ +
+
+
+ + + + + diff --git a/example/var/www/html/header.html b/example/var/www/html/header.html new file mode 100644 index 0000000..b56d057 --- /dev/null +++ b/example/var/www/html/header.html @@ -0,0 +1,16 @@ + + + <!--#echo var="title" --> + + + + + + + + + + + + +
diff --git a/example/var/www/html/headerDebug.html b/example/var/www/html/headerDebug.html new file mode 100644 index 0000000..df0fc99 --- /dev/null +++ b/example/var/www/html/headerDebug.html @@ -0,0 +1,26 @@ + + + <!--#echo var="title" --> + + + + + + + + + + + + + +
+

+

+

DEBUG

+
+

DEBUG log

+ +
+
+

diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index adfc2f9..ec24b22 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -488,7 +488,7 @@ struct _reqData { lua_State *L; qhashtbl_t *configs, *queries, *body, *cookies, *headers, *valid, *stuff, *database, *Rcookies, *Rheaders; - char *Scheme, *Host, *Method, *Script, *Path, *RUri, *doit, *form, *output, *outQuery; + char *Scheme, *Host, *Method, *Script, *Path, *RUri, *doit, *form, *output, *outQuery, *title; sesh shs, *lnk; gridStats *stats; qlist_t *errors, *messages; @@ -4689,53 +4689,6 @@ struct _fragment char *text; }; -static void HTMLdebug(qgrow_t *reply) -{ - reply->addstrf(reply, - "

\n" - "

\n" - "

DEBUG

\n" - "
\n" - "

DEBUG log

\n" - " \n" - "
\n" - "
\n" - "

\n" - ); -} - -static void HTMLheader(qgrow_t *reply, char *title) -{ - reply->addstrf(reply, - "\n" - " \n" - " %s\n" - " \n" - " \n" - " \n" -// " \n" -// " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - - , title); - - if (DEBUG) - reply->addstrf(reply, " \n"); - - reply->addstrf(reply, - " \n" - " \n" - " \n" - ); - reply->addstrf(reply, "
\n"); - if (DEBUG) - HTMLdebug(reply); -} // TODO - maybe escape non printables as well? char *HTMLentities[] = @@ -5056,6 +5009,10 @@ void HTMLfill(reqData *Rd, enum fragmentType type, char *text, int length) outize(Rd->reply, Rd->Rheaders, "Reply HEADERS"); } } + else if (strcmp("host", text) == 0) + Rd->reply->addstrf(Rd->reply, "%s", Rd->Host); + else if (strcmp("title", text) == 0) + Rd->reply->addstrf(Rd->reply, "%s", Rd->title); else if (strcmp("URL", text) == 0) Rd->reply->addstrf(Rd->reply, "%s://%s%s", Rd->Scheme, Rd->Host, Rd->Script); else @@ -5073,66 +5030,6 @@ void HTMLfill(reqData *Rd, enum fragmentType type, char *text, int length) } } -static void HTMLfooter(reqData *Rd) -{ - Rd->reply->addstrf(Rd->reply, "
\n"); - Rd->reply->addstr(Rd->reply, - "
\n" - "

Experimental account manager

\n" - "

This account manager system is currently experimental, and under heavy development.   " - " Which means it's not all written yet, and things may break.

\n" - "

To create an account, choose a name and password, type them in, click the 'create account' button.

" - "

On the next page, fill in all your details, then click on the 'confirm' button.

" - "

We follow the usual web site registration process, which sends a validation email, with a link to click.   " - " When you get that email, click on the link, or copy it into a web browser.

" - "

You will then be logged off.   Now you have to wait for an admin to approve your new account.   " - " They should check with the person you listed as vouching for you first.   They will tell you after they approve your account.

" - "

Missing bits that are still being written - editing accounts, listing accounts, deleting accounts.

\n" - "

Experimental chat thingy

\n" - "

In the bottom right corner is an experimental chat thingy, based on Jabber / XMPP.

\n" - "

Click on the 'Toggle chat' button to pop it up, then use your grid user name for the 'XMPP Address:' field.   " - " Your user name has to be in the format 'first.last', two words with a dot in the middle.   " - " Then put your grid account password in the 'Password' field and click the 'Log in' button.   " - " Ignore the 'Don't have a chat account? Create an account' bit.

\n" - "

Note that the chat windows can be resized by dragging their top or left edges, which I suggest you do, coz the default size is too small.

\n" - "

You can also use any other Jabber / XMPP client as well.

\n" - "

Remember this is EXPERIMENTAL, I'll be changing things.   Next I'll make it so you don't have to log in to both this chat thingy and the account page separataly.

" - "

P.S.   Yes, I hate the default theme to.   lol

\n" - "
\n"); -// Rd->reply->addstr(Rd->reply, "
\n
\n"); - Rd->reply->addstrf(Rd->reply, - "
\n" - " \n" - "
\n" - "
\n" - "
\n" - "
\n" - "\n" - - "\n" - "\n", webHost, webHost, webHost, webHost); -} - - fragment *newFragment(enum fragmentType type, char *text, int len) { fragment *frg = xmalloc(sizeof(fragment)); @@ -5298,9 +5195,36 @@ HTMLfile *checkHTMLcache(char *file) return ret; } +static void HTMLheader(reqData *Rd, /*qgrow_t *reply,*/ char *title) +{ + char *f = NULL; + Rd->title = xmprintf(title); + if (DEBUG) + f = xmprintf("%s%s/headerDebug.html", scRoot, webRoot); + else + f = xmprintf("%s%s/header.html", scRoot, webRoot); + HTMLfile *thisFile = checkHTMLcache(f); + if (NULL != thisFile) + unfragize(thisFile->fragments, Rd, FALSE); + else + E("Can't find %s file!", f); + free(thisFile); + free(f); +} +static void HTMLfooter(reqData *Rd) +{ + char *f = xmprintf("%s%s/footer.html", scRoot, webRoot); + HTMLfile *thisFile = checkHTMLcache(f); + if (NULL != thisFile) + unfragize(thisFile->fragments, Rd, FALSE); + else + E("Can't find %s file!", f); + free(thisFile); + free(f); +} /* TODO - @@ -7067,7 +6991,8 @@ static void accountWebHeaders(reqData *Rd, inputForm *oF) //, char *name) { char *linky = checkLinky(Rd); - HTMLheader(Rd->reply, " account manager"); + Rd->title = xmprintf(" account manager"); + HTMLheader(Rd, " account manager"); Rd->reply->addstrf(Rd->reply, "

account manager

\n"); if (NULL != Rd->shs.name) { @@ -9931,6 +9856,7 @@ fcgiDone: qhashtbl_free(Rd->queries); if (Rd->lnk) free(Rd->lnk); free(Rd->RUri); + free(Rd->title); struct timespec now; if (-1 == clock_gettime(CLOCK_REALTIME, &now)) -- cgit v1.1