diff options
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/html.c b/html.c index 9386205..562f909 100644 --- a/html.c +++ b/html.c @@ -49,7 +49,7 @@ enum kcgi_err htmlHead(struct khtmlreq *html, const char *title) { } enum kcgi_err -htmlNav(struct khtmlreq *html, const char *network, const char *context) { +htmlNav(struct khtmlreq *html, struct Scope scope) { enum kcgi_err error = 0 || khtml_elem(html, KELEM_NAV) || khtml_elem(html, KELEM_OL) @@ -59,33 +59,33 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { || khtml_closeelem(html, 2); if (error) return error; - if (network) { + if (scope.network) { char *href = khttp_urlpart( NULL, NULL, Pages[Contexts], - Keys[Network].name, network, + Keys[Network].name, scope.network, NULL ); if (!href) err(EX_OSERR, "khttp_urlpart"); error = 0 || khtml_elem(html, KELEM_LI) || khtml_attr(html, KELEM_A, KATTR_HREF, href, KATTR__MAX) - || khtml_puts(html, network) + || khtml_puts(html, scope.network) || khtml_closeelem(html, 2); if (error) return error; } - if (network && context) { + if (scope.network && scope.context) { char *href = khttp_urlpart( NULL, NULL, Pages[Events], - Keys[Network].name, network, - Keys[Context].name, context, + Keys[Network].name, scope.network, + Keys[Context].name, scope.context, NULL ); if (!href) err(EX_OSERR, "khttp_urlpart"); error = 0 || khtml_elem(html, KELEM_LI) || khtml_attr(html, KELEM_A, KATTR_HREF, href, KATTR__MAX) - || khtml_puts(html, context) + || khtml_puts(html, scope.context) || khtml_closeelem(html, 2); if (error) return error; } @@ -93,7 +93,8 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { char label[256]; snprintf( label, sizeof(label), "Search%s%s", - (network ? " " : ""), (context ? context : network ? network : "") + (scope.network ? " " : ""), + (scope.context ? scope.context : scope.network ? scope.network : "") ); error = 0 @@ -108,6 +109,7 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { html, KELEM_INPUT, KATTR_TYPE, "search", KATTR_NAME, Keys[Query].name, + KATTR_VALUE, (scope.query ? scope.query : ""), KATTR__MAX ) || khtml_attr( @@ -118,23 +120,23 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { ); if (error) return error; - if (network) { + if (scope.network) { error = khtml_attr( html, KELEM_INPUT, KATTR_TYPE, "hidden", KATTR_NAME, Keys[Network].name, - KATTR_VALUE, network, + KATTR_VALUE, scope.network, KATTR__MAX ); if (error) return error; } - if (context) { + if (scope.context) { error = khtml_attr( html, KELEM_INPUT, KATTR_TYPE, "hidden", KATTR_NAME, Keys[Context].name, - KATTR_VALUE, context, + KATTR_VALUE, scope.context, KATTR__MAX ); if (error) return error; @@ -284,7 +286,8 @@ static const char *Types[TypesLen] = { #undef X }; -enum kcgi_err htmlEvent(struct khtmlreq *html, struct Event event) { +enum kcgi_err +htmlEvent(struct khtmlreq *html, struct Scope scope, struct Event event) { const char *type = (event.type < TypesLen ? Types[event.type] : "unknown"); return 0 || khtml_attrx( @@ -294,8 +297,8 @@ enum kcgi_err htmlEvent(struct khtmlreq *html, struct Event event) { KATTR__MAX ) || eventTime(html, event) - || eventNetwork(html, event) - || eventContext(html, event) + || (scope.network ? 0 : eventNetwork(html, event)) + || (scope.context ? 0 : eventContext(html, event)) || eventNick(html, event) || eventMessage(html, event) || khtml_closeelem(html, 1); |