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
@@ -77,24 +77,26 @@ void config_cb(const char *name, const char *value) | |||
77 | else if (!strcmp(name, "noplainemail")) | 77 | else if (!strcmp(name, "noplainemail")) |
78 | ctx.cfg.noplainemail = atoi(value); | 78 | ctx.cfg.noplainemail = atoi(value); |
79 | else if (!strcmp(name, "noheader")) | 79 | else if (!strcmp(name, "noheader")) |
80 | ctx.cfg.noheader = atoi(value); | 80 | ctx.cfg.noheader = atoi(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); |
97 | else if (!strcmp(name, "cache-repo-ttl")) | 99 | else if (!strcmp(name, "cache-repo-ttl")) |
98 | ctx.cfg.cache_repo_ttl = atoi(value); | 100 | ctx.cfg.cache_repo_ttl = atoi(value); |
99 | else if (!strcmp(name, "cache-static-ttl")) | 101 | else if (!strcmp(name, "cache-static-ttl")) |
100 | ctx.cfg.cache_static_ttl = atoi(value); | 102 | ctx.cfg.cache_static_ttl = atoi(value); |
@@ -229,24 +231,25 @@ static void prepare_context(struct cgit_context *ctx) | |||
229 | ctx->cfg.agefile = "info/web/last-modified"; | 231 | ctx->cfg.agefile = "info/web/last-modified"; |
230 | ctx->cfg.nocache = 0; | 232 | ctx->cfg.nocache = 0; |
231 | ctx->cfg.cache_size = 0; | 233 | ctx->cfg.cache_size = 0; |
232 | ctx->cfg.cache_dynamic_ttl = 5; | 234 | ctx->cfg.cache_dynamic_ttl = 5; |
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; |
249 | ctx->cfg.robots = "index, nofollow"; | 252 | ctx->cfg.robots = "index, nofollow"; |
250 | ctx->cfg.root_title = "Git repository browser"; | 253 | ctx->cfg.root_title = "Git repository browser"; |
251 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 254 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
252 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; | 255 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
@@ -228,34 +228,34 @@ td.ls-size { | |||
228 | 228 | ||
229 | td.ls-mode { | 229 | td.ls-mode { |
230 | font-family: monospace; | 230 | font-family: monospace; |
231 | width: 10em; | 231 | width: 10em; |
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; |
258 | text-align: right; | 258 | text-align: right; |
259 | text-decoration: none; | 259 | text-decoration: none; |
260 | } | 260 | } |
261 | 261 | ||
@@ -164,24 +164,25 @@ struct cgit_config { | |||
164 | char *script_name; | 164 | char *script_name; |
165 | char *virtual_root; | 165 | char *virtual_root; |
166 | int cache_size; | 166 | int cache_size; |
167 | int cache_dynamic_ttl; | 167 | int cache_dynamic_ttl; |
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; |
184 | int noplainemail; | 185 | int noplainemail; |
185 | int noheader; | 186 | int noheader; |
186 | int renamelimit; | 187 | int renamelimit; |
187 | int snapshots; | 188 | int snapshots; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0d18290..3b16db9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -90,24 +90,28 @@ enable-index-links:: | |||
90 | "commit" and "tree" pages). Default value: "0". | 90 | "commit" and "tree" pages). Default value: "0". |
91 | 91 | ||
92 | enable-log-filecount:: | 92 | enable-log-filecount:: |
93 | Flag which, when set to "1", will make cgit print the number of | 93 | Flag which, when set to "1", will make cgit print the number of |
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 |
110 | "generated by..." message. Default value: none. | 114 | "generated by..." message. Default value: none. |
111 | 115 | ||
112 | head-include:: | 116 | head-include:: |
113 | The content of the file specified with this option will be included | 117 | The content of the file specified with this option will be included |
@@ -13,47 +13,54 @@ | |||
13 | 13 | ||
14 | char *curr_rev; | 14 | char *curr_rev; |
15 | char *match_path; | 15 | char *match_path; |
16 | int header = 0; | 16 | 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) |
56 | { | 63 | { |
57 | unsigned long ofs, idx; | 64 | unsigned long ofs, idx; |
58 | static char ascii[ROWLEN + 1]; | 65 | static char ascii[ROWLEN + 1]; |
59 | 66 | ||