-rw-r--r-- | ui-summary.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-summary.c b/ui-summary.c index 42f4300..0a7869b 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,141 +1,141 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary page |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
12 | int flags, void *cb_data) | 12 | int flags, void *cb_data) |
13 | { | 13 | { |
14 | struct commit *commit; | 14 | struct commit *commit; |
15 | struct commitinfo *info; | 15 | struct commitinfo *info; |
16 | char buf[256], *url; | 16 | char buf[256], *url; |
17 | 17 | ||
18 | strncpy(buf, refname, sizeof(buf)); | 18 | strncpy(buf, refname, sizeof(buf)); |
19 | commit = lookup_commit(sha1); | 19 | commit = lookup_commit(sha1); |
20 | if (commit && !parse_commit(commit)){ | 20 | if (commit && !parse_commit(commit)){ |
21 | info = cgit_parse_commit(commit); | 21 | info = cgit_parse_commit(commit); |
22 | html("<tr><td>"); | 22 | html("<tr><td>"); |
23 | url = cgit_pageurl(cgit_query_repo, "log", | 23 | url = cgit_pageurl(cgit_query_repo, "log", |
24 | fmt("h=%s", refname)); | 24 | fmt("h=%s", refname)); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | html_txt(info->author); | 31 | html_txt(info->author); |
32 | html("</td><td>"); | 32 | html("</td><td>"); |
33 | url = cgit_pageurl(cgit_query_repo, "commit", | 33 | url = cgit_pageurl(cgit_query_repo, "commit", |
34 | fmt("id=%s", sha1_to_hex(sha1))); | 34 | fmt("id=%s", sha1_to_hex(sha1))); |
35 | html_link_open(url, NULL, NULL); | 35 | html_link_open(url, NULL, NULL); |
36 | html_ntxt(cgit_max_msg_len, info->subject); | 36 | html_ntxt(cgit_max_msg_len, info->subject); |
37 | html_link_close(); | 37 | html_link_close(); |
38 | html("</td></tr>\n"); | 38 | html("</td></tr>\n"); |
39 | cgit_free_commitinfo(info); | 39 | cgit_free_commitinfo(info); |
40 | } else { | 40 | } else { |
41 | html("<tr><td>"); | 41 | html("<tr><td>"); |
42 | html_txt(buf); | 42 | html_txt(buf); |
43 | html("</td><td colspan='3'>"); | 43 | html("</td><td colspan='3'>"); |
44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | } | 46 | } |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | static void cgit_print_object_ref(struct object *obj) | 51 | static void cgit_print_object_ref(struct object *obj) |
52 | { | 52 | { |
53 | char *page, *url; | 53 | char *page, *url; |
54 | 54 | ||
55 | if (obj->type == OBJ_COMMIT) | 55 | if (obj->type == OBJ_COMMIT) |
56 | page = "commit"; | 56 | page = "commit"; |
57 | else if (obj->type == OBJ_TREE) | 57 | else if (obj->type == OBJ_TREE) |
58 | page = "tree"; | 58 | page = "tree"; |
59 | else | 59 | else |
60 | page = "view"; | 60 | page = "view"; |
61 | 61 | ||
62 | url = cgit_pageurl(cgit_query_repo, page, | 62 | url = cgit_pageurl(cgit_query_repo, page, |
63 | fmt("id=%s", sha1_to_hex(obj->sha1))); | 63 | fmt("id=%s", sha1_to_hex(obj->sha1))); |
64 | html_link_open(url, NULL, NULL); | 64 | html_link_open(url, NULL, NULL); |
65 | htmlf("%s %s", type_names[obj->type], | 65 | htmlf("%s %s", typename(obj->type), |
66 | sha1_to_hex(obj->sha1)); | 66 | sha1_to_hex(obj->sha1)); |
67 | html_link_close(); | 67 | html_link_close(); |
68 | } | 68 | } |
69 | 69 | ||
70 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | 70 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, |
71 | int flags, void *cb_data) | 71 | int flags, void *cb_data) |
72 | { | 72 | { |
73 | struct tag *tag; | 73 | struct tag *tag; |
74 | struct taginfo *info; | 74 | struct taginfo *info; |
75 | struct object *obj; | 75 | struct object *obj; |
76 | char buf[256], *url; | 76 | char buf[256], *url; |
77 | 77 | ||
78 | strncpy(buf, refname, sizeof(buf)); | 78 | strncpy(buf, refname, sizeof(buf)); |
79 | obj = parse_object(sha1); | 79 | obj = parse_object(sha1); |
80 | if (!obj) | 80 | if (!obj) |
81 | return 1; | 81 | return 1; |
82 | if (obj->type == OBJ_TAG) { | 82 | if (obj->type == OBJ_TAG) { |
83 | tag = lookup_tag(sha1); | 83 | tag = lookup_tag(sha1); |
84 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 84 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
85 | return 2; | 85 | return 2; |
86 | html("<tr><td>"); | 86 | html("<tr><td>"); |
87 | url = cgit_pageurl(cgit_query_repo, "view", | 87 | url = cgit_pageurl(cgit_query_repo, "view", |
88 | fmt("id=%s", sha1_to_hex(sha1))); | 88 | fmt("id=%s", sha1_to_hex(sha1))); |
89 | html_link_open(url, NULL, NULL); | 89 | html_link_open(url, NULL, NULL); |
90 | html_txt(buf); | 90 | html_txt(buf); |
91 | html_link_close(); | 91 | html_link_close(); |
92 | html("</td><td>"); | 92 | html("</td><td>"); |
93 | if (info->tagger_date > 0) | 93 | if (info->tagger_date > 0) |
94 | cgit_print_date(info->tagger_date); | 94 | cgit_print_date(info->tagger_date); |
95 | html("</td><td>"); | 95 | html("</td><td>"); |
96 | if (info->tagger) | 96 | if (info->tagger) |
97 | html(info->tagger); | 97 | html(info->tagger); |
98 | html("</td><td>"); | 98 | html("</td><td>"); |
99 | cgit_print_object_ref(tag->tagged); | 99 | cgit_print_object_ref(tag->tagged); |
100 | html("</td></tr>\n"); | 100 | html("</td></tr>\n"); |
101 | } else { | 101 | } else { |
102 | html("<tr><td>"); | 102 | html("<tr><td>"); |
103 | html_txt(buf); | 103 | html_txt(buf); |
104 | html("</td><td colspan='2'/><td>"); | 104 | html("</td><td colspan='2'/><td>"); |
105 | cgit_print_object_ref(obj); | 105 | cgit_print_object_ref(obj); |
106 | html("</td></tr>\n"); | 106 | html("</td></tr>\n"); |
107 | } | 107 | } |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | static void cgit_print_branches() | 111 | static void cgit_print_branches() |
112 | { | 112 | { |
113 | html("<tr class='nohover'><th class='left'>Branch</th>" | 113 | html("<tr class='nohover'><th class='left'>Branch</th>" |
114 | "<th class='left'>Updated</th>" | 114 | "<th class='left'>Updated</th>" |
115 | "<th class='left'>Author</th>" | 115 | "<th class='left'>Author</th>" |
116 | "<th class='left'>Head commit</th></tr>\n"); | 116 | "<th class='left'>Head commit</th></tr>\n"); |
117 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 117 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
118 | } | 118 | } |
119 | 119 | ||
120 | static void cgit_print_tags() | 120 | static void cgit_print_tags() |
121 | { | 121 | { |
122 | html("<tr class='nohover'><th class='left'>Tag</th>" | 122 | html("<tr class='nohover'><th class='left'>Tag</th>" |
123 | "<th class='left'>Created</th>" | 123 | "<th class='left'>Created</th>" |
124 | "<th class='left'>Author</th>" | 124 | "<th class='left'>Author</th>" |
125 | "<th class='left'>Reference</th></tr>\n"); | 125 | "<th class='left'>Reference</th></tr>\n"); |
126 | for_each_tag_ref(cgit_print_tag_cb, NULL); | 126 | for_each_tag_ref(cgit_print_tag_cb, NULL); |
127 | } | 127 | } |
128 | 128 | ||
129 | void cgit_print_summary() | 129 | void cgit_print_summary() |
130 | { | 130 | { |
131 | html("<h2>"); | 131 | html("<h2>"); |
132 | html(cgit_repo->name); | 132 | html(cgit_repo->name); |
133 | html("</h2><h3>"); | 133 | html("</h2><h3>"); |
134 | html(cgit_repo->desc); | 134 | html(cgit_repo->desc); |
135 | html("</h3>"); | 135 | html("</h3>"); |
136 | html("<table class='list nowrap'>"); | 136 | html("<table class='list nowrap'>"); |
137 | cgit_print_branches(); | 137 | cgit_print_branches(); |
138 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 138 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
139 | cgit_print_tags(); | 139 | cgit_print_tags(); |
140 | html("</table>"); | 140 | html("</table>"); |
141 | } | 141 | } |