blob: 8ff36425e99c7953a82f11b02c7e585d08890211 [file] [log] [blame]
Lars Hjemli14180342006-12-11 16:55:07 +01001/* ui-summary.c: functions for generating repo summary page
2 *
3 * Copyright (C) 2006 Lars Hjemli
4 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
8
9#include "cgit.h"
10
11static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
12 int flags, void *cb_data)
13{
14 struct commit *commit;
Lars Hjemli148fb962006-12-16 00:33:28 +010015 struct commitinfo *info;
Lars Hjemli14180342006-12-11 16:55:07 +010016 char buf[256], *url;
17
18 commit = lookup_commit(sha1);
19 if (commit && !parse_commit(commit)){
Lars Hjemli148fb962006-12-16 00:33:28 +010020 info = cgit_parse_commit(commit);
Lars Hjemli14180342006-12-11 16:55:07 +010021 html("<tr><td>");
22 url = cgit_pageurl(cgit_query_repo, "log",
23 fmt("h=%s", refname));
24 html_link_open(url, NULL, NULL);
25 strncpy(buf, refname, sizeof(buf));
26 html_txt(buf);
27 html_link_close();
28 html("</td><td>");
Lars Hjemli148fb962006-12-16 00:33:28 +010029 cgit_print_date(commit->date);
30 html("</td><td>");
31 url = cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(sha1)));
32 html_link_open(url, NULL, NULL);
33 html_txt(info->subject);
34 html_link_close();
35 html("</td><td>");
36 html_txt(info->author);
Lars Hjemli14180342006-12-11 16:55:07 +010037 html("</td></tr>\n");
38 } else {
39 html("<tr><td>");
40 html_txt(buf);
41 html("</td><td>");
42 htmlf("*** bad ref %s", sha1_to_hex(sha1));
43 html("</td></tr>\n");
44 }
45 return 0;
46}
47
48static void cgit_print_branches()
49{
50 html("<table class='list'>");
Lars Hjemli148fb962006-12-16 00:33:28 +010051 html("<tr><th class='left'>Branch</th><th class='left'>Updated</th><th class='left'>Commit subject</th><th class='left'>Author</th></tr>\n");
Lars Hjemli14180342006-12-11 16:55:07 +010052 for_each_branch_ref(cgit_print_branch_cb, NULL);
53 html("</table>");
54}
55
Lars Hjemlid14c5f62006-12-11 17:04:19 +010056void cgit_print_summary()
Lars Hjemli14180342006-12-11 16:55:07 +010057{
58 html("<h2>");
59 html_txt("Repo summary page");
60 html("</h2>");
61 cgit_print_branches();
62}