summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-10-05 19:12:08 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-10-05 19:12:08 (UTC)
commit8b5fc6de036cf159ffa61a55158044749bd6f4d9 (patch) (unidiff)
treec1accdd309b0af0f17fd97e91b8980185db79b21
parent2e884f3162771880a2a5260713d6b7d1aa25bc6f (diff)
downloadcgit-8b5fc6de036cf159ffa61a55158044749bd6f4d9.zip
cgit-8b5fc6de036cf159ffa61a55158044749bd6f4d9.tar.gz
cgit-8b5fc6de036cf159ffa61a55158044749bd6f4d9.tar.bz2
ui-shared: generate proper links in cgit_object_link()
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 1e12529..a959224 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -338,71 +338,63 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
338 if (new_rev && strcmp(new_rev, ctx.qry.head)) { 338 if (new_rev && strcmp(new_rev, ctx.qry.head)) {
339 html(delim); 339 html(delim);
340 html("id="); 340 html("id=");
341 html_url_arg(new_rev); 341 html_url_arg(new_rev);
342 delim = "&amp;"; 342 delim = "&amp;";
343 } 343 }
344 if (old_rev) { 344 if (old_rev) {
345 html(delim); 345 html(delim);
346 html("id2="); 346 html("id2=");
347 html_url_arg(old_rev); 347 html_url_arg(old_rev);
348 } 348 }
349 html("'>"); 349 html("'>");
350 html_txt(name); 350 html_txt(name);
351 html("</a>"); 351 html("</a>");
352} 352}
353 353
354void cgit_patch_link(char *name, char *title, char *class, char *head, 354void cgit_patch_link(char *name, char *title, char *class, char *head,
355 char *rev) 355 char *rev)
356{ 356{
357 reporevlink("patch", name, title, class, head, rev, NULL); 357 reporevlink("patch", name, title, class, head, rev, NULL);
358} 358}
359 359
360void cgit_object_link(struct object *obj) 360void cgit_object_link(struct object *obj)
361{ 361{
362 char *page, *arg, *url; 362 char *page, *rev, *name;
363 363
364 if (obj->type == OBJ_COMMIT) { 364 if (obj->type == OBJ_COMMIT) {
365 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 365 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
366 ctx.qry.head, sha1_to_hex(obj->sha1)); 366 ctx.qry.head, sha1_to_hex(obj->sha1));
367 return; 367 return;
368 } else if (obj->type == OBJ_TREE) { 368 } else if (obj->type == OBJ_TREE)
369 page = "tree"; 369 page = "tree";
370 arg = "id"; 370 else if (obj->type == OBJ_TAG)
371 } else if (obj->type == OBJ_TAG) {
372 page = "tag"; 371 page = "tag";
373 arg = "id"; 372 else
374 } else {
375 page = "blob"; 373 page = "blob";
376 arg = "id"; 374 rev = sha1_to_hex(obj->sha1);
377 } 375 name = fmt("%s %s", typename(obj->type), rev);
378 376 reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL);
379 url = cgit_pageurl(ctx.qry.repo, page,
380 fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
381 html_link_open(url, NULL, NULL);
382 htmlf("%s %s", typename(obj->type),
383 sha1_to_hex(obj->sha1));
384 html_link_close();
385} 377}
386 378
387void cgit_print_date(time_t secs, char *format, int local_time) 379void cgit_print_date(time_t secs, char *format, int local_time)
388{ 380{
389 char buf[64]; 381 char buf[64];
390 struct tm *time; 382 struct tm *time;
391 383
392 if (!secs) 384 if (!secs)
393 return; 385 return;
394 if(local_time) 386 if(local_time)
395 time = localtime(&secs); 387 time = localtime(&secs);
396 else 388 else
397 time = gmtime(&secs); 389 time = gmtime(&secs);
398 strftime(buf, sizeof(buf)-1, format, time); 390 strftime(buf, sizeof(buf)-1, format, time);
399 html_txt(buf); 391 html_txt(buf);
400} 392}
401 393
402void cgit_print_age(time_t t, time_t max_relative, char *format) 394void cgit_print_age(time_t t, time_t max_relative, char *format)
403{ 395{
404 time_t now, secs; 396 time_t now, secs;
405 397
406 if (!t) 398 if (!t)
407 return; 399 return;
408 time(&now); 400 time(&now);