author | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 11:17:00 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 11:17:00 (UTC) |
commit | 426032f767763b46f462de51d1ebded34f671d79 (patch) (unidiff) | |
tree | c94684f2d5f6c4ea500ebc60a36a7d74ff76cadb /ui-tree.c | |
parent | 486c87ec2906c445ca505c877720d56e02aed784 (diff) | |
download | cgit-426032f767763b46f462de51d1ebded34f671d79.zip cgit-426032f767763b46f462de51d1ebded34f671d79.tar.gz cgit-426032f767763b46f462de51d1ebded34f671d79.tar.bz2 |
ui-tree: html/css cleanup
Various fixes to make html and css more "clean". The only visible change
is the link to file/directory log: it is now printed as "L" (for Log)
instead of "H" (for History).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-tree.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -27,125 +27,123 @@ static void print_object(const unsigned char *sha1, char *path) | |||
27 | 27 | ||
28 | buf = read_sha1_file(sha1, &type, &size); | 28 | buf = read_sha1_file(sha1, &type, &size); |
29 | if (!buf) { | 29 | if (!buf) { |
30 | cgit_print_error(fmt("Error reading object %s", | 30 | cgit_print_error(fmt("Error reading object %s", |
31 | sha1_to_hex(sha1))); | 31 | sha1_to_hex(sha1))); |
32 | return; | 32 | return; |
33 | } | 33 | } |
34 | 34 | ||
35 | html("<table class='blob'>\n"); | 35 | html("<table class='blob'>\n"); |
36 | idx = 0; | 36 | idx = 0; |
37 | start = 0; | 37 | start = 0; |
38 | lineno = 0; | 38 | lineno = 0; |
39 | while(idx < size) { | 39 | while(idx < size) { |
40 | if (buf[idx] == '\n') { | 40 | if (buf[idx] == '\n') { |
41 | buf[idx] = '\0'; | 41 | buf[idx] = '\0'; |
42 | htmlf("<tr><td class='no'>%d</td><td class='txt'>", | 42 | htmlf("<tr><td class='no'>%d</td><td class='txt'>", |
43 | ++lineno); | 43 | ++lineno); |
44 | html_txt(buf + start); | 44 | html_txt(buf + start); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | start = idx + 1; | 46 | start = idx + 1; |
47 | } | 47 | } |
48 | idx++; | 48 | idx++; |
49 | } | 49 | } |
50 | html("</table>\n"); | 50 | html("</table>\n"); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, | 54 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, |
55 | const char *pathname, unsigned int mode, int stage) | 55 | const char *pathname, unsigned int mode, int stage) |
56 | { | 56 | { |
57 | char *name; | 57 | char *name; |
58 | char *fullpath; | 58 | char *fullpath; |
59 | enum object_type type; | 59 | enum object_type type; |
60 | unsigned long size = 0; | 60 | unsigned long size = 0; |
61 | char *url, *qry; | 61 | char *url, *qry; |
62 | 62 | ||
63 | name = xstrdup(pathname); | 63 | name = xstrdup(pathname); |
64 | fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", | 64 | fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", |
65 | cgit_query_path ? "/" : "", name); | 65 | cgit_query_path ? "/" : "", name); |
66 | 66 | ||
67 | type = sha1_object_info(sha1, &size); | 67 | type = sha1_object_info(sha1, &size); |
68 | if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { | 68 | if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { |
69 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", | 69 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
70 | name, | 70 | name, |
71 | sha1_to_hex(sha1)); | 71 | sha1_to_hex(sha1)); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | html("<tr><td class='filemode'>"); | 75 | html("<tr><td class='ls-mode'>"); |
76 | html_filemode(mode); | 76 | html_filemode(mode); |
77 | html("</td><td "); | 77 | html("</td><td>"); |
78 | if (S_ISDIRLNK(mode)) { | 78 | if (S_ISDIRLNK(mode)) { |
79 | htmlf("class='ls-mod'><a href='"); | 79 | htmlf("<a class='ls-mod' href='"); |
80 | html_attr(fmt(cgit_repo->module_link, | 80 | html_attr(fmt(cgit_repo->module_link, |
81 | name, | 81 | name, |
82 | sha1_to_hex(sha1))); | 82 | sha1_to_hex(sha1))); |
83 | html("'>"); | 83 | html("'>"); |
84 | html_txt(name); | 84 | html_txt(name); |
85 | html("</a>"); | 85 | html("</a>"); |
86 | } else if (S_ISDIR(mode)) { | 86 | } else if (S_ISDIR(mode)) { |
87 | html("class='ls-dir'>"); | 87 | cgit_tree_link(name, NULL, "ls-dir", cgit_query_head, |
88 | cgit_tree_link(name, NULL, NULL, cgit_query_head, | ||
89 | curr_rev, fullpath); | 88 | curr_rev, fullpath); |
90 | } else { | 89 | } else { |
91 | html("class='ls-blob'>"); | 90 | cgit_tree_link(name, NULL, "ls-blob", cgit_query_head, |
92 | cgit_tree_link(name, NULL, NULL, cgit_query_head, | ||
93 | curr_rev, fullpath); | 91 | curr_rev, fullpath); |
94 | } | 92 | } |
95 | htmlf("</td><td class='filesize'>%li</td>", size); | 93 | htmlf("</td><td class='ls-size'>%li</td>", size); |
96 | 94 | ||
97 | html("<td class='links'><a href='"); | 95 | html("<td><a href='"); |
98 | qry = fmt("h=%s&path=%s%s%s", curr_rev, | 96 | qry = fmt("h=%s&path=%s%s%s", curr_rev, |
99 | cgit_query_path ? cgit_query_path : "", | 97 | cgit_query_path ? cgit_query_path : "", |
100 | cgit_query_path ? "/" : "", pathname); | 98 | cgit_query_path ? "/" : "", pathname); |
101 | url = cgit_pageurl(cgit_query_repo, "log", qry); | 99 | url = cgit_pageurl(cgit_query_repo, "log", qry); |
102 | html_attr(url); | 100 | html_attr(url); |
103 | html("' class='button'>H</a></td>"); | 101 | html("' title='Log' class='button'>L</a></td>"); |
104 | html("</tr>\n"); | 102 | html("</tr>\n"); |
105 | free(name); | 103 | free(name); |
106 | return 0; | 104 | return 0; |
107 | } | 105 | } |
108 | 106 | ||
109 | static void ls_head() | 107 | static void ls_head() |
110 | { | 108 | { |
111 | html("<table class='list'>\n"); | 109 | html("<table class='list'>\n"); |
112 | html("<tr class='nohover'>"); | 110 | html("<tr class='nohover'>"); |
113 | html("<th class='left'>Mode</th>"); | 111 | html("<th class='left'>Mode</th>"); |
114 | html("<th class='left'>Name</th>"); | 112 | html("<th class='left'>Name</th>"); |
115 | html("<th class='right'>Size</th>"); | 113 | html("<th class='right'>Size</th>"); |
116 | html("<th/>"); | 114 | html("<th/>"); |
117 | html("</tr>\n"); | 115 | html("</tr>\n"); |
118 | header = 1; | 116 | header = 1; |
119 | } | 117 | } |
120 | 118 | ||
121 | static void ls_tail() | 119 | static void ls_tail() |
122 | { | 120 | { |
123 | if (!header) | 121 | if (!header) |
124 | return; | 122 | return; |
125 | html("</table>\n"); | 123 | html("</table>\n"); |
126 | header = 0; | 124 | header = 0; |
127 | } | 125 | } |
128 | 126 | ||
129 | static void ls_tree(const unsigned char *sha1, char *path) | 127 | static void ls_tree(const unsigned char *sha1, char *path) |
130 | { | 128 | { |
131 | struct tree *tree; | 129 | struct tree *tree; |
132 | 130 | ||
133 | tree = parse_tree_indirect(sha1); | 131 | tree = parse_tree_indirect(sha1); |
134 | if (!tree) { | 132 | if (!tree) { |
135 | cgit_print_error(fmt("Not a tree object: %s", | 133 | cgit_print_error(fmt("Not a tree object: %s", |
136 | sha1_to_hex(sha1))); | 134 | sha1_to_hex(sha1))); |
137 | return; | 135 | return; |
138 | } | 136 | } |
139 | 137 | ||
140 | ls_head(); | 138 | ls_head(); |
141 | read_tree_recursive(tree, "", 0, 1, NULL, ls_item); | 139 | read_tree_recursive(tree, "", 0, 1, NULL, ls_item); |
142 | ls_tail(); | 140 | ls_tail(); |
143 | } | 141 | } |
144 | 142 | ||
145 | 143 | ||
146 | static int walk_tree(const unsigned char *sha1, const char *base, int baselen, | 144 | static int walk_tree(const unsigned char *sha1, const char *base, int baselen, |
147 | const char *pathname, unsigned mode, int stage) | 145 | const char *pathname, unsigned mode, int stage) |
148 | { | 146 | { |
149 | static int state; | 147 | static int state; |
150 | static char buffer[PATH_MAX]; | 148 | static char buffer[PATH_MAX]; |
151 | char *url; | 149 | char *url; |