httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1226491 - /httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c
Date Mon, 02 Jan 2012 17:39:17 GMT
Author: sf
Date: Mon Jan  2 17:39:17 2012
New Revision: 1226491

URL: http://svn.apache.org/viewvc?rev=1226491&view=rev
Log:
factor common code into function

display short list name in h1 heading/title

always set charset=utf-8 in headers

Modified:
    httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c?rev=1226491&r1=1226490&r2=1226491&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c Mon Jan  2 17:39:17 2012
@@ -708,6 +708,48 @@ static void mbox_static_msglist_nav(requ
     ap_rputs("</th></tr>\n", r);
 }
 
+/* Send page header */
+static void send_page_header(request_rec *r, const char *title,
+                             const char *h1, int add_script)
+{
+    mbox_dir_cfg_t *conf = ap_get_module_config(r->per_dir_config,
+                                                &mbox_module);
+    ap_set_content_type(r, "text/html; charset=utf-8");
+    if (!h1)
+        h1 = title;
+    ap_rprintf(r,
+               "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+               "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
+               "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n"
+               "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
+               " <head>\n"
+               "  <meta http-equiv=\"Content-Type\" "
+                   "content=\"text/html; charset=utf-8\" />\n"
+               "  <title>%s</title>\n",
+               title);
+
+    if (conf->style_path) {
+        ap_rprintf(r,
+                   "  <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
+                   conf->style_path);
+    }
+
+    if (add_script && conf->script_path) {
+        ap_rprintf(r,
+                   "  <script type=\"text/javascript\" src=\"%s\"></script>\n",
+                   conf->script_path);
+    }
+
+    ap_rputs(" </head>\n\n"
+             " <body id=\"archives\"", r);
+    if (add_script)
+        ap_rprintf(r, " onload=\"javascript:loadBrowser ('%s');\"", get_base_uri(r));
+    ap_rputs(">\n", r);
+
+    ap_rprintf(r, "  <h1>%s</h1>\n\n", h1);
+}
+
+
 /* Display the XHTML index of the specified mbox file. */
 apr_status_t mbox_static_msglist(request_rec *r, apr_file_t *f,
                                  int sortFlags)
@@ -783,30 +825,10 @@ apr_status_t mbox_static_msglist(request
         year = "";
     }
 
-    /* Send page header */
-    ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
-    ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
-             r);
-    ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
-
-    ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
-    ap_rputs(" <head>\n", r);
-    ap_rputs("  <meta http-equiv=\"Content-Type\" "
-             "content=\"text/html; charset=utf-8\" />\n", r);
-    ap_rprintf(r, "  <title>Mailing list archives: %s %.4s</title>\n",
-               month, year);
-
-    if (conf->style_path) {
-        ap_rprintf(r,
-                   "  <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
-                   conf->style_path);
-    }
-
-    ap_rputs(" </head>\n\n", r);
-    ap_rputs(" <body id=\"archives\">\n", r);
-
-    ap_rprintf(r, "  <h1>Mailing list archives: %s %.4s</h1>\n\n",
-               month, year);
+    send_page_header(r,
+                     apr_psprintf(r->pool, "%s mailing list archives: %s %.4s",
+                                  get_base_name(r), month, year),
+                     NULL, 0);
 
     ap_rputs("  <h5>\n", r);
 
@@ -881,43 +903,13 @@ apr_status_t mbox_static_msglist(request
 /* Outputs the AJAX browser XHTML stub. */
 apr_status_t mbox_ajax_browser(request_rec *r)
 {
-    mbox_dir_cfg_t *conf;
-    const char *baseURI;
+    mbox_dir_cfg_t *conf = ap_get_module_config(r->per_dir_config,
+                                                &mbox_module);
 
-    conf = ap_get_module_config(r->per_dir_config, &mbox_module);
-    baseURI = get_base_uri(r);
-
-    ap_set_content_type(r, "text/html; charset=utf-8");
-
-    ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
-    ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
-             r);
-    ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
-
-    ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
-    ap_rputs(" <head>\n", r);
-    ap_rputs("  <meta http-equiv=\"Content-Type\" "
-             "content=\"text/html; charset=utf-8\" />\n", r);
-    ap_rputs("  <title>Mailing list archives</title>\n", r);
-
-    if (conf->style_path) {
-        ap_rprintf(r,
-                   "   <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
-                   conf->style_path);
-    }
-
-    if (conf->script_path) {
-        ap_rprintf(r,
-                   "   <script type=\"text/javascript\" src=\"%s\"></script>\n",
-                   conf->script_path);
-    }
-
-    ap_rputs(" </head>\n\n", r);
-
-    ap_rprintf(r,
-               " <body id=\"archives\" onload=\"javascript:loadBrowser ('%s');\">\n",
-               baseURI);
-    ap_rputs("  <h1>Mailing list archives</h1>\n\n", r);
+    send_page_header(r,
+                     apr_psprintf(r->pool, "%s mailing list archives",
+                                  get_base_name(r)),
+                     NULL, 1);
 
     ap_rputs("  <h5>\n", r);
 
@@ -1144,27 +1136,11 @@ int mbox_static_message(request_rec *r, 
                                              m->content_type,
                                              m->cte, m->boundary);
 
-    ap_rputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", r);
-    ap_rputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
-             r);
-    ap_rputs("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n", r);
-
-    ap_rputs("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n", r);
-    ap_rputs(" <head>\n", r);
-    ap_rputs("  <meta http-equiv=\"Content-Type\" "
-             "content=\"text/html; charset=utf-8\" />\n", r);
-    ap_rprintf(r, "  <title>%s</title>\n",
-               ESCAPE_OR_BLANK(r->pool, m->subject));
-
-    if (conf->style_path) {
-        ap_rprintf(r,
-                   "   <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n",
-                   conf->style_path);
-    }
-
-    ap_rputs(" </head>\n\n", r);
-    ap_rputs(" <body id=\"archives\">\n", r);
-    ap_rputs("  <h1>Mailing list archives</h1>\n\n", r);
+    send_page_header(r,
+                     ESCAPE_OR_BLANK(r->pool, m->subject),
+                     apr_psprintf(r->pool, "%s mailing list archives",
+                                  get_base_name(r)),
+                     0);
 
     ap_rputs("  <h5>\n", r);
 



Mime
View raw message