/* * The repository summary page and the about page. The summary stacks the * branch list, the tag list and the head of the log into one table and ends * with the clone urls, reusing the listings ui-refs.c and ui-log.c draw * elsewhere. The about page renders the readme that config parsing picked for * the repository, either through the configured about filter or escaped as * plain text. */ #include "cgit.h" #include "filter.h" #include "html.h" #include "shared.h" #include "ui-blob.h" #include "ui-log.h" #include "ui-refs.h" #include "ui-shared.h" #include "ui-summary.h" // Age, commit message and author, the three columns a log row always has. // ui-log.c adds one more for each of the two optional counts, and the rows // this page stretches across the table have to match that width. #define LOG_BASE_COLUMNS 3 static int clone_urls_printed; static int log_columns(void) { int columns = LOG_BASE_COLUMNS; if (ctx.repo->enable_log_filecount) columns++; if (ctx.repo->enable_log_linecount) columns++; return columns; } static void print_clone_url(const char *url) { int columns = log_columns(); // cgit_add_clone_urls may call back no times at all, so the heading // waits for a first url rather than being printed ahead of the walk. if (clone_urls_printed++ == 0) { html("
\n"); htmlf("");
if (ref) {
cgit_print_file(filename, ref, 1, 1);
} else {
struct strbuf sb = STRBUF_INIT;
if (strbuf_read_file(&sb, filename, 0) >= 0)
html_txt(sb.buf);
strbuf_release(&sb);
}
html("");
} else {
struct strbuf tree_base = STRBUF_INIT, tree_query = STRBUF_INIT;
// A tracked readme's links lead into the tree at the ref it was
// read from, while one on disk has no tree to lead into.
if (ref)
cgit_tree_url(ref, &tree_base, &tree_query);
// The filter is what makes the source safe here, so it is fed
// through unescaped.
cgit_open_filter(ctx.repo->about_filter, filename, tree_base.buf, tree_query.buf);
if (ref)
cgit_print_file(filename, ref, 1, 0);
else
html_include(filename);
cgit_close_filter(ctx.repo->about_filter);
strbuf_release(&tree_base);
strbuf_release(&tree_query);
}
html("