JSON render complete!
authorArt Cancro <ajc@citadel.org>
Sun, 18 Feb 2018 00:40:47 +0000 (19:40 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 18 Feb 2018 00:40:47 +0000 (19:40 -0500)
webcit-ng/forum_view.c
webcit-ng/static/js/views.js

index 6d8a8a3de8c9fbf736211346628d20c2466a69f7..fb88eddcd968221f8fde786d6b254984ae6c354c 100644 (file)
@@ -24,6 +24,20 @@ struct mthread {
 };
 
 
+// Commands we need to send to Citadel Server before we begin rendering forum view.
+// These are common to flat and threaded views.
+//
+void setup_for_forum_view(struct ctdlsession *c)
+{
+       char buf[1024];
+       ctdl_printf(c, "MSGP text/html|text/plain");            // Declare the MIME types we know how to render
+       ctdl_readline(c, buf, sizeof(buf));                     // Ignore the response
+       ctdl_printf(c, "MSGP dont_decode");                     // Tell the server we will decode base64/etc client-side
+       ctdl_readline(c, buf, sizeof(buf));                     // Ignore the response
+}
+
+
+#if 0
 // Renderer for one message in the threaded view
 // (This will probably work for the flat view too.)
 //
@@ -131,21 +145,6 @@ void forum_render_one_message(struct ctdlsession *c, StrBuf *sj, long msgnum)
 }
 
 
-// Commands we need to send to Citadel Server before we begin rendering forum view.
-// These are common to flat and threaded views.
-//
-void setup_for_forum_view(struct ctdlsession *c)
-{
-       char buf[1024];
-       ctdl_printf(c, "MSGP text/html|text/plain");            // Declare the MIME types we know how to render
-       ctdl_readline(c, buf, sizeof(buf));                     // Ignore the response
-       ctdl_printf(c, "MSGP dont_decode");                     // Tell the server we will decode base64/etc client-side
-       ctdl_readline(c, buf, sizeof(buf));                     // Ignore the response
-}
-
-
-#if 0
-
 // This code implements the thread display code.  The thread sorting algorithm is working nicely but we're trying
 // not to do rendering in the C server of webcit.  Maybe move it into the server as "MSGS threaded" or something like that?
 
index bfa45f5a6e3b5f5139a54cc9ce0a64f6af195464..e0f1a49af1312649af322c1de59b304550baa438 100644 (file)
@@ -162,7 +162,28 @@ function render_one(div, msgnum, view)
                {
                        if ((this.status / 100) == 2)
                        {
-                               document.getElementById(div).innerHTML = this.responseText;     // FIXME don't let the C server render it.  do JSON now.
+                               msg = JSON.parse(this.responseText);
+
+                               document.getElementById(div).innerHTML =
+                               "<div>"                                                         // begin message wrapper
+                               + "<div style=\"float:left;padding-right:2px\">"                // begin avatar FIXME move to a stylesheet
+                               + "<i class=\"fa fa-user-circle fa-2x\"></i> "                  // FIXME temporary avatar
+                               + "</div>"                                                      // end avatar
+                               + "<div>"                                                       // begin content
+                               + "<div>"                                                       // begin header
+                               + "<span class=\"ctdl-username\"><a href=\"#\">"                // FIXME link to user profile
+                               + msg.from
+                               + "</a></span> "
+                               + "<span class=\"ctdl-msgdate\">"
+                               + msg.time
+                               + "</span> "
+                               + "</div>"                                                      // end header
+                               + "<div>"                                                       // begin body
+                               + msg.text
+                               + "</div>"                                                      // end body
+                               + "</div>"                                                      // end content
+                               + "</div>"                                                      // end wrapper
+                               ;
                        }
                        else
                        {