author | Lars Hjemli <larsh@slaptop.hjemli.net> | 2007-01-27 23:39:26 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-01-27 23:52:41 (UTC) |
commit | 777faf7e509e1de2b795b2a326ff00c9bd799104 (patch) (unidiff) | |
tree | ccb440445caf46cbfa3d4bd21d743697f37a9876 /ui-tree.c | |
parent | 447025f62ccbbb6e038d42009368e28f3e162460 (diff) | |
download | cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.zip cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.tar.gz cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.tar.bz2 |
Cleanup table listings
Make the output for <table class='list'> a bit nicer
Signed-off-by: Lars Hjemli <larsh@slaptop.hjemli.net>
-rw-r--r-- | ui-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1,79 +1,79 @@ | |||
1 | /* ui-tree.c: functions for tree output | 1 | /* ui-tree.c: functions for tree output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | 11 | ||
12 | static int print_entry(const unsigned char *sha1, const char *base, | 12 | static int print_entry(const unsigned char *sha1, const char *base, |
13 | int baselen, const char *pathname, unsigned int mode, | 13 | int baselen, const char *pathname, unsigned int mode, |
14 | int stage) | 14 | int stage) |
15 | { | 15 | { |
16 | char *name; | 16 | char *name; |
17 | char type[20]; | 17 | char type[20]; |
18 | unsigned long size; | 18 | unsigned long size; |
19 | 19 | ||
20 | if (sha1_object_info(sha1, type, &size)) { | 20 | if (sha1_object_info(sha1, type, &size)) { |
21 | cgit_print_error(fmt("Bad object name: %s", | 21 | cgit_print_error(fmt("Bad object name: %s", |
22 | sha1_to_hex(sha1))); | 22 | sha1_to_hex(sha1))); |
23 | return 0; | 23 | return 0; |
24 | } | 24 | } |
25 | name = xstrdup(pathname); | 25 | name = xstrdup(pathname); |
26 | html("<tr><td class='filemode'>"); | 26 | html("<tr><td class='filemode'>"); |
27 | html_filemode(mode); | 27 | html_filemode(mode); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | if (S_ISDIR(mode)) { | 29 | if (S_ISDIR(mode)) { |
30 | html("<div class='ls-dir'><a href='"); | 30 | html("<div class='ls-dir'><a href='"); |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", | 31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
32 | fmt("id=%s&path=%s%s/", | 32 | fmt("id=%s&path=%s%s/", |
33 | sha1_to_hex(sha1), | 33 | sha1_to_hex(sha1), |
34 | cgit_query_path ? cgit_query_path : "", | 34 | cgit_query_path ? cgit_query_path : "", |
35 | pathname))); | 35 | pathname))); |
36 | } else { | 36 | } else { |
37 | html("<div class='ls-blob'><a href='"); | 37 | html("<div class='ls-blob'><a href='"); |
38 | html_attr(cgit_pageurl(cgit_query_repo, "view", | 38 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), | 39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
40 | cgit_query_path ? cgit_query_path : "", | 40 | cgit_query_path ? cgit_query_path : "", |
41 | pathname))); | 41 | pathname))); |
42 | } | 42 | } |
43 | html("'>"); | 43 | html("'>"); |
44 | html_txt(name); | 44 | html_txt(name); |
45 | if (S_ISDIR(mode)) | 45 | if (S_ISDIR(mode)) |
46 | html("/"); | 46 | html("/"); |
47 | html("</a></div></td>"); | 47 | html("</a></div></td>"); |
48 | htmlf("<td class='filesize'>%li</td>", size); | 48 | htmlf("<td class='filesize'>%li</td>", size); |
49 | html("</tr>\n"); | 49 | html("</tr>\n"); |
50 | free(name); | 50 | free(name); |
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | void cgit_print_tree(const char *hex, char *path) | 54 | void cgit_print_tree(const char *hex, char *path) |
55 | { | 55 | { |
56 | struct tree *tree; | 56 | struct tree *tree; |
57 | unsigned char sha1[20]; | 57 | unsigned char sha1[20]; |
58 | 58 | ||
59 | if (get_sha1_hex(hex, sha1)) { | 59 | if (get_sha1_hex(hex, sha1)) { |
60 | cgit_print_error(fmt("Invalid object id: %s", hex)); | 60 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | tree = parse_tree_indirect(sha1); | 63 | tree = parse_tree_indirect(sha1); |
64 | if (!tree) { | 64 | if (!tree) { |
65 | cgit_print_error(fmt("Not a tree object: %s", hex)); | 65 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | 68 | ||
69 | html("<h2>Tree content</h2>\n"); | 69 | html("<h2>Tree content</h2>\n"); |
70 | html_txt(path); | 70 | html_txt(path); |
71 | html("<table class='list'>\n"); | 71 | html("<table class='list'>\n"); |
72 | html("<tr>"); | 72 | html("<tr class='nohover'>"); |
73 | html("<th class='left'>Mode</th>"); | 73 | html("<th class='left'>Mode</th>"); |
74 | html("<th class='left'>Name</th>"); | 74 | html("<th class='left'>Name</th>"); |
75 | html("<th class='right'>Size</th>"); | 75 | html("<th class='right'>Size</th>"); |
76 | html("</tr>\n"); | 76 | html("</tr>\n"); |
77 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); | 77 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); |
78 | html("</table>\n"); | 78 | html("</table>\n"); |
79 | } | 79 | } |