beautiful
authorArt Cancro <ajc@citadel.org>
Mon, 13 Dec 2021 01:10:35 +0000 (20:10 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 13 Dec 2021 01:10:35 +0000 (20:10 -0500)
webcit-ng/http.c
webcit-ng/main.c
webcit-ng/request.c
webcit-ng/static.c
webcit-ng/static/js/view_forum.js

index 8daa52afa6985e6a05765307772c095513433da2..47a5bf66b9c2128409bc435f3d194c5ad4aa55a8 100644 (file)
@@ -1,4 +1,3 @@
-//
 // This module handles HTTP transactions.
 //
 // Copyright (c) 1996-2021 by the citadel.org team
@@ -210,19 +209,26 @@ void perform_one_http_transaction(struct client_handle *ch) {
                        h.request_body = malloc(h.request_body_length);
                        client_read(ch, h.request_body, h.request_body_length);
 
-                       //write(2, HKEY("\033[31m"));
-                       //write(2, h.request_body, h.request_body_length);
-                       //write(2, HKEY("\033[0m\n"));
+                       // Write the entire request body to stderr -- not what you want during normal operation.
+                       #ifdef BODY_TO_STDERR
+                       write(2, HKEY("\033[31m"));
+                       write(2, h.request_body, h.request_body_length);
+                       write(2, HKEY("\033[0m\n"));
+                       #endif
 
                }
+
                // Now pass control up to the next layer to perform the request.
                perform_request(&h);
 
-               // Output the results back to the client.
-               //write(2, HKEY("\033[32m"));
-               //write(2, h.response_body, h.response_body_length);
-               //write(2, HKEY("\033[0m\n"));
+               // Write the entire response body to stderr -- not what you want during normal operation.
+               #ifdef BODY_TO_STDERR
+               write(2, HKEY("\033[32m"));
+               write(2, h.response_body, h.response_body_length);
+               write(2, HKEY("\033[0m\n"));
+               #endif
 
+               // Output the results back to the client.
                syslog(LOG_DEBUG, "> %03d %s", h.response_code, h.response_string);
                client_printf(ch, "HTTP/1.1 %03d %s\r\n", h.response_code, h.response_string);
                client_printf(ch, "Connection: close\r\n");
index faf244beecfee27984434afd19111420597298b4..958b4ea40326284bbaa763c6fb85e3c65c5d3362 100644 (file)
@@ -1,4 +1,3 @@
-//
 // Main entry point for the program.
 //
 // Copyright (c) 1996-2021 by the citadel.org team
index 294bcb6527589d18545ccea10b5793ef6e823bec..8ea0893c9f9c7c4be0086e11a1671a05624060f8 100644 (file)
@@ -41,9 +41,7 @@ void do_502(struct http_transaction *h) {
        h->response_code = 502;
        h->response_string = strdup("bad gateway");
        add_response_header(h, strdup("Content-type"), strdup("text/plain"));
-       h->response_body =
-           strdup(_
-                  ("This program was unable to connect or stay connected to the Citadel server.  Please report this problem to your system administrator."));
+       h->response_body = strdup(_("This program was unable to connect or stay connected to the Citadel server.  Please report this problem to your system administrator."));
        h->response_body_length = strlen(h->response_body);
 }
 
@@ -123,11 +121,11 @@ void perform_request(struct http_transaction *h) {
        // WebDAV methods like OPTIONS and PROPFIND *require* a logged-in session,
        // even if the Citadel server allows anonymous access.
        if (IsEmptyStr(c->auth)) {
-               if ((!strcasecmp(h->method, "OPTIONS"))
-                   || (!strcasecmp(h->method, "PROPFIND"))
-                   || (!strcasecmp(h->method, "REPORT"))
-                   || (!strcasecmp(h->method, "DELETE"))
-                   ) {
+               if (    (!strcasecmp(h->method, "OPTIONS"))
+                       || (!strcasecmp(h->method, "PROPFIND"))
+                       || (!strcasecmp(h->method, "REPORT"))
+                       || (!strcasecmp(h->method, "DELETE"))
+               ) {
                        request_http_authenticate(h);
                        disconnect_from_citadel(c);
                        return;
index f2b7811e0fd5a61ad614ca8af6d5fd3d8b5adb99..a523b49289acea2792d4569566f06585dd09558a 100644 (file)
@@ -1,4 +1,3 @@
-//
 // Output static content
 //
 // Copyright (c) 1996-2021 by the citadel.org team
index 79d0cbb11b3d76fceefc0ddc2cbfea1924587686..9116ef328e20a22bc874ba02586c22d8be96b83d 100644 (file)
@@ -13,7 +13,6 @@
 
 
 // Forum view (flat)
-//
 function forum_readmessages(target_div, gt_msg, lt_msg) {
        original_text = document.getElementById(target_div).innerHTML;          // in case we need to replace it after an error
        document.getElementById(target_div).innerHTML = 
@@ -107,7 +106,6 @@ function forum_readmessages(target_div, gt_msg, lt_msg) {
 
 
 // Render a range of messages, with the div prefix specified
-//
 function forum_render_messages(msgs, prefix, scroll_to) {
        for (i=0; i<msgs.length; ++i) {
                forum_render_one(prefix, msgs[i], scroll_to);
@@ -195,16 +193,12 @@ function compose_references(references, msgid) {
        }
        refs += msgid;
 
-       console.log("initial len: " + refs.length);
        // If the resulting string is too big, we can trim it here
        while (refs.length > 900) {
                r = refs.split("|");
                r.splice(1,1);          // remove the second element so we keep the root
                refs = r.join("|");
-               console.log("split len: " + refs.length);
        }
-
-
        return refs;
 }
 
@@ -215,8 +209,6 @@ function open_reply_box(prefix, msgnum, is_quoted, references, msgid) {
        new_div_name = prefix + "reply_to_" + msgnum;
        document.getElementById(target_div_name).outerHTML += "<div id=\"" + new_div_name + "\">reply box put here</div>";
 
-       // FIXME - we need to retain the message number being replied to
-
        replybox =
          "<div class=\"ctdl-msg-wrapper ctdl-msg-reply\">"             // begin message wrapper
        + "<div class=\"ctdl-avatar\">"                                 // begin avatar
@@ -373,9 +365,9 @@ function forum_save_message(div_name, reply_to_msgnum) {
                                for (var i in headers) {
                                        if (headers[i].startsWith("etag: ")) {
                                                new_msg_num = headers[i].split(" ")[1];
-                                               alert("div_name=" + div_name + " , reply_to_msgnum = " + reply_to_msgnum + " , new_msg_num = " + new_msg_num);
                                        }
                                }
+                               alert("div_name=" + div_name + " , reply_to_msgnum = " + reply_to_msgnum + " , new_msg_num = " + new_msg_num);
                                document.getElementById(div_name).outerHTML = "";               // close the editor
                        }
                        else {
@@ -383,7 +375,7 @@ function forum_save_message(div_name, reply_to_msgnum) {
                                if (error_message.length == 0) {
                                        error_message = _("An error has occurred.");
                                }
-                               alert(error_message);
+                               alert(error_message);                                           // editor remains open
                        }
                }
        };