]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* if we need the first urlpart, we musn't move it just left, but add another one...
[citadel.git] / webcit / webcit.c
index 1983f166fd9a8fbae12b91be5161a35df845e621..d6aa8a0d2d26b8f9b7d152b2de6201a14ab8f50e 100644 (file)
@@ -171,7 +171,7 @@ void dump_vars(void)
        const char *HKey;
        HashPos *Cursor;
        
-       Cursor = GetNewHashPos ();
+       Cursor = GetNewHashPos (WCC->urlstrings, 0);
        while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) {
                u = (urlcontent*) U;
                wprintf("%38s = %s\n", u->url_key, ChrPtr(u->url_data));
@@ -382,8 +382,13 @@ void hprintf(const char *format,...)
 }
 
 
-void put_trailing_javascript(void) {
-       wprintf("%s", ChrPtr(WC->trailing_javascript));
+void tmplput_trailing_javascript(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+{
+       struct wcsession *WCC = WC;
+
+       if (WCC != NULL)
+               StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType,
+                                    WCC->trailing_javascript, 0);
 }
 
 /*
@@ -397,7 +402,6 @@ void wDumpContent(int print_standard_html_footer)
 {
        if (print_standard_html_footer) {
                wprintf("</div> <!-- end of 'content' div -->\n");
-               svcallback("TRAILING_JAVASCRIPT", put_trailing_javascript);
                do_template("trailing", NULL);
        }
 
@@ -789,7 +793,7 @@ void print_menu_box(char* Title, char *Class, int nLines, ...)
        long i;
        
        svput("BOXTITLE", WCS_STRING, Title);
-       do_template("beginbox", NULL);
+       do_template("beginboxx", NULL);
        
        wprintf("<ul class=\"%s\">", Class);
        
@@ -923,7 +927,7 @@ void display_vcard_photo_img(void)
        const char *contentType;
        struct wcsession *WCC = WC;
 
-       msgnum = StrTol(WCC->UrlFragment1);
+       msgnum = StrTol(WCC->UrlFragment2);
        
        vcard = load_mimepart(msgnum,"1");
        v = vcard_load(vcard);
@@ -1807,8 +1811,11 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                                                WCC->UrlFragment1 = NewStrBuf();
                                        if (WCC->UrlFragment2 == NULL)
                                                WCC->UrlFragment2 = NewStrBuf();
-                                       StrBufPrintf(WCC->UrlFragment1, "%s", index[1]);
-                                       StrBufPrintf(WCC->UrlFragment2, "%s", index[2]);
+                                       if (WCC->UrlFragment3 == NULL)
+                                               WCC->UrlFragment3 = NewStrBuf();
+                                       StrBufPrintf(WCC->UrlFragment1, "%s", index[0]);
+                                       StrBufPrintf(WCC->UrlFragment2, "%s", index[1]);
+                                       StrBufPrintf(WCC->UrlFragment3, "%s", index[2]);
                                }
                                if ((Handler->Flags & AJAX) != 0)
                                        begin_ajax_response();
@@ -1860,6 +1867,8 @@ void diagnostics(void)
        StrEscPuts(WC->UrlFragment1);
        wprintf("<br />\n");
        StrEscPuts(WC->UrlFragment2);
+       wprintf("<br />\n");
+       StrEscPuts(WC->UrlFragment3);
        wprintf("</PRE><hr />\n");
        wprintf("Variables: <br /><PRE>\n");
        dump_vars();
@@ -1868,26 +1877,26 @@ void diagnostics(void)
 }
 
 void view_mimepart(void) {
-       mimepart(ChrPtr(WC->UrlFragment1),
-                ChrPtr(WC->UrlFragment2),
+       mimepart(ChrPtr(WC->UrlFragment2),
+                ChrPtr(WC->UrlFragment3),
                 0);
 }
 
 void download_mimepart(void) {
-       mimepart(ChrPtr(WC->UrlFragment1),
-                ChrPtr(WC->UrlFragment2),
+       mimepart(ChrPtr(WC->UrlFragment2),
+                ChrPtr(WC->UrlFragment3),
                 1);
 }
 
 void view_postpart(void) {
-       postpart(WC->UrlFragment1,
-                WC->UrlFragment2,
+       postpart(WC->UrlFragment2,
+                WC->UrlFragment3,
                 0);
 }
 
 void download_postpart(void) {
-       postpart(WC->UrlFragment1,
-                WC->UrlFragment2,
+       postpart(WC->UrlFragment2,
+                WC->UrlFragment3,
                 1);
 }
 
@@ -1906,8 +1915,12 @@ void tmplput_importantmessage(StrBuf *Target, int nArgs, WCTemplateToken *Tokens
        struct wcsession *WCC = WC;
        
        if (WCC != NULL) {
+/*
+               StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
+                                    WCC->ImportantMessage, 0);
+*/
                StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
-                       WCC->ImportantMessage[0] = '\0';
+               WCC->ImportantMessage[0] = '\0';
        }
 }
 
@@ -1924,9 +1937,12 @@ int ConditionalBstr(WCTemplateToken *Tokens, void *Context, int ContextType)
 
 void tmplput_bstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
 {
-       StrBufAppendBuf(Target, 
-                       SBstr(Tokens->Params[0]->Start, 
-                             Tokens->Params[0]->len), 0);
+       const StrBuf *Buf = SBstr(Tokens->Params[0]->Start, 
+                           Tokens->Params[0]->len);
+       if (Buf != NULL)
+               StrBufAppendTemplate(Target, nArgs, Tokens, 
+                                    Context, ContextType,
+                                    Buf, 1);
 }
 
 
@@ -1937,7 +1953,23 @@ void tmplput_csslocal(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *
                        csslocal, 0);
 }
 
+void tmplput_url_part(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+       StrBuf *UrlBuf;
+       struct wcsession *WCC = WC;
+       
+       if (WCC != NULL) {
+               if (Tokens->Params[0]->lvalue == 0)
+                       UrlBuf = WCC->UrlFragment1;
+               else if (Tokens->Params[0]->lvalue == 1)
+                       UrlBuf = WCC->UrlFragment2;
+               else
+                       UrlBuf = WCC->UrlFragment3;
 
+               StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
+                                    UrlBuf, 1);
+       }
+}
 
 
 
@@ -1962,7 +1994,9 @@ InitModule_WEBCIT
        RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
        RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr, CTX_NONE);
        RegisterNamespace("BSTR", 1, 2, tmplput_bstr, CTX_NONE);
+       RegisterNamespace("URLPART", 1, 2, tmplput_url_part, CTX_NONE);
        RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE);
        RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
        RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE);
+       RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, CTX_NONE);
 }