summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 1e895a6..c684628 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -29,88 +29,80 @@ static void cgit_print_branch(struct refinfo *ref)
29 html("</td><td>"); 29 html("</td><td>");
30 html_txt(info->author); 30 html_txt(info->author);
31 html("</td><td>"); 31 html("</td><td>");
32 cgit_commit_link(info->subject, NULL, NULL, name, NULL); 32 cgit_commit_link(info->subject, NULL, NULL, name, NULL);
33 html("</td></tr>\n"); 33 html("</td></tr>\n");
34 cgit_free_commitinfo(info); 34 cgit_free_commitinfo(info);
35 } else { 35 } else {
36 html("<tr><td>"); 36 html("<tr><td>");
37 html_txt(name); 37 html_txt(name);
38 html("</td><td colspan='3'>"); 38 html("</td><td colspan='3'>");
39 htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1)); 39 htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1));
40 html("</td></tr>\n"); 40 html("</td></tr>\n");
41 } 41 }
42} 42}
43 43
44static void print_tag_header() 44static void print_tag_header()
45{ 45{
46 html("<tr class='nohover'><th class='left'>Tag</th>" 46 html("<tr class='nohover'><th class='left'>Tag</th>"
47 "<th class='left'>Age</th>" 47 "<th class='left'>Age</th>"
48 "<th class='left'>Author</th>" 48 "<th class='left'>Author</th>"
49 "<th class='left'>Reference</th></tr>\n"); 49 "<th class='left'>Reference</th></tr>\n");
50 header = 1; 50 header = 1;
51} 51}
52 52
53static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, 53static int print_tag(struct refinfo *ref)
54 int flags, void *cb_data)
55{ 54{
56 struct tag *tag; 55 struct tag *tag;
57 struct taginfo *info; 56 struct taginfo *info;
58 struct object *obj; 57 char *url, *name = (char *)ref->refname;
59 char buf[256], *url;
60 58
61 strncpy(buf, refname, sizeof(buf)); 59 if (ref->object->type == OBJ_TAG) {
62 obj = parse_object(sha1); 60 tag = lookup_tag(ref->object->sha1);
63 if (!obj)
64 return 1;
65 if (obj->type == OBJ_TAG) {
66 tag = lookup_tag(sha1);
67 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 61 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
68 return 2; 62 return 2;
69 if (!header)
70 print_tag_header();
71 html("<tr><td>"); 63 html("<tr><td>");
72 url = cgit_pageurl(cgit_query_repo, "tag", 64 url = cgit_pageurl(cgit_query_repo, "tag",
73 fmt("id=%s", refname)); 65 fmt("id=%s", name));
74 html_link_open(url, NULL, NULL); 66 html_link_open(url, NULL, NULL);
75 html_txt(buf); 67 html_txt(name);
76 html_link_close(); 68 html_link_close();
77 html("</td><td>"); 69 html("</td><td>");
78 if (info->tagger_date > 0) 70 if (info->tagger_date > 0)
79 cgit_print_age(info->tagger_date, -1, NULL); 71 cgit_print_age(info->tagger_date, -1, NULL);
80 html("</td><td>"); 72 html("</td><td>");
81 if (info->tagger) 73 if (info->tagger)
82 html(info->tagger); 74 html(info->tagger);
83 html("</td><td>"); 75 html("</td><td>");
84 cgit_object_link(tag->tagged); 76 cgit_object_link(tag->tagged);
85 html("</td></tr>\n"); 77 html("</td></tr>\n");
86 } else { 78 } else {
87 if (!header) 79 if (!header)
88 print_tag_header(); 80 print_tag_header();
89 html("<tr><td>"); 81 html("<tr><td>");
90 html_txt(buf); 82 html_txt(name);
91 html("</td><td colspan='2'/><td>"); 83 html("</td><td colspan='2'/><td>");
92 cgit_object_link(obj); 84 cgit_object_link(ref->object);
93 html("</td></tr>\n"); 85 html("</td></tr>\n");
94 } 86 }
95 return 0; 87 return 0;
96} 88}
97 89
98static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, 90static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1,
99 int flags, void *cb_data) 91 int flags, void *cb_data)
100{ 92{
101 struct tag *tag; 93 struct tag *tag;
102 struct taginfo *info; 94 struct taginfo *info;
103 struct object *obj; 95 struct object *obj;
104 char buf[256], *url; 96 char buf[256], *url;
105 unsigned char fileid[20]; 97 unsigned char fileid[20];
106 98
107 if (prefixcmp(refname, "refs/archives")) 99 if (prefixcmp(refname, "refs/archives"))
108 return 0; 100 return 0;
109 strncpy(buf, refname+14, sizeof(buf)); 101 strncpy(buf, refname+14, sizeof(buf));
110 obj = parse_object(sha1); 102 obj = parse_object(sha1);
111 if (!obj) 103 if (!obj)
112 return 1; 104 return 1;
113 if (obj->type == OBJ_TAG) { 105 if (obj->type == OBJ_TAG) {
114 tag = lookup_tag(sha1); 106 tag = lookup_tag(sha1);
115 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 107 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
116 return 0; 108 return 0;
@@ -134,50 +126,60 @@ static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1,
134 html_link_close(); 126 html_link_close();
135 html("</td></tr>"); 127 html("</td></tr>");
136 return 0; 128 return 0;
137} 129}
138 130
139static void cgit_print_branches() 131static void cgit_print_branches()
140{ 132{
141 struct reflist list; 133 struct reflist list;
142 int i; 134 int i;
143 135
144 html("<tr class='nohover'><th class='left'>Branch</th>" 136 html("<tr class='nohover'><th class='left'>Branch</th>"
145 "<th class='left'>Idle</th>" 137 "<th class='left'>Idle</th>"
146 "<th class='left'>Author</th>" 138 "<th class='left'>Author</th>"
147 "<th class='left'>Head commit</th></tr>\n"); 139 "<th class='left'>Head commit</th></tr>\n");
148 140
149 list.refs = NULL; 141 list.refs = NULL;
150 list.alloc = list.count = 0; 142 list.alloc = list.count = 0;
151 for_each_branch_ref(cgit_refs_cb, &list); 143 for_each_branch_ref(cgit_refs_cb, &list);
152 for(i=0; i<list.count; i++) 144 for(i=0; i<list.count; i++)
153 cgit_print_branch(list.refs[i]); 145 cgit_print_branch(list.refs[i]);
154} 146}
155 147
156static void cgit_print_tags() 148static void cgit_print_tags()
157{ 149{
150 struct reflist list;
151 int i;
152
158 header = 0; 153 header = 0;
159 for_each_tag_ref(cgit_print_tag_cb, NULL); 154 list.refs = NULL;
155 list.alloc = list.count = 0;
156 for_each_tag_ref(cgit_refs_cb, &list);
157 if (list.count == 0)
158 return;
159 print_tag_header();
160 for(i=0; i<list.count; i++)
161 print_tag(list.refs[i]);
160} 162}
161 163
162static void cgit_print_archives() 164static void cgit_print_archives()
163{ 165{
164 header = 0; 166 header = 0;
165 for_each_ref(cgit_print_archive_cb, NULL); 167 for_each_ref(cgit_print_archive_cb, NULL);
166 if (header) 168 if (header)
167 html("</table>"); 169 html("</table>");
168} 170}
169 171
170void cgit_print_summary() 172void cgit_print_summary()
171{ 173{
172 html("<div id='summary'>"); 174 html("<div id='summary'>");
173 cgit_print_archives(); 175 cgit_print_archives();
174 html("<h2>"); 176 html("<h2>");
175 html_txt(cgit_repo->name); 177 html_txt(cgit_repo->name);
176 html(" - "); 178 html(" - ");
177 html_txt(cgit_repo->desc); 179 html_txt(cgit_repo->desc);
178 html("</h2>"); 180 html("</h2>");
179 if (cgit_repo->readme) 181 if (cgit_repo->readme)
180 html_include(cgit_repo->readme); 182 html_include(cgit_repo->readme);
181 html("</div>"); 183 html("</div>");
182 if (cgit_summary_log > 0) 184 if (cgit_summary_log > 0)
183 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); 185 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0);