char *cgit_currenturl(void) { if (!ctx.qry.url) return xstrdup(cgit_rooturl()); const char *root = cgit_rooturl(); size_t len = strlen(root); if (len && root[len - 1] == '/') return fmtalloc("%s%s", root, ctx.qry.url); return fmtalloc("%s/%s", root, ctx.qry.url); }
const char *cgit_loginurl(void) { static const char *login_url; if (!login_url) login_url = fmtalloc("%s?p=login", cgit_rooturl()); return login_url; }
static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) { char *delim = "?"; if (always_root || page) html_attr(cgit_rooturl()); else { char *currenturl = cgit_currenturl(); html_attr(currenturl); free(currenturl); } if (page) { htmlf("?p=%s", page); delim = "&"; } if (search) { html(delim); html("q="); html_attr(search); delim = "&"; } if (sort) { html(delim); html("s="); html_attr(sort); delim = "&"; } if (ofs) { html(delim); htmlf("ofs=%d", ofs); } }
void print_sort_header(const char *title, const char *sort) { htmlf("<th class='left'><a href='%s?s=%s", cgit_rooturl(), sort); if (ctx.qry.search) { html("&q="); html_url_arg(ctx.qry.search); } htmlf("'>%s</a></th>", title); }