author | Lars Hjemli <hjemli@gmail.com> | 2009-09-13 20:01:52 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-09-13 20:01:52 (UTC) |
commit | 5f12e45fe3338095916a444ff106dd9fc9991d84 (patch) (unidiff) | |
tree | 26b04e10b2ea277c09620bcf119eaa8f79e2fb88 | |
parent | 45c49d6cf4b819385dfee620a81e3cb095ed5cd1 (diff) | |
parent | 6638f40868ccf7806a9668560d3608324704c2b7 (diff) | |
download | cgit-5f12e45fe3338095916a444ff106dd9fc9991d84.zip cgit-5f12e45fe3338095916a444ff106dd9fc9991d84.tar.gz cgit-5f12e45fe3338095916a444ff106dd9fc9991d84.tar.bz2 |
Merge branch 'fp/linenumbers'
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.css | 6 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-tree.c | 35 |
5 files changed, 32 insertions, 17 deletions
@@ -81,16 +81,18 @@ void config_cb(const char *name, const char *value) | |||
81 | else if (!strcmp(name, "snapshots")) | 81 | else if (!strcmp(name, "snapshots")) |
82 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 82 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
83 | else if (!strcmp(name, "enable-index-links")) | 83 | else if (!strcmp(name, "enable-index-links")) |
84 | ctx.cfg.enable_index_links = atoi(value); | 84 | ctx.cfg.enable_index_links = atoi(value); |
85 | else if (!strcmp(name, "enable-log-filecount")) | 85 | else if (!strcmp(name, "enable-log-filecount")) |
86 | ctx.cfg.enable_log_filecount = atoi(value); | 86 | ctx.cfg.enable_log_filecount = atoi(value); |
87 | else if (!strcmp(name, "enable-log-linecount")) | 87 | else if (!strcmp(name, "enable-log-linecount")) |
88 | ctx.cfg.enable_log_linecount = atoi(value); | 88 | ctx.cfg.enable_log_linecount = atoi(value); |
89 | else if (!strcmp(name, "enable-tree-linenumbers")) | ||
90 | ctx.cfg.enable_tree_linenumbers = atoi(value); | ||
89 | else if (!strcmp(name, "max-stats")) | 91 | else if (!strcmp(name, "max-stats")) |
90 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 92 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
91 | else if (!strcmp(name, "cache-size")) | 93 | else if (!strcmp(name, "cache-size")) |
92 | ctx.cfg.cache_size = atoi(value); | 94 | ctx.cfg.cache_size = atoi(value); |
93 | else if (!strcmp(name, "cache-root")) | 95 | else if (!strcmp(name, "cache-root")) |
94 | ctx.cfg.cache_root = xstrdup(value); | 96 | ctx.cfg.cache_root = xstrdup(value); |
95 | else if (!strcmp(name, "cache-root-ttl")) | 97 | else if (!strcmp(name, "cache-root-ttl")) |
96 | ctx.cfg.cache_root_ttl = atoi(value); | 98 | ctx.cfg.cache_root_ttl = atoi(value); |
@@ -233,16 +235,17 @@ static void prepare_context(struct cgit_context *ctx) | |||
233 | ctx->cfg.cache_max_create_time = 5; | 235 | ctx->cfg.cache_max_create_time = 5; |
234 | ctx->cfg.cache_repo_ttl = 5; | 236 | ctx->cfg.cache_repo_ttl = 5; |
235 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; | 237 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
236 | ctx->cfg.cache_root_ttl = 5; | 238 | ctx->cfg.cache_root_ttl = 5; |
237 | ctx->cfg.cache_static_ttl = -1; | 239 | ctx->cfg.cache_static_ttl = -1; |
238 | ctx->cfg.css = "/cgit.css"; | 240 | ctx->cfg.css = "/cgit.css"; |
239 | ctx->cfg.logo = "/cgit.png"; | 241 | ctx->cfg.logo = "/cgit.png"; |
240 | ctx->cfg.local_time = 0; | 242 | ctx->cfg.local_time = 0; |
243 | ctx->cfg.enable_tree_linenumbers = 1; | ||
241 | ctx->cfg.max_repo_count = 50; | 244 | ctx->cfg.max_repo_count = 50; |
242 | ctx->cfg.max_commit_count = 50; | 245 | ctx->cfg.max_commit_count = 50; |
243 | ctx->cfg.max_lock_attempts = 5; | 246 | ctx->cfg.max_lock_attempts = 5; |
244 | ctx->cfg.max_msg_len = 80; | 247 | ctx->cfg.max_msg_len = 80; |
245 | ctx->cfg.max_repodesc_len = 80; | 248 | ctx->cfg.max_repodesc_len = 80; |
246 | ctx->cfg.max_stats = 0; | 249 | ctx->cfg.max_stats = 0; |
247 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 250 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
248 | ctx->cfg.renamelimit = -1; | 251 | ctx->cfg.renamelimit = -1; |
@@ -232,26 +232,26 @@ td.ls-mode { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | table.blob { | 234 | table.blob { |
235 | margin-top: 0.5em; | 235 | margin-top: 0.5em; |
236 | border-top: solid 1px black; | 236 | border-top: solid 1px black; |
237 | } | 237 | } |
238 | 238 | ||
239 | table.blob td.lines { | 239 | table.blob td.lines { |
240 | margin: 0; padding: 0; | 240 | margin: 0; padding: 0 0 0 0.5em; |
241 | vertical-align: top; | 241 | vertical-align: top; |
242 | color: black; | 242 | color: black; |
243 | } | 243 | } |
244 | 244 | ||
245 | table.blob td.linenumbers { | 245 | table.blob td.linenumbers { |
246 | margin: 0; padding: 0; | 246 | margin: 0; padding: 0 0.5em 0 0.5em; |
247 | vertical-align: top; | 247 | vertical-align: top; |
248 | text-align: right; | ||
248 | border-right: 1px solid gray; | 249 | border-right: 1px solid gray; |
249 | background-color: #eee; | ||
250 | } | 250 | } |
251 | 251 | ||
252 | table.blob pre { | 252 | table.blob pre { |
253 | padding: 0; margin: 0; | 253 | padding: 0; margin: 0; |
254 | } | 254 | } |
255 | 255 | ||
256 | table.blob a.no { | 256 | table.blob a.no { |
257 | color: gray; | 257 | color: gray; |
@@ -168,16 +168,17 @@ struct cgit_config { | |||
168 | int cache_max_create_time; | 168 | int cache_max_create_time; |
169 | int cache_repo_ttl; | 169 | int cache_repo_ttl; |
170 | int cache_root_ttl; | 170 | int cache_root_ttl; |
171 | int cache_static_ttl; | 171 | int cache_static_ttl; |
172 | int embedded; | 172 | int embedded; |
173 | int enable_index_links; | 173 | int enable_index_links; |
174 | int enable_log_filecount; | 174 | int enable_log_filecount; |
175 | int enable_log_linecount; | 175 | int enable_log_linecount; |
176 | int enable_tree_linenumbers; | ||
176 | int local_time; | 177 | int local_time; |
177 | int max_repo_count; | 178 | int max_repo_count; |
178 | int max_commit_count; | 179 | int max_commit_count; |
179 | int max_lock_attempts; | 180 | int max_lock_attempts; |
180 | int max_msg_len; | 181 | int max_msg_len; |
181 | int max_repodesc_len; | 182 | int max_repodesc_len; |
182 | int max_stats; | 183 | int max_stats; |
183 | int nocache; | 184 | int nocache; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0d18290..3b16db9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -94,16 +94,20 @@ enable-log-filecount:: | |||
94 | modified files for each commit on the repository log page. Default | 94 | modified files for each commit on the repository log page. Default |
95 | value: "0". | 95 | value: "0". |
96 | 96 | ||
97 | enable-log-linecount:: | 97 | enable-log-linecount:: |
98 | Flag which, when set to "1", will make cgit print the number of added | 98 | Flag which, when set to "1", will make cgit print the number of added |
99 | and removed lines for each commit on the repository log page. Default | 99 | and removed lines for each commit on the repository log page. Default |
100 | value: "0". | 100 | value: "0". |
101 | 101 | ||
102 | enable-tree-linenumbers:: | ||
103 | Flag which, when set to "1", will make cgit generate linenumber links | ||
104 | for plaintext blobs printed in the tree view. Default value: "1". | ||
105 | |||
102 | favicon:: | 106 | favicon:: |
103 | Url used as link to a shortcut icon for cgit. If specified, it is | 107 | Url used as link to a shortcut icon for cgit. If specified, it is |
104 | suggested to use the value "/favicon.ico" since certain browsers will | 108 | suggested to use the value "/favicon.ico" since certain browsers will |
105 | ignore other values. Default value: none. | 109 | ignore other values. Default value: none. |
106 | 110 | ||
107 | footer:: | 111 | footer:: |
108 | The content of the file specified with this option will be included | 112 | The content of the file specified with this option will be included |
109 | verbatim at the bottom of all pages (i.e. it replaces the standard | 113 | verbatim at the bottom of all pages (i.e. it replaces the standard |
@@ -17,39 +17,46 @@ int header = 0; | |||
17 | 17 | ||
18 | static void print_text_buffer(const char *name, char *buf, unsigned long size) | 18 | static void print_text_buffer(const char *name, char *buf, unsigned long size) |
19 | { | 19 | { |
20 | unsigned long lineno, idx; | 20 | unsigned long lineno, idx; |
21 | const char *numberfmt = | 21 | const char *numberfmt = |
22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; | 22 | "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; |
23 | 23 | ||
24 | html("<table summary='blob content' class='blob'>\n"); | 24 | html("<table summary='blob content' class='blob'>\n"); |
25 | |||
26 | if (ctx.cfg.enable_tree_linenumbers) { | ||
27 | html("<tr><td class='linenumbers'><pre>"); | ||
28 | idx = 0; | ||
29 | lineno = 0; | ||
30 | |||
31 | if (size) { | ||
32 | htmlf(numberfmt, ++lineno); | ||
33 | while(idx < size - 1) { // skip absolute last newline | ||
34 | if (buf[idx] == '\n') | ||
35 | htmlf(numberfmt, ++lineno); | ||
36 | idx++; | ||
37 | } | ||
38 | } | ||
39 | html("</pre></td>\n"); | ||
40 | } | ||
41 | else { | ||
42 | html("<tr>\n"); | ||
43 | } | ||
44 | |||
25 | if (ctx.repo->source_filter) { | 45 | if (ctx.repo->source_filter) { |
26 | html("<tr><td class='lines'><pre><code>"); | 46 | html("<td class='lines'><pre><code>"); |
27 | ctx.repo->source_filter->argv[1] = xstrdup(name); | 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
28 | cgit_open_filter(ctx.repo->source_filter); | 48 | cgit_open_filter(ctx.repo->source_filter); |
29 | write(STDOUT_FILENO, buf, size); | 49 | write(STDOUT_FILENO, buf, size); |
30 | cgit_close_filter(ctx.repo->source_filter); | 50 | cgit_close_filter(ctx.repo->source_filter); |
31 | html("</code></pre></td></tr></table>\n"); | 51 | html("</code></pre></td></tr></table>\n"); |
32 | return; | 52 | return; |
33 | } | 53 | } |
34 | 54 | ||
35 | html("<tr><td class='linenumbers'><pre>"); | ||
36 | idx = 0; | ||
37 | lineno = 0; | ||
38 | |||
39 | if (size) { | ||
40 | htmlf(numberfmt, ++lineno); | ||
41 | while(idx < size - 1) { // skip absolute last newline | ||
42 | if (buf[idx] == '\n') | ||
43 | htmlf(numberfmt, ++lineno); | ||
44 | idx++; | ||
45 | } | ||
46 | } | ||
47 | html("</pre></td>\n"); | ||
48 | html("<td class='lines'><pre><code>"); | 55 | html("<td class='lines'><pre><code>"); |
49 | html_txt(buf); | 56 | html_txt(buf); |
50 | html("</code></pre></td></tr></table>\n"); | 57 | html("</code></pre></td></tr></table>\n"); |
51 | } | 58 | } |
52 | 59 | ||
53 | #define ROWLEN 32 | 60 | #define ROWLEN 32 |
54 | 61 | ||
55 | static void print_binary_buffer(char *buf, unsigned long size) | 62 | static void print_binary_buffer(char *buf, unsigned long size) |