X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/48c487d72daef7e71683a85f775db8d36ab20341..fa4dfee5489d8c829da92637dd84e8650439f313:/ui-tree.c diff --git a/ui-tree.c b/ui-tree.c index e16b638..2f052c7 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -7,6 +7,8 @@ */ #include "cgit.h" +#include "html.h" +#include "ui-shared.h" char *curr_rev; char *match_path; @@ -15,8 +17,9 @@ int header = 0; static void print_object(const unsigned char *sha1, char *path) { enum object_type type; - unsigned char *buf; + char *buf; unsigned long size, lineno, start, idx; + const char *linefmt = "%1$d"; type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { @@ -32,21 +35,28 @@ static void print_object(const unsigned char *sha1, char *path) return; } - html("\n"); + html(" blob: %s",sha1_to_hex(sha1)); + + html("
\n"); idx = 0; start = 0; lineno = 0; while(idx < size) { if (buf[idx] == '\n') { buf[idx] = '\0'; - htmlf("\n"); start = idx + 1; } idx++; } + htmlf(linefmt, ++lineno); + html_txt(buf + start); + html("\n"); html("
%d", - ++lineno); + htmlf(linefmt, ++lineno); html_txt(buf + start); html("
\n"); } @@ -58,14 +68,13 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, char *fullpath; enum object_type type; unsigned long size = 0; - char *url, *qry; name = xstrdup(pathname); - fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", - cgit_query_path ? "/" : "", name); + fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", + ctx.qry.path ? "/" : "", name); type = sha1_object_info(sha1, &size); - if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { + if (type == OBJ_BAD && !S_ISGITLINK(mode)) { htmlf("Bad object: %s %s", name, sha1_to_hex(sha1)); @@ -73,28 +82,28 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, } html(""); - html_filemode(mode); + cgit_print_filemode(mode); html(""); - if (S_ISDIRLNK(mode)) { + if (S_ISGITLINK(mode)) { htmlf(""); html_txt(name); html(""); } else if (S_ISDIR(mode)) { - cgit_tree_link(name, NULL, "ls-dir", cgit_query_head, + cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, curr_rev, fullpath); } else { - cgit_tree_link(name, NULL, "ls-blob", cgit_query_head, + cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, curr_rev, fullpath); } htmlf("%li", size); html(""); - cgit_log_link("L", "Log", "button", cgit_query_head, curr_rev, - fullpath); + cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, + fullpath, 0, NULL, NULL); html("\n"); free(name); return 0; @@ -102,7 +111,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, static void ls_head() { - html("\n"); + html("
\n"); html(""); html(""); html(""); @@ -147,10 +156,10 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen, if (state == 0) { memcpy(buffer, base, baselen); strcpy(buffer+baselen, pathname); - url = cgit_pageurl(cgit_query_repo, "tree", + url = cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s&path=%s", curr_rev, buffer)); html("/"); - cgit_tree_link(xstrdup(pathname), NULL, NULL, cgit_query_head, + cgit_tree_link(xstrdup(pathname), NULL, NULL, ctx.qry.head, curr_rev, buffer); if (strcmp(match_path, buffer)) @@ -182,7 +191,7 @@ void cgit_print_tree(const char *rev, char *path) const char *paths[] = {path, NULL}; if (!rev) - rev = cgit_query_head; + rev = ctx.qry.head; curr_rev = xstrdup(rev); if (get_sha1(rev, sha1)) { @@ -196,7 +205,7 @@ void cgit_print_tree(const char *rev, char *path) } html("path: root"); if (path == NULL) {
ModeName