Suggestion from James Beal: support a '--title' option to override the
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Jul 2011 18:15:37 +0000 (18:15 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Jul 2011 18:15:37 +0000 (18:15 +0000)
'agedu:' prefix at the start of the title of output web pages.

git-svn-id: svn://svn.tartarus.org/sgt/agedu@9246 cda61777-01e9-0310-a592-d414129be87e

agedu.but
agedu.c
html.c
html.h

index 37cfdbf..bb3d4b5 100644 (file)
--- a/agedu.but
+++ b/agedu.but
@@ -544,8 +544,8 @@ mode, the argument is treated as the name of a directory: the
 directory will be created if it does not already exist, and the
 output HTML files will be created inside it.
 
 directory will be created if it does not already exist, and the
 output HTML files will be created inside it.
 
-The following options affect the web server mode \cw{-w}, and in one
-case also the stand-alone HTML generation mode \cw{-H}:
+The following options affect the web server mode \cw{-w}, and in some
+cases also the stand-alone HTML generation mode \cw{-H}:
 
 \dt \cw{-r} \e{age range} or \cw{--age-range} \e{age range}
 
 
 \dt \cw{-r} \e{age range} or \cw{--age-range} \e{age range}
 
@@ -651,6 +651,15 @@ consist of the username, followed by a colon, followed by the
 password, followed \e{immediately} by end of file (no trailing
 newline, or else it will be considered part of the password).
 
 password, followed \e{immediately} by end of file (no trailing
 newline, or else it will be considered part of the password).
 
+\dt \cw{--title} \e{title}
+
+\dd Specify the string that appears at the start of the <title>
+section of the output HTML pages. The default is \cq{agedu}. This
+title is followed by a colon and then the path you're viewing within
+the index file. You might use this option if you were serving
+\cw{agedu} reports for several different servers and wanted to make it
+clearer which one a user was looking at.
+
 \dt \cw{--no-eof}
 
 \dd Stop \cw{agedu} in web server mode from looking for end-of-file on
 \dt \cw{--no-eof}
 
 \dd Stop \cw{agedu} in web server mode from looking for end-of-file on
diff --git a/agedu.c b/agedu.c
index fd8aaea..00eda2b 100644 (file)
--- a/agedu.c
+++ b/agedu.c
@@ -361,6 +361,8 @@ static void text_query(const void *mappedfile, const char *querydir,
         HELPARG("filename") HELPOPT("[--web] read HTTP Basic user/pass from file") \
     VAL(AUTHFD) LONG(auth_fd) \
         HELPARG("fd") HELPOPT("[--web] read HTTP Basic user/pass from fd") \
         HELPARG("filename") HELPOPT("[--web] read HTTP Basic user/pass from file") \
     VAL(AUTHFD) LONG(auth_fd) \
         HELPARG("fd") HELPOPT("[--web] read HTTP Basic user/pass from fd") \
+    VAL(HTMLTITLE) LONG(title) \
+        HELPARG("title") HELPOPT("[--web,--html] title prefix for web pages") \
     VAL(DEPTH) SHORT(d) LONG(depth) LONG(max_depth) LONG(maximum_depth) \
         HELPARG("levels") HELPOPT("[--text,--html] recurse to this many levels") \
     VAL(MINAGE) SHORT(a) LONG(age) LONG(min_age) LONG(minimum_age) \
     VAL(DEPTH) SHORT(d) LONG(depth) LONG(max_depth) LONG(maximum_depth) \
         HELPARG("levels") HELPOPT("[--text,--html] recurse to this many levels") \
     VAL(MINAGE) SHORT(a) LONG(age) LONG(min_age) LONG(minimum_age) \
@@ -504,6 +506,7 @@ int main(int argc, char **argv)
     int httpserverport = 0;
     const char *httpauthdata = NULL;
     const char *outfile = NULL;
     int httpserverport = 0;
     const char *httpauthdata = NULL;
     const char *outfile = NULL;
+    const char *html_title = PNAME;
     int auth = HTTPD_AUTH_MAGIC | HTTPD_AUTH_BASIC;
     int progress = 1;
     struct inclusion_exclusion *inex = NULL;
     int auth = HTTPD_AUTH_MAGIC | HTTPD_AUTH_BASIC;
     int progress = 1;
     struct inclusion_exclusion *inex = NULL;
@@ -791,6 +794,9 @@ int main(int argc, char **argv)
                  case OPT_OUTFILE:
                    outfile = optval;
                    break;
                  case OPT_OUTFILE:
                    outfile = optval;
                    break;
+                  case OPT_HTMLTITLE:
+                    html_title = optval;
+                    break;
                  case OPT_MINAGE:
                    textcutoff = parse_age(now, optval);
                    break;
                  case OPT_MINAGE:
                    textcutoff = parse_age(now, optval);
                    break;
@@ -1375,6 +1381,7 @@ int main(int argc, char **argv)
                cfg.newest = htmlnewest;
                cfg.showfiles = showfiles;
            }
                cfg.newest = htmlnewest;
                cfg.showfiles = showfiles;
            }
+            cfg.html_title = html_title;
 
            if (!querydir) {
                /*
 
            if (!querydir) {
                /*
@@ -1593,6 +1600,7 @@ int main(int argc, char **argv)
            pcfg.oldest = htmloldest;
            pcfg.newest = htmlnewest;
            pcfg.showfiles = showfiles;
            pcfg.oldest = htmloldest;
            pcfg.newest = htmlnewest;
            pcfg.showfiles = showfiles;
+            pcfg.html_title = html_title;
            run_httpd(mappedfile, auth, &dcfg, &pcfg);
            munmap(mappedfile, totalsize);
        } else if (mode == REMOVE) {
            run_httpd(mappedfile, auth, &dcfg, &pcfg);
            munmap(mappedfile, totalsize);
        } else if (mode == REMOVE) {
diff --git a/html.c b/html.c
index f1b4df0..7f82f39 100644 (file)
--- a/html.c
+++ b/html.c
@@ -876,7 +876,9 @@ char *html_query(const void *t, unsigned long index,
      */
     htprintf(ctx, "<head>\n");
     trie_getpath(t, index, path);
      */
     htprintf(ctx, "<head>\n");
     trie_getpath(t, index, path);
-    htprintf(ctx, "<title>%s: ", PNAME);
+    htprintf(ctx, "<title>");
+    htescape(ctx, cfg->html_title, strlen(cfg->html_title), 0);
+    htprintf(ctx, ": ");
     htescape(ctx, path, strlen(path), 0);
     htprintf(ctx, "</title>\n");
     htprintf(ctx, "</head>\n");
     htescape(ctx, path, strlen(path), 0);
     htprintf(ctx, "</title>\n");
     htprintf(ctx, "</head>\n");
diff --git a/html.h b/html.h
index 6615a4a..47b7ffd 100644 (file)
--- a/html.h
+++ b/html.h
@@ -83,6 +83,11 @@ struct html_config {
      * directories in the report.
      */
     int showfiles;
      * directories in the report.
      */
     int showfiles;
+    /*
+     * The string appearing in the <title> part of HTML pages, before
+     * a colon followed by the path being served. Default is "agedu".
+     */
+    const char *html_title;
 };
 
 /*
 };
 
 /*