* templatize manual post
authorWilfried Göesgens <willi@citadel.org>
Thu, 22 Jul 2010 21:02:58 +0000 (21:02 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 22 Jul 2010 21:02:58 +0000 (21:02 +0000)
webcit/mainmenu.c
webcit/static/t/aide/display_generic_cmd.html [new file with mode: 0644]
webcit/static/t/aide/display_generic_result.html [new file with mode: 0644]

index b2831714b5f47284fb54c7e52dd50b712c0b3779..6bb1171a5665bbc386221db4479c3a3312a240bb 100644 (file)
@@ -28,60 +28,15 @@ void display_aide_menu(void)
 }
 
 
-
-/*
- * Display the screen to enter a generic server command
- */
-void display_generic(void)
-{
-       output_headers(1, 1, 2, 0, 0, 0);
-       wc_printf("<div id=\"banner\">\n");
-       wc_printf("<h1>");
-       wc_printf(_("Enter a server command"));
-       wc_printf("</h1>");
-       wc_printf("</div>\n");
-
-       wc_printf("<div id=\"content\" class=\"service\">\n");
-
-       wc_printf("<div class=\"fix_scrollbar_bug\">"
-               "<table class=\"mainmenu_background\"><tr><td>\n");
-
-       wc_printf("<center>");
-       wc_printf(_("This screen allows you to enter Citadel server commands which are "
-               "not supported by WebCit.  If you do not know what that means, "
-               "then this screen will not be of much use to you."));
-       wc_printf("<br />\n");
-
-       wc_printf("<form method=\"post\" action=\"do_generic\">\n");
-       wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
-       wc_printf(_("Enter command:"));
-       wc_printf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
-
-       wc_printf(_("Command input (if requesting SEND_LISTING transfer mode):"));
-       wc_printf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
-
-       wc_printf("<font size=-2>");
-       wc_printf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), ChrPtr(WC->Hdr->HR.http_host));
-       wc_printf("</font>\n");
-       wc_printf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
-       wc_printf("&nbsp;");
-       wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
-
-       wc_printf("</form></center>\n");
-       wc_printf("</td></tr></table></div>\n");
-       wDumpContent(1);
-}
-
 /*
  * Interactive window to perform generic Citadel server commands.
  */
 void do_generic(void)
 {
-
-       wcsession *WCC = WC;
+        WCTemplputParams SubTP;
        int Done = 0;
        StrBuf *Buf;
+       StrBuf *LineBuf;
        char *junk;
        size_t len;
 
@@ -90,38 +45,34 @@ void do_generic(void)
                return;
        }
 
-       output_headers(1, 1, 0, 0, 0, 0);
+        memset(&SubTP, 0, sizeof(WCTemplputParams));
        Buf = NewStrBuf();
        serv_puts(bstr("g_cmd"));
        StrBuf_ServGetln(Buf);
-       svput("BOXTITLE", WCS_STRING, _("Server command results"));
-       do_template("beginboxx", NULL);
-
-       wc_printf("<table border=0><tr><td>Command:</td><td><tt>");
-       StrEscAppend(WCC->WBuf, sbstr("g_cmd"), NULL, 0, 0);
-       wc_printf("</tt></td></tr><tr><td>Result:</td><td><tt>");
-       StrEscAppend(WCC->WBuf, Buf, NULL, 0, 0);
-       StrBufAppendBufPlain(WCC->WBuf, HKEY("<br>\n"), 0);
-       wc_printf("</tt></td></tr></table><br />\n");
        
        switch (GetServerStatus(Buf, NULL)) {
        case 8:
                serv_puts("\n\n000");
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
-                       StrBufAppendBufPlain(WCC->WBuf, HKEY("\000"), 0);
+                       StrBufAppendBufPlain(Buf, HKEY("\000"), 0);
                        break;
                }
        case 1:
+               LineBuf = NewStrBuf();
+               StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
                while (!Done) {
-                       StrBuf_ServGetln(Buf);
-                       if ( (StrLength(Buf)==3) && 
-                            !strcmp(ChrPtr(Buf), "000")) {
+                       StrBuf_ServGetln(LineBuf);
+                       if ( (StrLength(LineBuf)==3) && 
+                            !strcmp(ChrPtr(LineBuf), "000")) {
                                Done = 1;
                        }
-                       StrEscAppend(WCC->WBuf, Buf, NULL, 0, 0);
-                       StrBufAppendBufPlain(WCC->WBuf, HKEY("<br>\n"), 0);
+                       StrBufAppendBuf(Buf, LineBuf, 0);
+                       StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
                }
+               FreeStrBuf(&LineBuf);
+               break;
+       case 2:
                break;
        case 4:
                text_to_server(bstr("g_input"));
@@ -137,47 +88,22 @@ void do_generic(void)
                memset(junk, 0, len);
                serv_write(junk, len);
                free(junk);
+               break;
        }
        
-       wc_printf("<hr />");
-       wc_printf("<a href=\"display_generic\">Enter another command</a><br />\n");
-       wc_printf("<a href=\"display_advanced\">Return to menu</a>\n");
-       do_template("endbox", NULL);
-       FreeStrBuf(&Buf);
-       wDumpContent(1);
-}
-
-
-/*
- * Display the menubar.  
- *
- * Set 'as_single_page' to display HTML headers and footers -- otherwise it's assumed
- * that the menubar is being embedded in another page.
- */
-void display_menubar(int as_single_page) {
-
-       if (as_single_page) {
-               output_headers(0, 0, 0, 0, 0, 0);
-               wc_printf("<html>\n"
-                       "<head>\n"
-                       "<title>MenuBar</title>\n"
-                       "<style type=\"text/css\">\n"
-                       "body   { text-decoration: none; }\n"
-                       "</style>\n"
-                       "</head>\n");
-               do_template("background", NULL);
-       }
+       begin_burst();
+       output_headers(1, 0, 0, 0, 1, 0);
 
-       do_template("menubar", NULL);
+        SubTP.Filter.ContextType = CTX_STRBUF;
+        SubTP.Context = Buf;
 
-       if (as_single_page) {
-               wDumpContent(2);
-       }
+        DoTemplate(HKEY("aide_display_generic_result"), NULL, &SubTP);
 
+        wDumpContent(1);
 
+       FreeStrBuf(&Buf);
 }
 
-
 /*
  * Display the wait / input dialog while restarting the server.
  */
@@ -244,8 +170,6 @@ void display_shutdown(void)
        }
 }
 
-void _display_menubar(void) { display_menubar(0); }
-
 void 
 InitModule_MAINMENU
 (void)
@@ -253,7 +177,5 @@ InitModule_MAINMENU
        WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
        WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
        WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
-       WebcitAddUrlHandler(HKEY("display_generic"), "", 0, display_generic, 0);
        WebcitAddUrlHandler(HKEY("do_generic"), "", 0, do_generic, 0);
-       WebcitAddUrlHandler(HKEY("display_menubar"), "", 0, _display_menubar, 0);
 }
diff --git a/webcit/static/t/aide/display_generic_cmd.html b/webcit/static/t/aide/display_generic_cmd.html
new file mode 100644 (file)
index 0000000..549229b
--- /dev/null
@@ -0,0 +1,32 @@
+<?=("head")>
+<div id="banner">
+  <h1>
+    <?_("Enter a server command")>
+  </h1>
+</div>
+
+<div id="content" class="service">
+  <div class="fix_scrollbar_bug">
+    <??("COND:AIDE", 1)>
+    <table class="mainmenu_background"><tr><td>
+
+         <center><?_("This screen allows you to enter Citadel server commands which are not supported by WebCit.  If you do not know what that means, then this screen will not be of much use to you.")><br />
+           <form method="post" action="do_generic">
+             <input type="hidden" name="nonce" value="<?NONCE>">
+             <?_("Enter command:")><br />
+             <input type="text" name="g_cmd" size=80 maxlength="250"><br />
+             <?_("Command input (if requesting SEND_LISTING transfer mode):")><br />
+             <textarea name="g_input" rows=10 cols=80 width=80></textarea><br />
+             <font size=-2>
+               <?_("Detected host header is ")><?%("COND:IS_HTTPS", 1, 1, 1, "https", "http")>://<?URL:HOSTNAME>
+             </font>
+             <input type="submit" name="sc_button" value="<?_("Send command")>">&nbsp;
+             <input type="submit" name="cancel_button" value="<?_("Cancel")>"><br />
+           </form>
+         </center>
+       </td>
+      </tr>
+    </table>
+    <??("X", 1)>
+  </div>
+<?=("trailing")>
diff --git a/webcit/static/t/aide/display_generic_result.html b/webcit/static/t/aide/display_generic_result.html
new file mode 100644 (file)
index 0000000..809d5d7
--- /dev/null
@@ -0,0 +1,23 @@
+<?=("head")>
+<?=("beginbox_1")><?_("Server command results")><?=("beginbox_2")>
+
+</td><td valign=top> 
+
+
+<table border=0><tr><td>Command:</td><td><tt>
+
+<?BSTR("g_cmd")>
+
+</tt></td></tr><tr><td>Result:</td><td><tt>
+
+<?CONTEXTSTR("H")>
+       
+<br>
+</tt></td></tr></table><br />
+<hr />
+<a href="do_template?template=aide_display_generic_cmd"><?_("Enter another command")></a><br />
+<a href="display_advanced"><?_("Return to menu")></a>
+
+<?=("endbox")><br>
+
+<?=("trailing")>