示例#1
0
文件: ui-log.c 项目: p00ya/cgit
void print_commit(struct commit *commit)
{
	struct commitinfo *info;
	char *tmp;
	int cols = 2;

	info = cgit_parse_commit(commit);
	htmlf("<tr%s><td>",
		ctx.qry.showmsg ? " class='logheader'" : "");
	tmp = fmt("id=%s", sha1_to_hex(commit->object.sha1));
	tmp = cgit_fileurl(ctx.repo->url, "commit", ctx.qry.vpath, tmp);
	html_link_open(tmp, NULL, NULL);
	cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
	html_link_close();
	htmlf("</td><td%s>",
		ctx.qry.showmsg ? " class='logsubject'" : "");
	cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
			 sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0);
	show_commit_decorations(commit);
	html("</td><td>");
	html_txt(info->author);
	if (ctx.repo->enable_log_filecount) {
		files = 0;
		add_lines = 0;
		rem_lines = 0;
		cgit_diff_commit(commit, inspect_files);
		html("</td><td>");
		htmlf("%d", files);
		if (ctx.repo->enable_log_linecount) {
			html("</td><td>");
			htmlf("-%d/+%d", rem_lines, add_lines);
		}
	}
	html("</td></tr>\n");
	if (ctx.qry.showmsg) {
		struct strbuf notes = STRBUF_INIT;
		format_note(NULL, commit->object.sha1, &notes, PAGE_ENCODING, 0);

		if (ctx.repo->enable_log_filecount) {
			cols++;
			if (ctx.repo->enable_log_linecount)
				cols++;
		}
		htmlf("<tr class='nohover'><td/><td colspan='%d' class='logmsg'>",
			cols);
		html_txt(info->msg);
		html("</td></tr>\n");
		if (notes.len != 0) {
			html("<tr class='nohover'>");
			html("<td class='lognotes-label'>Notes:</td>");
			htmlf("<td colspan='%d' class='lognotes'>",
				cols);
			html_txt(notes.buf);
			html("</td></tr>\n");
		}
		strbuf_release(&notes);
	}
	cgit_free_commitinfo(info);
}
示例#2
0
文件: ui-shared.c 项目: certik/cgit
char *cgit_pageurl(const char *reponame, const char *pagename,
		   const char *query)
{
	return cgit_fileurl(reponame,pagename,0,query);
}