author | Lars Hjemli <hjemli@gmail.com> | 2008-02-23 21:45:33 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-18 07:13:10 (UTC) |
commit | b1f9b9c1459cb9a30ebf80721aff6ef788d1f891 (patch) (unidiff) | |
tree | 05796a741faef90c12aadd3a5c92b702ec870c48 /ui-tree.c | |
parent | b88fb016d0209f7041ac7d3b4d2c077318407a4d (diff) | |
download | cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.zip cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.gz cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.bz2 |
Introduce html.h
All html-functions can be quite easily separated from the rest of cgit, so
lets do it; the only issue was html_filemode which uses some git-defined
macros so the function is moved into ui-shared.c::cgit_print_filemode().
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-tree.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1,25 +1,26 @@ | |||
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 | #include "html.h" | ||
10 | 11 | ||
11 | char *curr_rev; | 12 | char *curr_rev; |
12 | char *match_path; | 13 | char *match_path; |
13 | int header = 0; | 14 | int header = 0; |
14 | 15 | ||
15 | static void print_object(const unsigned char *sha1, char *path) | 16 | static void print_object(const unsigned char *sha1, char *path) |
16 | { | 17 | { |
17 | enum object_type type; | 18 | enum object_type type; |
18 | char *buf; | 19 | char *buf; |
19 | unsigned long size, lineno, start, idx; | 20 | unsigned long size, lineno, start, idx; |
20 | 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'>"; | 21 | 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'>"; |
21 | 22 | ||
22 | type = sha1_object_info(sha1, &size); | 23 | type = sha1_object_info(sha1, &size); |
23 | if (type == OBJ_BAD) { | 24 | if (type == OBJ_BAD) { |
24 | cgit_print_error(fmt("Bad object name: %s", | 25 | cgit_print_error(fmt("Bad object name: %s", |
25 | sha1_to_hex(sha1))); | 26 | sha1_to_hex(sha1))); |
@@ -66,33 +67,33 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, | |||
66 | enum object_type type; | 67 | enum object_type type; |
67 | unsigned long size = 0; | 68 | unsigned long size = 0; |
68 | 69 | ||
69 | name = xstrdup(pathname); | 70 | name = xstrdup(pathname); |
70 | fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", | 71 | fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", |
71 | ctx.qry.path ? "/" : "", name); | 72 | ctx.qry.path ? "/" : "", name); |
72 | 73 | ||
73 | type = sha1_object_info(sha1, &size); | 74 | type = sha1_object_info(sha1, &size); |
74 | if (type == OBJ_BAD && !S_ISGITLINK(mode)) { | 75 | if (type == OBJ_BAD && !S_ISGITLINK(mode)) { |
75 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", | 76 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
76 | name, | 77 | name, |
77 | sha1_to_hex(sha1)); | 78 | sha1_to_hex(sha1)); |
78 | return 0; | 79 | return 0; |
79 | } | 80 | } |
80 | 81 | ||
81 | html("<tr><td class='ls-mode'>"); | 82 | html("<tr><td class='ls-mode'>"); |
82 | html_filemode(mode); | 83 | cgit_print_filemode(mode); |
83 | html("</td><td>"); | 84 | html("</td><td>"); |
84 | if (S_ISGITLINK(mode)) { | 85 | if (S_ISGITLINK(mode)) { |
85 | htmlf("<a class='ls-mod' href='"); | 86 | htmlf("<a class='ls-mod' href='"); |
86 | html_attr(fmt(ctx.repo->module_link, | 87 | html_attr(fmt(ctx.repo->module_link, |
87 | name, | 88 | name, |
88 | sha1_to_hex(sha1))); | 89 | sha1_to_hex(sha1))); |
89 | html("'>"); | 90 | html("'>"); |
90 | html_txt(name); | 91 | html_txt(name); |
91 | html("</a>"); | 92 | html("</a>"); |
92 | } else if (S_ISDIR(mode)) { | 93 | } else if (S_ISDIR(mode)) { |
93 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, | 94 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, |
94 | curr_rev, fullpath); | 95 | curr_rev, fullpath); |
95 | } else { | 96 | } else { |
96 | cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, | 97 | cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, |
97 | curr_rev, fullpath); | 98 | curr_rev, fullpath); |
98 | } | 99 | } |