changed objects are outputted, allowing for selections of code only
This commit is contained in:
parent
25f6a1f4c2
commit
a90e2aa4e1
33
cgit.css
33
cgit.css
@ -236,26 +236,31 @@ table.blob {
|
|||||||
border-top: solid 1px black;
|
border-top: solid 1px black;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.blob td.no {
|
table.blob td.lines {
|
||||||
border-right: solid 1px black;
|
margin: 0; padding: 0;
|
||||||
|
vertical-align: top;
|
||||||
color: black;
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.blob td.linenumbers {
|
||||||
|
margin: 0; padding: 0;
|
||||||
|
vertical-align: top;
|
||||||
|
border-right: 1px solid gray;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.blob pre {
|
||||||
|
padding: 0; margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.blob a.no {
|
||||||
|
color: gray;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
|
||||||
|
|
||||||
table.blob td.no a {
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.blob td.no a:hover {
|
|
||||||
color: black;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.blob td.txt {
|
table.blob a.no a:hover {
|
||||||
white-space: pre;
|
color: black;
|
||||||
font-family: monospace;
|
|
||||||
padding-left: 0.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table.nowrap td {
|
table.nowrap td {
|
||||||
|
@ -11,11 +11,11 @@ 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 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp'
|
||||||
|
|
||||||
run_test 'find line 1' '
|
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' '
|
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 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'
|
||||||
|
31
ui-tree.c
31
ui-tree.c
@ -18,8 +18,8 @@ static void print_object(const unsigned char *sha1, char *path)
|
|||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
char *buf;
|
char *buf;
|
||||||
unsigned long size, lineno, start, idx;
|
unsigned long size, lineno, 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'>";
|
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);
|
type = sha1_object_info(sha1, &size);
|
||||||
if (type == OBJ_BAD) {
|
if (type == OBJ_BAD) {
|
||||||
@ -38,27 +38,28 @@ static void print_object(const unsigned char *sha1, char *path)
|
|||||||
html(" (");
|
html(" (");
|
||||||
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
|
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
|
||||||
curr_rev, path);
|
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("<table summary='blob content' class='blob'>\n");
|
||||||
|
html("<tr>\n");
|
||||||
|
|
||||||
|
html("<td class='linenumbers'><pre>");
|
||||||
idx = 0;
|
idx = 0;
|
||||||
start = 0;
|
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
while(idx < size) {
|
htmlf(numberfmt, ++lineno);
|
||||||
|
while(idx < size - 1) { // skip absolute last newline
|
||||||
if (buf[idx] == '\n') {
|
if (buf[idx] == '\n') {
|
||||||
buf[idx] = '\0';
|
htmlf(numberfmt, ++lineno);
|
||||||
htmlf(linefmt, ++lineno);
|
|
||||||
html_txt(buf + start);
|
|
||||||
html("</td></tr>\n");
|
|
||||||
start = idx + 1;
|
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (start < idx) {
|
html("</pre></td>\n");
|
||||||
htmlf(linefmt, ++lineno);
|
|
||||||
html_txt(buf + start);
|
html("<td class='lines'><pre><code>");
|
||||||
}
|
html_txt(buf);
|
||||||
html("</td></tr>\n");
|
html("</code></pre></td>\n");
|
||||||
|
|
||||||
|
html("</tr>\n");
|
||||||
html("</table>\n");
|
html("</table>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user