aboutsummaryrefslogtreecommitdiffstats
path: root/ui-view.c
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2007-06-17 03:20:42 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2007-06-17 03:20:42 (JST)
commitffc69736a606fd8f9a10468cce48b9a37b428944 (patch)
treeb080c702391244a525fa0e7c97758f7f7fa0c383 /ui-view.c
parent849f0f0f02f858e21fbe59295846e51628f82915 (diff)
downloadcgit-ffc69736a606fd8f9a10468cce48b9a37b428944.zip
cgit-ffc69736a606fd8f9a10468cce48b9a37b428944.tar.gz
ui-tree: unify with ui-view, use path to select tree/blob
This teaches ui-tree to show both trees and blobs, thereby making ui-view superfluous. At the same time, ui-tree is extended to honour the specified path instead of requiering a tree/blob sha1.
Diffstat (limited to 'ui-view.c')
-rw-r--r--ui-view.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/ui-view.c b/ui-view.c
deleted file mode 100644
index 8873415..0000000
--- a/ui-view.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* ui-view.c: functions to output _any_ object, given it's sha1
2 *
3 * Copyright (C) 2006 Lars Hjemli
4 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
8
9#include "cgit.h"
10
11void cgit_print_view(const char *hex, char *path)
12{
13 unsigned char sha1[20];
14 enum object_type type;
15 unsigned char *buf;
16 unsigned long size;
17
18 if (get_sha1_hex(hex, sha1)){
19 cgit_print_error(fmt("Bad hex value: %s", hex));
20 return;
21 }
22
23 type = sha1_object_info(sha1, &size);
24 if (type == OBJ_BAD) {
25 cgit_print_error(fmt("Bad object name: %s", hex));
26 return;
27 }
28
29 buf = read_sha1_file(sha1, &type, &size);
30 if (!buf) {
31 cgit_print_error(fmt("Error reading object %s", hex));
32 return;
33 }
34
35 buf[size] = '\0';
36 html("<table class='list'>\n");
37 html("<tr class='nohover'><th class='left'>");
38 if (path)
39 htmlf("%s (", path);
40 htmlf("%s %s, %li bytes", typename(type), hex, size);
41 if (path)
42 html(")");
43
44 html(" <a href='");
45 html_attr(cgit_pageurl(cgit_query_repo, "blob",
46 fmt("id=%s&amp;path=%s",
47 hex,
48 path)));
49 html("'>download</a>");
50 html("</th></tr>\n");
51 html("<tr><td class='blob'>\n");
52 html_txt(buf);
53 html("\n</td></tr>\n");
54 html("</table>\n");
55}