[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/cgi.c between version 1.149 and 1.150

version 1.149, 2017/03/15 10:17:29 version 1.150, 2017/03/15 13:18:53
Line 81  static void   pg_search(const struct req *);
Line 81  static void   pg_search(const struct req *);
 static  void             pg_searchres(const struct req *,  static  void             pg_searchres(const struct req *,
                                 struct manpage *, size_t);                                  struct manpage *, size_t);
 static  void             pg_show(struct req *, const char *);  static  void             pg_show(struct req *, const char *);
 static  void             resp_begin_html(int, const char *);  static  void             resp_begin_html(int, const char *, const char *);
 static  void             resp_begin_http(int, const char *);  static  void             resp_begin_http(int, const char *);
 static  void             resp_catman(const struct req *, const char *);  static  void             resp_catman(const struct req *, const char *);
 static  void             resp_copy(const char *);  static  void             resp_copy(const char *);
Line 346  resp_copy(const char *filename)
Line 346  resp_copy(const char *filename)
 }  }
   
 static void  static void
 resp_begin_html(int code, const char *msg)  resp_begin_html(int code, const char *msg, const char *file)
 {  {
           char    *cp;
   
         resp_begin_http(code, msg);          resp_begin_http(code, msg);
   
Line 357  resp_begin_html(int code, const char *msg)
Line 358  resp_begin_html(int code, const char *msg)
                "  <meta charset=\"UTF-8\"/>\n"                 "  <meta charset=\"UTF-8\"/>\n"
                "  <link rel=\"stylesheet\" href=\"%s/mandoc.css\""                 "  <link rel=\"stylesheet\" href=\"%s/mandoc.css\""
                " type=\"text/css\" media=\"all\">\n"                 " type=\"text/css\" media=\"all\">\n"
                "  <title>%s</title>\n"                 "  <title>",
                  CSS_DIR);
           if (file != NULL) {
                   if ((cp = strrchr(file, '/')) != NULL)
                           file = cp + 1;
                   if ((cp = strrchr(file, '.')) != NULL) {
                           printf("%.*s(%s) - ", (int)(cp - file), file, cp + 1);
                   } else
                           printf("%s - ", file);
           }
           printf("%s</title>\n"
                "</head>\n"                 "</head>\n"
                "<body>\n",                 "<body>\n",
                CSS_DIR, CUSTOMIZE_TITLE);                 CUSTOMIZE_TITLE);
   
         resp_copy(MAN_DIR "/header.html");          resp_copy(MAN_DIR "/header.html");
 }  }
Line 493  static void
Line 504  static void
 pg_index(const struct req *req)  pg_index(const struct req *req)
 {  {
   
         resp_begin_html(200, NULL);          resp_begin_html(200, NULL, NULL);
         resp_searchform(req, FOCUS_QUERY);          resp_searchform(req, FOCUS_QUERY);
         printf("<p>\n"          printf("<p>\n"
                "This web interface is documented in the\n"                 "This web interface is documented in the\n"
Line 510  pg_index(const struct req *req)
Line 521  pg_index(const struct req *req)
 static void  static void
 pg_noresult(const struct req *req, const char *msg)  pg_noresult(const struct req *req, const char *msg)
 {  {
         resp_begin_html(200, NULL);          resp_begin_html(200, NULL, NULL);
         resp_searchform(req, FOCUS_QUERY);          resp_searchform(req, FOCUS_QUERY);
         puts("<p>");          puts("<p>");
         puts(msg);          puts(msg);
Line 522  static void
Line 533  static void
 pg_error_badrequest(const char *msg)  pg_error_badrequest(const char *msg)
 {  {
   
         resp_begin_html(400, "Bad Request");          resp_begin_html(400, "Bad Request", NULL);
         puts("<h1>Bad Request</h1>\n"          puts("<h1>Bad Request</h1>\n"
              "<p>\n");               "<p>\n");
         puts(msg);          puts(msg);
Line 535  pg_error_badrequest(const char *msg)
Line 546  pg_error_badrequest(const char *msg)
 static void  static void
 pg_error_internal(void)  pg_error_internal(void)
 {  {
         resp_begin_html(500, "Internal Server Error");          resp_begin_html(500, "Internal Server Error", NULL);
         puts("<p>Internal Server Error</p>");          puts("<p>Internal Server Error</p>");
         resp_end_html();          resp_end_html();
 }  }
Line 591  pg_searchres(const struct req *req, struct manpage *r,
Line 602  pg_searchres(const struct req *req, struct manpage *r,
                 return;                  return;
         }          }
   
         resp_begin_html(200, NULL);  
         resp_searchform(req,  
             req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY);  
   
         if (sz > 1) {  
                 puts("<table class=\"results\">");  
                 for (i = 0; i < sz; i++) {  
                         printf("  <tr>\n"  
                                "    <td>"  
                                "<a class=\"Xr\" href=\"/%s%s%s/%s\">",  
                             scriptname, *scriptname == '\0' ? "" : "/",  
                             req->q.manpath, r[i].file);  
                         html_print(r[i].names);  
                         printf("</a></td>\n"  
                                "    <td><span class=\"Nd\">");  
                         html_print(r[i].output);  
                         puts("</span></td>\n"  
                              "  </tr>");  
                 }  
                 puts("</table>");  
         }  
   
         /*          /*
          * In man(1) mode, show one of the pages           * In man(1) mode, show one of the pages
          * even if more than one is found.           * even if more than one is found.
          */           */
   
           iuse = 0;
         if (req->q.equal || sz == 1) {          if (req->q.equal || sz == 1) {
                 puts("<hr>");  
                 iuse = 0;  
                 priouse = 20;                  priouse = 20;
                 archpriouse = 3;                  archpriouse = 3;
                 for (i = 0; i < sz; i++) {                  for (i = 0; i < sz; i++) {
Line 653  pg_searchres(const struct req *req, struct manpage *r,
Line 641  pg_searchres(const struct req *req, struct manpage *r,
                         priouse = prio;                          priouse = prio;
                         iuse = i;                          iuse = i;
                 }                  }
                   resp_begin_html(200, NULL, r[iuse].file);
           } else
                   resp_begin_html(200, NULL, NULL);
   
           resp_searchform(req,
               req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY);
   
           if (sz > 1) {
                   puts("<table class=\"results\">");
                   for (i = 0; i < sz; i++) {
                           printf("  <tr>\n"
                                  "    <td>"
                                  "<a class=\"Xr\" href=\"/%s%s%s/%s\">",
                               scriptname, *scriptname == '\0' ? "" : "/",
                               req->q.manpath, r[i].file);
                           html_print(r[i].names);
                           printf("</a></td>\n"
                                  "    <td><span class=\"Nd\">");
                           html_print(r[i].output);
                           puts("</span></td>\n"
                                "  </tr>");
                   }
                   puts("</table>");
           }
   
           if (req->q.equal || sz == 1) {
                   puts("<hr>");
                 resp_show(req, r[iuse].file);                  resp_show(req, r[iuse].file);
         }          }
   
Line 904  pg_show(struct req *req, const char *fullpath)
Line 919  pg_show(struct req *req, const char *fullpath)
                 return;                  return;
         }          }
   
         resp_begin_html(200, NULL);          resp_begin_html(200, NULL, file);
         resp_searchform(req, FOCUS_NONE);          resp_searchform(req, FOCUS_NONE);
         resp_show(req, file);          resp_show(req, file);
         resp_end_html();          resp_end_html();

Legend:
Removed from v.1.149  
changed lines
  Added in v.1.150

CVSweb