#include "ui-repolist.h"
#include "html.h"
#include "ui-shared.h"
-#include <strings.h>
static time_t read_agefile(char *path)
{
char *buf;
struct strbuf date_buf = STRBUF_INIT;
- if (readfile(path, &buf, &size))
+ if (readfile(path, &buf, &size)) {
+ free(buf);
return -1;
+ }
if (parse_date(buf, &date_buf) == 0)
result = strtoul(date_buf.buf, NULL, 10);
static void print_sort_header(const char *title, const char *sort)
{
+ char *currenturl = cgit_currenturl();
html("<th class='left'><a href='");
- html_attr(cgit_rooturl());
+ html_attr(currenturl);
htmlf("?s=%s", sort);
if (ctx.qry.search) {
html("&q=");
html_url_arg(ctx.qry.search);
}
htmlf("'>%s</a></th>", title);
+ free(currenturl);
}
-static void print_header()
+static void print_header(void)
{
html("<tr class='nohover'>");
print_sort_header("Name", "name");
class = (ctx.qry.ofs == ofs) ? "current" : NULL;
html("<li>");
cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1),
- class, search, sort, ofs);
+ class, search, sort, ofs, 0);
html("</li>");
}
html("</ul>");
int (*fn)(const void *a, const void *b);
};
-struct sortcolumn sortcolumn[] = {
+static const struct sortcolumn sortcolumn[] = {
{"section", sort_section},
{"name", sort_name},
{"desc", sort_desc},
static int sort_repolist(char *field)
{
- struct sortcolumn *column;
+ const struct sortcolumn *column;
for (column = &sortcolumn[0]; column->name; column++) {
if (strcmp(field, column->name))
}
-void cgit_print_repolist()
+void cgit_print_repolist(void)
{
int i, columns = 3, hits = 0, header = 0;
char *last_section = NULL;
cgit_close_filter(ctx.repo->owner_filter);
} else {
html("<a href='");
- html_attr(cgit_rooturl());
+ html_attr(cgit_currenturl());
html("?q=");
html_url_arg(ctx.repo->owner);
html("'>");
html("<td>");
cgit_summary_link("summary", NULL, "button", NULL);
cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
- 0, NULL, NULL, ctx.qry.showmsg);
+ 0, NULL, NULL, ctx.qry.showmsg, 0);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
html("</td>");
}
cgit_print_docend();
}
-void cgit_print_site_readme()
+void cgit_print_site_readme(void)
{
+ cgit_print_layout_start();
if (!ctx.cfg.root_readme)
- return;
+ goto done;
cgit_open_filter(ctx.cfg.about_filter, ctx.cfg.root_readme);
html_include(ctx.cfg.root_readme);
cgit_close_filter(ctx.cfg.about_filter);
+done:
+ cgit_print_layout_end();
}