]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* follow api-change in several places
[citadel.git] / webcit / webcit.c
index c4fd3648c431acc66e7a9bf098c6cb35c8ebf812..095082ccb8b55a5998de9b9348b0c462fa0f2c7d 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);
        }
 
@@ -758,10 +762,12 @@ void http_redirect(const char *whichpage) {
 void http_transmit_thing(const char *content_type,
                         int is_static) {
 
+#ifndef TECH_PREVIEW
        lprintf(9, "http_transmit_thing(%s)%s\n",
                content_type,
                (is_static ? " (static)" : "")
        );
+#endif
        output_headers(0, 0, 0, 0, 0, is_static);
 
        hprintf("Content-type: %s\r\n"
@@ -787,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);
        
@@ -856,7 +862,9 @@ void output_static(char *what)
 
 
                close(fd);
+#ifndef TECH_PREVIEW
                lprintf(9, "output_static('%s')  %s\n", what, content_type);
+#endif
                http_transmit_thing(content_type, 1);
        }
        if (yesbstr("force_close_session")) {
@@ -1902,8 +1910,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';
        }
 }
 
@@ -1920,9 +1932,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);
 }
 
 
@@ -1933,7 +1948,21 @@ 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
+                       UrlBuf = WCC->UrlFragment2;
 
+               StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
+                                    UrlBuf, 1);
+       }
+}
 
 
 
@@ -1958,7 +1987,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);
 }