-rw-r--r-- | ui-shared.c | 6 | ||||
-rw-r--r-- | ui-shared.h | 2 | ||||
-rw-r--r-- | ui-tree.c | 8 |
3 files changed, 12 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c index 4408969..a2e0dd2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -222,48 +222,54 @@ static char *repolink(char *title, char *class, char *page, char *head, } static void reporevlink(char *page, char *name, char *title, char *class, char *head, char *rev, char *path) { char *delim; delim = repolink(title, class, page, head, path); if (rev && strcmp(rev, ctx.qry.head)) { html(delim); html("id="); html_attr(rev); } html("'>"); html_txt(name); html("</a>"); } void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path) { reporevlink("tree", name, title, class, head, rev, path); } +void cgit_plain_link(char *name, char *title, char *class, char *head, + char *rev, char *path) +{ + reporevlink("plain", name, title, class, head, rev, path); +} + void cgit_log_link(char *name, char *title, char *class, char *head, char *rev, char *path, int ofs, char *grep, char *pattern) { char *delim; delim = repolink(title, class, "log", head, path); if (rev && strcmp(rev, ctx.qry.head)) { html(delim); html("id="); html_attr(rev); delim = "&"; } if (grep && pattern) { html(delim); html("qt="); html_attr(grep); delim = "&"; html(delim); html("q="); html_attr(pattern); } if (ofs > 0) { html(delim); html("ofs="); diff --git a/ui-shared.h b/ui-shared.h index 07da4b4..c5ce056 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -1,37 +1,39 @@ #ifndef UI_SHARED_H #define UI_SHARED_H extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query); extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); extern void cgit_index_link(char *name, char *title, char *class, char *pattern, int ofs); extern void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path); +extern void cgit_plain_link(char *name, char *title, char *class, char *head, + char *rev, char *path); extern void cgit_log_link(char *name, char *title, char *class, char *head, char *rev, char *path, int ofs, char *grep, char *pattern); extern void cgit_commit_link(char *name, char *title, char *class, char *head, char *rev); extern void cgit_patch_link(char *name, char *title, char *class, char *head, char *rev); extern void cgit_refs_link(char *name, char *title, char *class, char *head, char *rev, char *path); extern void cgit_snapshot_link(char *name, char *title, char *class, char *head, char *rev, char *archivename); extern void cgit_diff_link(char *name, char *title, char *class, char *head, char *new_rev, char *old_rev, char *path); extern void cgit_object_link(struct object *obj); extern void cgit_print_error(char *msg); extern void cgit_print_date(time_t secs, char *format, int local_time); extern void cgit_print_age(time_t t, time_t max_relative, char *format); extern void cgit_print_http_headers(struct cgit_context *ctx); extern void cgit_print_docstart(struct cgit_context *ctx); extern void cgit_print_docend(); extern void cgit_print_pageheader(struct cgit_context *ctx); extern void cgit_print_filemode(unsigned short mode); extern void cgit_print_snapshot_links(const char *repo, const char *head, @@ -14,52 +14,52 @@ char *curr_rev; char *match_path; int header = 0; static void print_object(const unsigned char *sha1, char *path) { enum object_type type; char *buf; unsigned long size, lineno, start, idx; const char *linefmt = "<tr><td class='no'><a id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a></td><td class='txt'>"; type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(sha1))); return; } buf = read_sha1_file(sha1, &type, &size); if (!buf) { cgit_print_error(fmt("Error reading object %s", sha1_to_hex(sha1))); return; } - html(" blob: <a href='"); - html_attr(cgit_pageurl(ctx.qry.repo, "blob", - fmt("id=%s&path=%s", sha1_to_hex(sha1), path))); - htmlf("'>%s</a>",sha1_to_hex(sha1)); + html(" ("); + cgit_plain_link("plain", NULL, NULL, ctx.qry.head, + curr_rev, path); + htmlf(")<br/>blob: %s", sha1_to_hex(sha1)); html("<table summary='blob content' class='blob'>\n"); idx = 0; start = 0; lineno = 0; while(idx < size) { if (buf[idx] == '\n') { buf[idx] = '\0'; htmlf(linefmt, ++lineno); html_txt(buf + start); html("</td></tr>\n"); start = idx + 1; } idx++; } htmlf(linefmt, ++lineno); html_txt(buf + start); html("</td></tr>\n"); html("</table>\n"); } static int ls_item(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned int mode, int stage, |