author | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 08:25:40 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 08:53:27 (UTC) |
commit | 8efb05f98ad389d1b7f5aac17838401908622dad (patch) (unidiff) | |
tree | 100c407d28215fab0e5d2936c939ff39ec5290fc /ui-summary.c | |
parent | 6bce91be1a60b46270c69c4098a8c03f47dae63a (diff) | |
download | cgit-8efb05f98ad389d1b7f5aac17838401908622dad.zip cgit-8efb05f98ad389d1b7f5aac17838401908622dad.tar.gz cgit-8efb05f98ad389d1b7f5aac17838401908622dad.tar.bz2 |
Make cgit_print_branches()/cgit_print_tags() external
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-summary.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-summary.c b/ui-summary.c index df79d01..97f1b57 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -121,123 +121,123 @@ static int print_tag(struct refinfo *ref) | |||
121 | html("</td><td colspan='2'/><td>"); | 121 | html("</td><td colspan='2'/><td>"); |
122 | cgit_object_link(ref->object); | 122 | cgit_object_link(ref->object); |
123 | html("</td></tr>\n"); | 123 | html("</td></tr>\n"); |
124 | } | 124 | } |
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | 128 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, |
129 | int flags, void *cb_data) | 129 | int flags, void *cb_data) |
130 | { | 130 | { |
131 | struct tag *tag; | 131 | struct tag *tag; |
132 | struct taginfo *info; | 132 | struct taginfo *info; |
133 | struct object *obj; | 133 | struct object *obj; |
134 | char buf[256], *url; | 134 | char buf[256], *url; |
135 | unsigned char fileid[20]; | 135 | unsigned char fileid[20]; |
136 | 136 | ||
137 | if (prefixcmp(refname, "refs/archives")) | 137 | if (prefixcmp(refname, "refs/archives")) |
138 | return 0; | 138 | return 0; |
139 | strncpy(buf, refname+14, sizeof(buf)); | 139 | strncpy(buf, refname+14, sizeof(buf)); |
140 | obj = parse_object(sha1); | 140 | obj = parse_object(sha1); |
141 | if (!obj) | 141 | if (!obj) |
142 | return 1; | 142 | return 1; |
143 | if (obj->type == OBJ_TAG) { | 143 | if (obj->type == OBJ_TAG) { |
144 | tag = lookup_tag(sha1); | 144 | tag = lookup_tag(sha1); |
145 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 145 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
146 | return 0; | 146 | return 0; |
147 | hashcpy(fileid, tag->tagged->sha1); | 147 | hashcpy(fileid, tag->tagged->sha1); |
148 | } else if (obj->type != OBJ_BLOB) { | 148 | } else if (obj->type != OBJ_BLOB) { |
149 | return 0; | 149 | return 0; |
150 | } else { | 150 | } else { |
151 | hashcpy(fileid, sha1); | 151 | hashcpy(fileid, sha1); |
152 | } | 152 | } |
153 | if (!header) { | 153 | if (!header) { |
154 | html("<table id='downloads'>"); | 154 | html("<table id='downloads'>"); |
155 | html("<tr><th>Downloads</th></tr>"); | 155 | html("<tr><th>Downloads</th></tr>"); |
156 | header = 1; | 156 | header = 1; |
157 | } | 157 | } |
158 | html("<tr><td>"); | 158 | html("<tr><td>"); |
159 | url = cgit_pageurl(cgit_query_repo, "blob", | 159 | url = cgit_pageurl(cgit_query_repo, "blob", |
160 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 160 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
161 | buf)); | 161 | buf)); |
162 | html_link_open(url, NULL, NULL); | 162 | html_link_open(url, NULL, NULL); |
163 | html_txt(buf); | 163 | html_txt(buf); |
164 | html_link_close(); | 164 | html_link_close(); |
165 | html("</td></tr>"); | 165 | html("</td></tr>"); |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static void cgit_print_branches(int maxcount) | 169 | void cgit_print_branches(int maxcount) |
170 | { | 170 | { |
171 | struct reflist list; | 171 | struct reflist list; |
172 | int i; | 172 | int i; |
173 | 173 | ||
174 | html("<tr class='nohover'><th class='left'>Branch</th>" | 174 | html("<tr class='nohover'><th class='left'>Branch</th>" |
175 | "<th class='left'>Idle</th>" | 175 | "<th class='left'>Idle</th>" |
176 | "<th class='left'>Author</th>" | 176 | "<th class='left'>Author</th>" |
177 | "<th class='left'>Head commit</th></tr>\n"); | 177 | "<th class='left'>Head commit</th></tr>\n"); |
178 | 178 | ||
179 | list.refs = NULL; | 179 | list.refs = NULL; |
180 | list.alloc = list.count = 0; | 180 | list.alloc = list.count = 0; |
181 | for_each_branch_ref(cgit_refs_cb, &list); | 181 | for_each_branch_ref(cgit_refs_cb, &list); |
182 | 182 | ||
183 | if (maxcount == 0 || maxcount > list.count) | 183 | if (maxcount == 0 || maxcount > list.count) |
184 | maxcount = list.count; | 184 | maxcount = list.count; |
185 | 185 | ||
186 | if (maxcount < list.count) { | 186 | if (maxcount < list.count) { |
187 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | 187 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); |
188 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 188 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
189 | } | 189 | } |
190 | 190 | ||
191 | for(i=0; i<maxcount; i++) | 191 | for(i=0; i<maxcount; i++) |
192 | cgit_print_branch(list.refs[i]); | 192 | cgit_print_branch(list.refs[i]); |
193 | } | 193 | } |
194 | 194 | ||
195 | static void cgit_print_tags(int maxcount) | 195 | void cgit_print_tags(int maxcount) |
196 | { | 196 | { |
197 | struct reflist list; | 197 | struct reflist list; |
198 | int i; | 198 | int i; |
199 | 199 | ||
200 | header = 0; | 200 | header = 0; |
201 | list.refs = NULL; | 201 | list.refs = NULL; |
202 | list.alloc = list.count = 0; | 202 | list.alloc = list.count = 0; |
203 | for_each_tag_ref(cgit_refs_cb, &list); | 203 | for_each_tag_ref(cgit_refs_cb, &list); |
204 | if (list.count == 0) | 204 | if (list.count == 0) |
205 | return; | 205 | return; |
206 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | 206 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |
207 | if (!maxcount) | 207 | if (!maxcount) |
208 | maxcount = list.count; | 208 | maxcount = list.count; |
209 | else if (maxcount > list.count) | 209 | else if (maxcount > list.count) |
210 | maxcount = list.count; | 210 | maxcount = list.count; |
211 | print_tag_header(); | 211 | print_tag_header(); |
212 | for(i=0; i<maxcount; i++) | 212 | for(i=0; i<maxcount; i++) |
213 | print_tag(list.refs[i]); | 213 | print_tag(list.refs[i]); |
214 | } | 214 | } |
215 | 215 | ||
216 | static void cgit_print_archives() | 216 | static void cgit_print_archives() |
217 | { | 217 | { |
218 | header = 0; | 218 | header = 0; |
219 | for_each_ref(cgit_print_archive_cb, NULL); | 219 | for_each_ref(cgit_print_archive_cb, NULL); |
220 | if (header) | 220 | if (header) |
221 | html("</table>"); | 221 | html("</table>"); |
222 | } | 222 | } |
223 | 223 | ||
224 | void cgit_print_summary() | 224 | void cgit_print_summary() |
225 | { | 225 | { |
226 | html("<div id='summary'>"); | 226 | html("<div id='summary'>"); |
227 | cgit_print_archives(); | 227 | cgit_print_archives(); |
228 | html("<h2>"); | 228 | html("<h2>"); |
229 | html_txt(cgit_repo->name); | 229 | html_txt(cgit_repo->name); |
230 | html(" - "); | 230 | html(" - "); |
231 | html_txt(cgit_repo->desc); | 231 | html_txt(cgit_repo->desc); |
232 | html("</h2>"); | 232 | html("</h2>"); |
233 | if (cgit_repo->readme) | 233 | if (cgit_repo->readme) |
234 | html_include(cgit_repo->readme); | 234 | html_include(cgit_repo->readme); |
235 | html("</div>"); | 235 | html("</div>"); |
236 | if (cgit_summary_log > 0) | 236 | if (cgit_summary_log > 0) |
237 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); | 237 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0); |
238 | html("<table class='list nowrap'>"); | 238 | html("<table class='list nowrap'>"); |
239 | if (cgit_summary_log > 0) | 239 | if (cgit_summary_log > 0) |
240 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 240 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
241 | cgit_print_branches(cgit_summary_branches); | 241 | cgit_print_branches(cgit_summary_branches); |
242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
243 | cgit_print_tags(cgit_summary_tags); | 243 | cgit_print_tags(cgit_summary_tags); |