commit - 4ae179a22713e09cab389f1d6941c4a98ffe21cb
commit + 63ee0dcac032703b9160148e3bef4e2af5a4cb11
blob - 775715a0de5161bf9cbc8fb00b5a75afb1147a6e
blob + e4641cc53d66a2ccbf9d8504835fe0896984881d
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
{
const struct got_error *error = NULL;
struct gw_dir *gw_dir = NULL;
- char *html, *navs, *next, *prev;
+ char *html, *navs;
+ char *href_next = NULL, *href_prev = NULL;
unsigned int prev_disp = 0, next_disp = 1, dir_c = 0;
enum kcgi_err kerr;
continue;
if (next_disp == gw_trans->gw_conf->got_max_repos_display) {
- kerr = khttp_puts(gw_trans->gw_req, np_wrapper_start);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "np_wrapper", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "nav_prev", KATTR__MAX);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
} else if ((gw_trans->gw_conf->got_max_repos_display > 0) &&
(gw_trans->page > 0) &&
(next_disp == gw_trans->gw_conf->got_max_repos_display ||
prev_disp == gw_trans->repos_total)) {
- kerr = khttp_puts(gw_trans->gw_req, np_wrapper_start);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "np_wrapper", KATTR__MAX);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "nav_prev", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
}
if ((gw_trans->gw_conf->got_max_repos_display > 0) &&
(gw_trans->page > 0) &&
(next_disp == gw_trans->gw_conf->got_max_repos_display ||
prev_disp == gw_trans->repos_total)) {
- if (asprintf(&prev, nav_prev, gw_trans->page - 1) == -1)
+ if (asprintf(&href_prev, "?page=%d",
+ gw_trans->page - 1) == -1)
return got_error_from_errno("asprintf");
- kerr = khttp_puts(gw_trans->gw_req, prev);
- free(prev);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_A,
+ KATTR_HREF, href_prev, KATTR__MAX);
+ free(href_prev);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
+ kerr = khtml_puts(gw_trans->gw_html_req, "Previous");
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
}
- kerr = khttp_puts(gw_trans->gw_req, div_end);
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
next_disp == gw_trans->gw_conf->got_max_repos_display &&
dir_c != (gw_trans->page + 1) *
gw_trans->gw_conf->got_max_repos_display) {
- if (asprintf(&next, nav_next, gw_trans->page + 1) == -1)
- return got_error_from_errno("calloc");
- kerr = khttp_puts(gw_trans->gw_req, next);
- free(next);
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "nav_next", KATTR__MAX);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
- kerr = khttp_puts(gw_trans->gw_req, div_end);
+ if (asprintf(&href_next, "?page=%d",
+ gw_trans->page + 1) == -1)
+ return got_error_from_errno("calloc");
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_A,
+ KATTR_HREF, href_next, KATTR__MAX);
+ free(href_next);
if (kerr != KCGI_OK)
- error = gw_kcgi_error(kerr);
+ return gw_kcgi_error(kerr);
+ kerr = khtml_puts(gw_trans->gw_html_req, "Next");
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 3);
+ if (kerr != KCGI_OK)
+ return gw_kcgi_error(kerr);
next_disp = 0;
break;
}
(gw_trans->page > 0) &&
(next_disp == gw_trans->gw_conf->got_max_repos_display ||
prev_disp == gw_trans->repos_total)) {
- kerr = khttp_puts(gw_trans->gw_req, div_end);
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 2);
if (kerr != KCGI_OK)
return gw_kcgi_error(kerr);
}
}
break;
case (TEMPL_SEARCH):
- kerr = khttp_puts(gw_trans->gw_req, search);
+ break;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV, KATTR_ID,
+ "search", KATTR__MAX);
if (kerr != KCGI_OK)
return 0;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_FORM,
+ KATTR_METHOD, "POST", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return 0;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_INPUT, KATTR_ID,
+ "got-search", KATTR_NAME, "got-search", KATTR_SIZE, "15",
+ KATTR_MAXLENGTH, "50", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return 0;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_BUTTON,
+ KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return 0;
+ kerr = khtml_puts(gw_trans->gw_html_req, "Search");
+ if (kerr != KCGI_OK)
+ return 0;
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 4);
+ if (kerr != KCGI_OK)
+ return 0;
break;
case(TEMPL_SITEOWNER):
if (gw_trans->gw_conf->got_site_owner != NULL &&
blob - 65fb5fc077a63345c4770d24f3b92f677023e54c
blob + 6847a568df9220759fab03cc9828e0cd1f5c3abf
--- gotweb/gotweb_ui.h
+++ gotweb/gotweb_ui.h
#ifndef GOTWEB_UI_H
#define GOTWEB_UI_H
-/* general html */
-
-char *site_link =
- "<div id='site_link'>" \
- "<a href='%s'>%s</a> %s %s" \
- "</div>";
-
-char *search =
- "<!--/* <div id='search'>" \
- "<form method='POST'>" \
- "<input type='search' id='got-search' name='got-search' size='15'" \
- " maxlength='50' />" \
- "<button>Search</button>" \
- "</form>" \
- "</div> */-->";
-
-char *np_wrapper_start =
- "<div id='np_wrapper'>" \
- "<div id='nav_prev'>";
-
-char *div_end =
- "</div>";
-
-char *nav_next =
- "<div id='nav_next'>" \
- "<a href='?page=%d'>Next<a/>" \
- "</div>";
-
-char *nav_prev =
- "<a href='?page=%d'>Previous<a/>";
-
/* index.tmpl */
char *index_projects_header =