author | Onne Gorter <onne.gorter@avinity.net> | 2009-01-07 12:56:14 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-01-10 11:13:54 (UTC) |
commit | a90e2aa4e1bd5c3a9657ce7d675943f4a265cc9f (patch) (side-by-side diff) | |
tree | bd7d4cce277dbe3094dee0130410a738b074e5b2 | |
parent | 25f6a1f4c29b6a6009a185e9473317f0fe64616d (diff) | |
download | cgit-a90e2aa4e1bd5c3a9657ce7d675943f4a265cc9f.zip cgit-a90e2aa4e1bd5c3a9657ce7d675943f4a265cc9f.tar.gz cgit-a90e2aa4e1bd5c3a9657ce7d675943f4a265cc9f.tar.bz2 |
changed objects are outputted, allowing for selections of code only
-rw-r--r-- | cgit.css | 27 | ||||
-rwxr-xr-x | tests/t0104-tree.sh | 4 | ||||
-rw-r--r-- | ui-tree.c | 31 |
3 files changed, 34 insertions, 28 deletions
@@ -233,32 +233,37 @@ td.ls-mode { table.blob { margin-top: 0.5em; border-top: solid 1px black; } -table.blob td.no { - border-right: solid 1px black; +table.blob td.lines { + margin: 0; padding: 0; + vertical-align: top; color: black; +} + +table.blob td.linenumbers { + margin: 0; padding: 0; + vertical-align: top; + border-right: 1px solid gray; background-color: #eee; - text-align: right; } -table.blob td.no a { - color: black; +table.blob pre { + padding: 0; margin: 0; } -table.blob td.no a:hover { - color: black; +table.blob a.no { + color: gray; + text-align: right; text-decoration: none; } -table.blob td.txt { - white-space: pre; - font-family: monospace; - padding-left: 0.5em; +table.blob a.no a:hover { + color: black; } table.nowrap td { white-space: nowrap; } diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 33f4eb0..2ce1251 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -8,17 +8,17 @@ run_test 'generate bar/tree' 'cgit_url "bar/tree" >trash/tmp' run_test 'find file-1' 'grep -e "file-1" trash/tmp' run_test 'find file-50' 'grep -e "file-50" trash/tmp' run_test 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp' run_test 'find line 1' ' - grep -e "<a id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp + grep -e "<a class=.no. id=.n1. name=.n1. href=.#n1.>1</a>" trash/tmp ' run_test 'no line 2' ' - ! grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp + ! grep -e "<a class=.no. id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp ' run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' run_test 'verify a+b link' ' grep -e "/foo+bar/tree/a+b" trash/tmp @@ -15,14 +15,14 @@ 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'>"; + unsigned long size, lineno, idx; + const char *numberfmt = "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { cgit_print_error(fmt("Bad object name: %s", sha1_to_hex(sha1))); return; @@ -35,33 +35,34 @@ static void print_object(const unsigned char *sha1, char *path) return; } html(" ("); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, curr_rev, path); - htmlf(")<br/>blob: %s", sha1_to_hex(sha1)); + htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); html("<table summary='blob content' class='blob'>\n"); + html("<tr>\n"); + + html("<td class='linenumbers'><pre>"); idx = 0; - start = 0; lineno = 0; - while(idx < size) { + htmlf(numberfmt, ++lineno); + while(idx < size - 1) { // skip absolute last newline if (buf[idx] == '\n') { - buf[idx] = '\0'; - htmlf(linefmt, ++lineno); - html_txt(buf + start); - html("</td></tr>\n"); - start = idx + 1; + htmlf(numberfmt, ++lineno); } idx++; } - if (start < idx) { - htmlf(linefmt, ++lineno); - html_txt(buf + start); - } - html("</td></tr>\n"); + html("</pre></td>\n"); + + html("<td class='lines'><pre><code>"); + html_txt(buf); + html("</code></pre></td>\n"); + + html("</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, |