]> git.cameronkatri.com Git - cgit.git/blob - ui-summary.c
Move cache_prepare() to cgit
[cgit.git] / ui-summary.c
1 /* 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
11 static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
12 int flags, void *cb_data)
13 {
14 struct commit *commit;
15 struct commitinfo *info;
16 char buf[256], *url;
17
18 commit = lookup_commit(sha1);
19 if (commit && !parse_commit(commit)){
20 info = cgit_parse_commit(commit);
21 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>");
29 cgit_print_date(commit->date);
30 html("</td><td>");
31 url = cgit_pageurl(cgit_query_repo, "commit",
32 fmt("id=%s", sha1_to_hex(sha1)));
33 html_link_open(url, NULL, NULL);
34 html_ntxt(80, info->subject);
35 html_link_close();
36 html("</td><td>");
37 html_txt(info->author);
38 html("</td></tr>\n");
39 cgit_free_commitinfo(info);
40 } else {
41 html("<tr><td>");
42 html_txt(buf);
43 html("</td><td>");
44 htmlf("*** bad ref %s", sha1_to_hex(sha1));
45 html("</td></tr>\n");
46 }
47 return 0;
48 }
49
50 static void cgit_print_branches()
51 {
52 html("<table class='list nowrap'>");
53 html("<tr><th class='left'>Branch</th>"
54 "<th class='left'>Updated</th>"
55 "<th class='left'>Commit subject</th>"
56 "<th class='left'>Author</th></tr>\n");
57 for_each_branch_ref(cgit_print_branch_cb, NULL);
58 html("</table>");
59 }
60
61 void cgit_print_summary()
62 {
63 html("<h2>");
64 html_txt("Repo summary page");
65 html("</h2>");
66 cgit_print_branches();
67 }