author | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 19:12:08 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 19:12:08 (UTC) |
commit | 8b5fc6de036cf159ffa61a55158044749bd6f4d9 (patch) (side-by-side diff) | |
tree | c1accdd309b0af0f17fd97e91b8980185db79b21 | |
parent | 2e884f3162771880a2a5260713d6b7d1aa25bc6f (diff) | |
download | cgit-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>
-rw-r--r-- | ui-shared.c | 22 |
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 @@ -314,119 +314,111 @@ void cgit_commit_link(char *name, char *title, char *class, char *head, name[ctx.cfg.max_msg_len - 2] = '.'; name[ctx.cfg.max_msg_len - 3] = '.'; } reporevlink("commit", name, title, class, head, rev, NULL); } void cgit_refs_link(char *name, char *title, char *class, char *head, char *rev, char *path) { reporevlink("refs", name, title, class, head, rev, path); } void cgit_snapshot_link(char *name, char *title, char *class, char *head, char *rev, char *archivename) { reporevlink("snapshot", name, title, class, head, rev, archivename); } void cgit_diff_link(char *name, char *title, char *class, char *head, char *new_rev, char *old_rev, char *path) { char *delim; delim = repolink(title, class, "diff", head, path); if (new_rev && strcmp(new_rev, ctx.qry.head)) { html(delim); html("id="); html_url_arg(new_rev); delim = "&"; } if (old_rev) { html(delim); html("id2="); html_url_arg(old_rev); } html("'>"); html_txt(name); html("</a>"); } void cgit_patch_link(char *name, char *title, char *class, char *head, char *rev) { reporevlink("patch", name, title, class, head, rev, NULL); } void cgit_object_link(struct object *obj) { - char *page, *arg, *url; + char *page, *rev, *name; if (obj->type == OBJ_COMMIT) { cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, ctx.qry.head, sha1_to_hex(obj->sha1)); return; - } else if (obj->type == OBJ_TREE) { + } else if (obj->type == OBJ_TREE) page = "tree"; - arg = "id"; - } else if (obj->type == OBJ_TAG) { + else if (obj->type == OBJ_TAG) page = "tag"; - arg = "id"; - } else { + else page = "blob"; - arg = "id"; - } - - url = cgit_pageurl(ctx.qry.repo, page, - fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); - html_link_open(url, NULL, NULL); - htmlf("%s %s", typename(obj->type), - sha1_to_hex(obj->sha1)); - html_link_close(); + rev = sha1_to_hex(obj->sha1); + name = fmt("%s %s", typename(obj->type), rev); + reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL); } void cgit_print_date(time_t secs, char *format, int local_time) { char buf[64]; struct tm *time; if (!secs) return; if(local_time) time = localtime(&secs); else time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); } void cgit_print_age(time_t t, time_t max_relative, char *format) { time_t now, secs; if (!t) return; time(&now); secs = now - t; if (secs > max_relative && max_relative >= 0) { cgit_print_date(t, format, ctx.cfg.local_time); return; } if (secs < TM_HOUR * 2) { htmlf("<span class='age-mins'>%.0f min.</span>", secs * 1.0 / TM_MIN); return; } if (secs < TM_DAY * 2) { htmlf("<span class='age-hours'>%.0f hours</span>", secs * 1.0 / TM_HOUR); return; } if (secs < TM_WEEK * 2) { htmlf("<span class='age-days'>%.0f days</span>", secs * 1.0 / TM_DAY); return; } if (secs < TM_MONTH * 2) { htmlf("<span class='age-weeks'>%.0f weeks</span>", |