From fb0cd39870e9842c7d4bb5583efff6591ddc4190 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 17 Feb 2018 19:40:47 -0500 Subject: [PATCH] JSON render complete! --- webcit-ng/forum_view.c | 29 ++++++++++++++--------------- webcit-ng/static/js/views.js | 23 ++++++++++++++++++++++- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/webcit-ng/forum_view.c b/webcit-ng/forum_view.c index 6d8a8a3de..fb88eddcd 100644 --- a/webcit-ng/forum_view.c +++ b/webcit-ng/forum_view.c @@ -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? diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index bfa45f5a6..e0f1a49af 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -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 = + "
" // begin message wrapper + + "
" // begin avatar FIXME move to a stylesheet + + " " // FIXME temporary avatar + + "
" // end avatar + + "
" // begin content + + "
" // begin header + + "" // FIXME link to user profile + + msg.from + + " " + + "" + + msg.time + + " " + + "
" // end header + + "
" // begin body + + msg.text + + "
" // end body + + "
" // end content + + "
" // end wrapper + ; } else { -- 2.39.2