]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
add preference whether the user prefers to send markdown messages.
[citadel.git] / webcit / messages.c
index 020e81665ca46a1e60d666d723d10da052ab7dfe..3c3c92f6dd2f3b1aced34d0a484c81cfeee63278 100644 (file)
@@ -171,7 +171,7 @@ int load_message(message_summary *Msg,
  * printable_view      Nonzero to display a printable view
  * section             Optional for encapsulated message/rfc822 submessage
  */
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime) 
+int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime, WCTemplputParams *TP
 {
        StrBuf *Buf;
        StrBuf *FoundCharset;
@@ -208,7 +208,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        StrBufTrim(Buf);
        StrBufLowerCase(Buf);
 
-       StackContext(NULL, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
+       StackContext(TP, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
        {
                /* Locate a renderer capable of converting this MIME part into HTML */
                if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
@@ -357,9 +357,9 @@ void handle_one_message(void)
        case ePOST:
                Tmpl = sbstr("template");
                if (StrLength(Tmpl) > 0) 
-                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
                else 
-                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
@@ -416,9 +416,9 @@ void embed_message(void) {
        case ePOST:
                Tmpl = sbstr("template");
                if (StrLength(Tmpl) > 0) 
-                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
                else 
-                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
@@ -455,7 +455,7 @@ void print_message(void) {
 
        begin_burst();
 
-       read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
+       read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime, NULL);
 
        wDumpContent(0);
 }
@@ -476,7 +476,7 @@ void display_headers(void) {
                PACKAGE_STRING);
        begin_burst();
 
-       serv_printf("MSG2 %ld|3", msgnum);
+       serv_printf("MSG2 %ld|1", msgnum);
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') {
                while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -1221,7 +1221,7 @@ void upload_attachment(void) {
        att->length = WCC->upload_length;
        att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
        att->FileName = NewStrBufDup(WCC->upload_filename);
-       UID = SBSTR("qquuid");
+       UID = sbstr("qquuid");
        if (UID)
                att->PartNum = NewStrBufDup(UID);
 
@@ -1366,6 +1366,10 @@ void display_enter(void)
        int i = 0;
        long replying_to;
 
+       int prefer_md;
+
+       get_pref_yesno("markdown", &prefer_md, 0);
+
        if (havebstr("force_room")) {
                gotoroom(sbstr("force_room"));
        }
@@ -1695,7 +1699,7 @@ void display_enter(void)
 
        begin_burst();
        output_headers(1, 0, 0, 0, 1, 0);
-       if (WCC->CurRoom.defview == VIEW_WIKIMD) 
+       if ((WCC->CurRoom.defview == VIEW_WIKIMD) || prefer_md)
                DoTemplate(HKEY("edit_markdown_epic"), NULL, &NoCtx);
        else
                DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
@@ -2056,6 +2060,8 @@ InitModule_MSG
                           PRF_STRING, 
                           NULL);
        RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
+       RegisterPreference("markdown",_("Prefer markdown editing"), PRF_YESNO, NULL);
+
 
        WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, ANONYMOUS|NEED_URL);
        WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, ANONYMOUS|NEED_URL);