-rw-r--r-- | ui-shared.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 3e378a4..ca2ee82 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -244,16 +244,40 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
244 | html("id2="); | 244 | html("id2="); |
245 | html_attr(old_rev); | 245 | html_attr(old_rev); |
246 | } | 246 | } |
247 | html("'>"); | 247 | html("'>"); |
248 | html_txt(name); | 248 | html_txt(name); |
249 | html("</a>"); | 249 | html("</a>"); |
250 | } | 250 | } |
251 | 251 | ||
252 | void cgit_object_link(struct object *obj) | ||
253 | { | ||
254 | char *page, *arg, *url; | ||
255 | |||
256 | if (obj->type == OBJ_COMMIT) { | ||
257 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | ||
258 | cgit_query_head, sha1_to_hex(obj->sha1)); | ||
259 | return; | ||
260 | } else if (obj->type == OBJ_TREE) { | ||
261 | page = "tree"; | ||
262 | arg = "id"; | ||
263 | } else { | ||
264 | page = "blob"; | ||
265 | arg = "id"; | ||
266 | } | ||
267 | |||
268 | url = cgit_pageurl(cgit_query_repo, page, | ||
269 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | ||
270 | html_link_open(url, NULL, NULL); | ||
271 | htmlf("%s %s", typename(obj->type), | ||
272 | sha1_to_hex(obj->sha1)); | ||
273 | html_link_close(); | ||
274 | } | ||
275 | |||
252 | void cgit_print_date(time_t secs, char *format) | 276 | void cgit_print_date(time_t secs, char *format) |
253 | { | 277 | { |
254 | char buf[64]; | 278 | char buf[64]; |
255 | struct tm *time; | 279 | struct tm *time; |
256 | 280 | ||
257 | time = gmtime(&secs); | 281 | time = gmtime(&secs); |
258 | strftime(buf, sizeof(buf)-1, format, time); | 282 | strftime(buf, sizeof(buf)-1, format, time); |
259 | html_txt(buf); | 283 | html_txt(buf); |