changed default style for directory listing and error pages

This commit is contained in:
hyung-hwan 2013-04-05 01:07:45 +00:00
parent 33d7fd632c
commit 75bf46e051
4 changed files with 36 additions and 15 deletions

View File

@ -779,7 +779,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
} }
pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("index")); pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("index"));
if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default.index")); if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("server-default.index"));
if (pair && pair->val->type == QSE_XLI_STR) if (pair && pair->val->type == QSE_XLI_STR)
{ {
const qse_char_t* tmpptr, * tmpend; const qse_char_t* tmpptr, * tmpend;
@ -801,7 +801,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
} }
pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("cgi")); pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("cgi"));
if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default.cgi")); if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("server-default.cgi"));
if (pair && pair->val->type == QSE_XLI_LIST) if (pair && pair->val->type == QSE_XLI_LIST)
{ {
/* TODO: more sanity check... this can be done with xli schema... if supported */ /* TODO: more sanity check... this can be done with xli schema... if supported */
@ -879,7 +879,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
} }
pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("mime")); pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("mime"));
if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default.mime")); if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("server-default.mime"));
if (pair && pair->val->type == QSE_XLI_LIST) if (pair && pair->val->type == QSE_XLI_LIST)
{ {
qse_xli_list_t* mimelist = (qse_xli_list_t*)pair->val; qse_xli_list_t* mimelist = (qse_xli_list_t*)pair->val;
@ -1214,7 +1214,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
} }
pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("ssl")); pair = qse_xli_findpairbyname (httpd_xtn->xli, list, QSE_T("ssl"));
if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default.ssl")); if (!pair) pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("server-default.ssl"));
if (pair && pair->val->type == QSE_XLI_STR) dope.flags |= QSE_HTTPD_SERVER_SECURE; if (pair && pair->val->type == QSE_XLI_STR) dope.flags |= QSE_HTTPD_SERVER_SECURE;
dope.detach = free_server_config; dope.detach = free_server_config;
@ -1348,7 +1348,7 @@ static int load_config (qse_httpd_t* httpd)
} }
/* load the global default */ /* load the global default */
pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default")); pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("server-default"));
if (pair && pair->val->type == QSE_XLI_LIST) if (pair && pair->val->type == QSE_XLI_LIST)
{ {
if (load_loccfg (httpd, (qse_xli_list_t*)pair->val, &httpd_xtn->dflcfg) <= -1) if (load_loccfg (httpd, (qse_xli_list_t*)pair->val, &httpd_xtn->dflcfg) <= -1)

View File

@ -5,14 +5,19 @@
# string to be used as a httpd name # string to be used as a httpd name
name = "QSEHTTPD v1"; name = "QSEHTTPD v1";
################################################
# default server configuration
################################################
server-default { server-default {
# default ssl certificate file # default ssl certificate file
#ssl-cert-file = "/etc/qse/cert.pem"; #ssl-cert-file = "/etc/qse/cert.pem";
# default ssl private key file # default ssl private key file
#ssl-key-file = "/etc/qse/key.pem"; #ssl-key-file = "/etc/qse/key.pem";
####################################################################
# document root # document root
root = "/"; ####################################################################
root = "/var/www";
realm = "default realm"; realm = "default realm";
auth = "username:password"; auth = "username:password";
@ -33,7 +38,9 @@ server-default {
@include "httpd-mime.conf"; @include "httpd-mime.conf";
} }
####################################################################
# control access to directories # control access to directories
####################################################################
dir-access { dir-access {
#prefix ".xxxx" = ok; #prefix ".xxxx" = ok;
#suffix ".xxxx" = ok; #suffix ".xxxx" = ok;
@ -41,8 +48,10 @@ server-default {
#other = noent; #other = noent;
} }
####################################################################
# control access to normal files. # control access to normal files.
# cgi scripts are not control by these. # cgi scripts are not control by these.
####################################################################
file-access { file-access {
#prefix "index.html." = ok; #prefix "index.html." = ok;
suffix ".html" = ok; suffix ".html" = ok;
@ -53,16 +62,28 @@ server-default {
#other = noent; #other = noent;
} }
dir-head = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>"; ####################################################################
# directory listing includes this string in the <head> tag of the
# generated html page.
####################################################################
#dir-head = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>";
# the directory listing shows the httpd name in the footer. ####################################################################
# you can override it with dir-foot. # directory listing shows the httpd name in the footer. you can
# override it with dir-foot.
####################################################################
#dir-foot = "QSEHTTPD v1"; #dir-foot = "QSEHTTPD v1";
error-head = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; }</style>"; ####################################################################
# the error page includes this string in the <head> tag of the
# generated html page.
####################################################################
#error-head = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; }</style>";
# an error page shows the httpd name in the footer. ####################################################################
# you can override it with error-foot. # the error page shows the httpd name in the footer. you can
# override it with error-foot.
####################################################################
#error-foot = "QSEHTTPD v1"; #error-foot = "QSEHTTPD v1";
} }

View File

@ -592,7 +592,7 @@ qse_httpd_task_t* qse_httpd_entaskdir (
data.path.len = qse_mbslen(data.path.ptr); data.path.len = qse_mbslen(data.path.ptr);
data.qpath.ptr = qse_htre_getqpath(req); data.qpath.ptr = qse_htre_getqpath(req);
data.qpath.len = qse_mbslen(data.qpath.ptr); data.qpath.len = qse_mbslen(data.qpath.ptr);
data.head.ptr = dir->head? dir->head: QSE_MT(""); data.head.ptr = dir->head? dir->head: QSE_MT("<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>");
data.head.len = qse_mbslen(data.head.ptr); data.head.len = qse_mbslen(data.head.ptr);
data.foot.ptr = dir->foot? dir->foot: qse_httpd_getname(httpd); data.foot.ptr = dir->foot? dir->foot: qse_httpd_getname(httpd);
data.foot.len = qse_mbslen(data.foot.ptr); data.foot.len = qse_mbslen(data.foot.ptr);

View File

@ -2115,7 +2115,7 @@ static int format_error (
server_xtn = qse_httpd_getserverxtn (httpd, client->server); server_xtn = qse_httpd_getserverxtn (httpd, client->server);
if (server_xtn->query (httpd, client->server, QSE_NULL, QSE_NULL, QSE_HTTPD_SERVERSTD_ERRHEAD, &head) <= -1) head = QSE_NULL; if (server_xtn->query (httpd, client->server, QSE_NULL, QSE_NULL, QSE_HTTPD_SERVERSTD_ERRHEAD, &head) <= -1) head = QSE_NULL;
if (head == QSE_NULL) head = QSE_MT(""); if (head == QSE_NULL) head = QSE_MT("<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; }</style>");
if (server_xtn->query (httpd, client->server, QSE_NULL, QSE_NULL, QSE_HTTPD_SERVERSTD_ERRFOOT, &foot) <= -1) foot = QSE_NULL; if (server_xtn->query (httpd, client->server, QSE_NULL, QSE_NULL, QSE_HTTPD_SERVERSTD_ERRFOOT, &foot) <= -1) foot = QSE_NULL;
if (foot == QSE_NULL) foot = qse_httpd_getname(httpd); if (foot == QSE_NULL) foot = qse_httpd_getname(httpd);