author | Florian Pritz <bluewind@xssn.at> | 2009-08-09 20:42:45 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-21 12:17:49 (UTC) |
commit | d67cc7f9d556650438e421cdcda37bc52710bffd (patch) (unidiff) | |
tree | df131c58de7c712550f124f8fb15aef303ff6054 | |
parent | 03389d6e67bfda5cb3ff1504db815f09715ec6f4 (diff) | |
download | cgit-d67cc7f9d556650438e421cdcda37bc52710bffd.zip cgit-d67cc7f9d556650438e421cdcda37bc52710bffd.tar.gz cgit-d67cc7f9d556650438e421cdcda37bc52710bffd.tar.bz2 |
Add 'linenumbers' config option
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-tree.c | 27 |
4 files changed, 23 insertions, 11 deletions
@@ -5,128 +5,130 @@ | |||
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 "cache.h" | 10 | #include "cache.h" |
11 | #include "cmd.h" | 11 | #include "cmd.h" |
12 | #include "configfile.h" | 12 | #include "configfile.h" |
13 | #include "html.h" | 13 | #include "html.h" |
14 | #include "ui-shared.h" | 14 | #include "ui-shared.h" |
15 | #include "ui-stats.h" | 15 | #include "ui-stats.h" |
16 | #include "scan-tree.h" | 16 | #include "scan-tree.h" |
17 | 17 | ||
18 | const char *cgit_version = CGIT_VERSION; | 18 | const char *cgit_version = CGIT_VERSION; |
19 | 19 | ||
20 | void add_mimetype(const char *name, const char *value) | 20 | void add_mimetype(const char *name, const char *value) |
21 | { | 21 | { |
22 | struct string_list_item *item; | 22 | struct string_list_item *item; |
23 | 23 | ||
24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); | 24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); |
25 | item->util = xstrdup(value); | 25 | item->util = xstrdup(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) |
29 | { | 29 | { |
30 | struct cgit_filter *f; | 30 | struct cgit_filter *f; |
31 | 31 | ||
32 | if (!cmd || !cmd[0]) | 32 | if (!cmd || !cmd[0]) |
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | f = xmalloc(sizeof(struct cgit_filter)); | 35 | f = xmalloc(sizeof(struct cgit_filter)); |
36 | f->cmd = xstrdup(cmd); | 36 | f->cmd = xstrdup(cmd); |
37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | 37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); |
38 | f->argv[0] = f->cmd; | 38 | f->argv[0] = f->cmd; |
39 | f->argv[1] = NULL; | 39 | f->argv[1] = NULL; |
40 | return f; | 40 | return f; |
41 | } | 41 | } |
42 | 42 | ||
43 | void config_cb(const char *name, const char *value) | 43 | void config_cb(const char *name, const char *value) |
44 | { | 44 | { |
45 | if (!strcmp(name, "root-title")) | 45 | if (!strcmp(name, "root-title")) |
46 | ctx.cfg.root_title = xstrdup(value); | 46 | ctx.cfg.root_title = xstrdup(value); |
47 | else if (!strcmp(name, "root-desc")) | 47 | else if (!strcmp(name, "root-desc")) |
48 | ctx.cfg.root_desc = xstrdup(value); | 48 | ctx.cfg.root_desc = xstrdup(value); |
49 | else if (!strcmp(name, "root-readme")) | 49 | else if (!strcmp(name, "root-readme")) |
50 | ctx.cfg.root_readme = xstrdup(value); | 50 | ctx.cfg.root_readme = xstrdup(value); |
51 | else if (!strcmp(name, "css")) | 51 | else if (!strcmp(name, "css")) |
52 | ctx.cfg.css = xstrdup(value); | 52 | ctx.cfg.css = xstrdup(value); |
53 | else if (!strcmp(name, "favicon")) | 53 | else if (!strcmp(name, "favicon")) |
54 | ctx.cfg.favicon = xstrdup(value); | 54 | ctx.cfg.favicon = xstrdup(value); |
55 | else if (!strcmp(name, "footer")) | 55 | else if (!strcmp(name, "footer")) |
56 | ctx.cfg.footer = xstrdup(value); | 56 | ctx.cfg.footer = xstrdup(value); |
57 | else if (!strcmp(name, "head-include")) | 57 | else if (!strcmp(name, "head-include")) |
58 | ctx.cfg.head_include = xstrdup(value); | 58 | ctx.cfg.head_include = xstrdup(value); |
59 | else if (!strcmp(name, "header")) | 59 | else if (!strcmp(name, "header")) |
60 | ctx.cfg.header = xstrdup(value); | 60 | ctx.cfg.header = xstrdup(value); |
61 | else if (!strcmp(name, "logo")) | 61 | else if (!strcmp(name, "logo")) |
62 | ctx.cfg.logo = xstrdup(value); | 62 | ctx.cfg.logo = xstrdup(value); |
63 | else if (!strcmp(name, "index-header")) | 63 | else if (!strcmp(name, "index-header")) |
64 | ctx.cfg.index_header = xstrdup(value); | 64 | ctx.cfg.index_header = xstrdup(value); |
65 | else if (!strcmp(name, "index-info")) | 65 | else if (!strcmp(name, "index-info")) |
66 | ctx.cfg.index_info = xstrdup(value); | 66 | ctx.cfg.index_info = xstrdup(value); |
67 | else if (!strcmp(name, "logo-link")) | 67 | else if (!strcmp(name, "logo-link")) |
68 | ctx.cfg.logo_link = xstrdup(value); | 68 | ctx.cfg.logo_link = xstrdup(value); |
69 | else if (!strcmp(name, "linenumbers")) | ||
70 | ctx.cfg.linenumbers = atoi(value); | ||
69 | else if (!strcmp(name, "module-link")) | 71 | else if (!strcmp(name, "module-link")) |
70 | ctx.cfg.module_link = xstrdup(value); | 72 | ctx.cfg.module_link = xstrdup(value); |
71 | else if (!strcmp(name, "virtual-root")) { | 73 | else if (!strcmp(name, "virtual-root")) { |
72 | ctx.cfg.virtual_root = trim_end(value, '/'); | 74 | ctx.cfg.virtual_root = trim_end(value, '/'); |
73 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 75 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
74 | ctx.cfg.virtual_root = ""; | 76 | ctx.cfg.virtual_root = ""; |
75 | } else if (!strcmp(name, "nocache")) | 77 | } else if (!strcmp(name, "nocache")) |
76 | ctx.cfg.nocache = atoi(value); | 78 | ctx.cfg.nocache = atoi(value); |
77 | else if (!strcmp(name, "noplainemail")) | 79 | else if (!strcmp(name, "noplainemail")) |
78 | ctx.cfg.noplainemail = atoi(value); | 80 | ctx.cfg.noplainemail = atoi(value); |
79 | else if (!strcmp(name, "noheader")) | 81 | else if (!strcmp(name, "noheader")) |
80 | ctx.cfg.noheader = atoi(value); | 82 | ctx.cfg.noheader = atoi(value); |
81 | else if (!strcmp(name, "snapshots")) | 83 | else if (!strcmp(name, "snapshots")) |
82 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 84 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
83 | else if (!strcmp(name, "enable-index-links")) | 85 | else if (!strcmp(name, "enable-index-links")) |
84 | ctx.cfg.enable_index_links = atoi(value); | 86 | ctx.cfg.enable_index_links = atoi(value); |
85 | else if (!strcmp(name, "enable-log-filecount")) | 87 | else if (!strcmp(name, "enable-log-filecount")) |
86 | ctx.cfg.enable_log_filecount = atoi(value); | 88 | ctx.cfg.enable_log_filecount = atoi(value); |
87 | else if (!strcmp(name, "enable-log-linecount")) | 89 | else if (!strcmp(name, "enable-log-linecount")) |
88 | ctx.cfg.enable_log_linecount = atoi(value); | 90 | ctx.cfg.enable_log_linecount = 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); |
101 | else if (!strcmp(name, "cache-dynamic-ttl")) | 103 | else if (!strcmp(name, "cache-dynamic-ttl")) |
102 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 104 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
103 | else if (!strcmp(name, "about-filter")) | 105 | else if (!strcmp(name, "about-filter")) |
104 | ctx.cfg.about_filter = new_filter(value, 0); | 106 | ctx.cfg.about_filter = new_filter(value, 0); |
105 | else if (!strcmp(name, "commit-filter")) | 107 | else if (!strcmp(name, "commit-filter")) |
106 | ctx.cfg.commit_filter = new_filter(value, 0); | 108 | ctx.cfg.commit_filter = new_filter(value, 0); |
107 | else if (!strcmp(name, "embedded")) | 109 | else if (!strcmp(name, "embedded")) |
108 | ctx.cfg.embedded = atoi(value); | 110 | ctx.cfg.embedded = atoi(value); |
109 | else if (!strcmp(name, "max-message-length")) | 111 | else if (!strcmp(name, "max-message-length")) |
110 | ctx.cfg.max_msg_len = atoi(value); | 112 | ctx.cfg.max_msg_len = atoi(value); |
111 | else if (!strcmp(name, "max-repodesc-length")) | 113 | else if (!strcmp(name, "max-repodesc-length")) |
112 | ctx.cfg.max_repodesc_len = atoi(value); | 114 | ctx.cfg.max_repodesc_len = atoi(value); |
113 | else if (!strcmp(name, "max-repo-count")) | 115 | else if (!strcmp(name, "max-repo-count")) |
114 | ctx.cfg.max_repo_count = atoi(value); | 116 | ctx.cfg.max_repo_count = atoi(value); |
115 | else if (!strcmp(name, "max-commit-count")) | 117 | else if (!strcmp(name, "max-commit-count")) |
116 | ctx.cfg.max_commit_count = atoi(value); | 118 | ctx.cfg.max_commit_count = atoi(value); |
117 | else if (!strcmp(name, "source-filter")) | 119 | else if (!strcmp(name, "source-filter")) |
118 | ctx.cfg.source_filter = new_filter(value, 1); | 120 | ctx.cfg.source_filter = new_filter(value, 1); |
119 | else if (!strcmp(name, "summary-log")) | 121 | else if (!strcmp(name, "summary-log")) |
120 | ctx.cfg.summary_log = atoi(value); | 122 | ctx.cfg.summary_log = atoi(value); |
121 | else if (!strcmp(name, "summary-branches")) | 123 | else if (!strcmp(name, "summary-branches")) |
122 | ctx.cfg.summary_branches = atoi(value); | 124 | ctx.cfg.summary_branches = atoi(value); |
123 | else if (!strcmp(name, "summary-tags")) | 125 | else if (!strcmp(name, "summary-tags")) |
124 | ctx.cfg.summary_tags = atoi(value); | 126 | ctx.cfg.summary_tags = atoi(value); |
125 | else if (!strcmp(name, "agefile")) | 127 | else if (!strcmp(name, "agefile")) |
126 | ctx.cfg.agefile = xstrdup(value); | 128 | ctx.cfg.agefile = xstrdup(value); |
127 | else if (!strcmp(name, "renamelimit")) | 129 | else if (!strcmp(name, "renamelimit")) |
128 | ctx.cfg.renamelimit = atoi(value); | 130 | ctx.cfg.renamelimit = atoi(value); |
129 | else if (!strcmp(name, "robots")) | 131 | else if (!strcmp(name, "robots")) |
130 | ctx.cfg.robots = xstrdup(value); | 132 | ctx.cfg.robots = xstrdup(value); |
131 | else if (!strcmp(name, "clone-prefix")) | 133 | else if (!strcmp(name, "clone-prefix")) |
132 | ctx.cfg.clone_prefix = xstrdup(value); | 134 | ctx.cfg.clone_prefix = xstrdup(value); |
@@ -113,128 +113,129 @@ struct refinfo { | |||
113 | struct commitinfo *commit; | 113 | struct commitinfo *commit; |
114 | }; | 114 | }; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | struct reflist { | 117 | struct reflist { |
118 | struct refinfo **refs; | 118 | struct refinfo **refs; |
119 | int alloc; | 119 | int alloc; |
120 | int count; | 120 | int count; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | struct cgit_query { | 123 | struct cgit_query { |
124 | int has_symref; | 124 | int has_symref; |
125 | int has_sha1; | 125 | int has_sha1; |
126 | char *raw; | 126 | char *raw; |
127 | char *repo; | 127 | char *repo; |
128 | char *page; | 128 | char *page; |
129 | char *search; | 129 | char *search; |
130 | char *grep; | 130 | char *grep; |
131 | char *head; | 131 | char *head; |
132 | char *sha1; | 132 | char *sha1; |
133 | char *sha2; | 133 | char *sha2; |
134 | char *path; | 134 | char *path; |
135 | char *name; | 135 | char *name; |
136 | char *mimetype; | 136 | char *mimetype; |
137 | char *url; | 137 | char *url; |
138 | char *period; | 138 | char *period; |
139 | int ofs; | 139 | int ofs; |
140 | int nohead; | 140 | int nohead; |
141 | char *sort; | 141 | char *sort; |
142 | int showmsg; | 142 | int showmsg; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | struct cgit_config { | 145 | struct cgit_config { |
146 | char *agefile; | 146 | char *agefile; |
147 | char *cache_root; | 147 | char *cache_root; |
148 | char *clone_prefix; | 148 | char *clone_prefix; |
149 | char *css; | 149 | char *css; |
150 | char *favicon; | 150 | char *favicon; |
151 | char *footer; | 151 | char *footer; |
152 | char *head_include; | 152 | char *head_include; |
153 | char *header; | 153 | char *header; |
154 | char *index_header; | 154 | char *index_header; |
155 | char *index_info; | 155 | char *index_info; |
156 | char *logo; | 156 | char *logo; |
157 | char *logo_link; | 157 | char *logo_link; |
158 | char *module_link; | 158 | char *module_link; |
159 | char *repo_group; | 159 | char *repo_group; |
160 | char *robots; | 160 | char *robots; |
161 | char *root_title; | 161 | char *root_title; |
162 | char *root_desc; | 162 | char *root_desc; |
163 | char *root_readme; | 163 | char *root_readme; |
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 local_time; | 176 | int local_time; |
177 | int linenumbers; | ||
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; |
188 | int summary_branches; | 189 | int summary_branches; |
189 | int summary_log; | 190 | int summary_log; |
190 | int summary_tags; | 191 | int summary_tags; |
191 | struct string_list mimetypes; | 192 | struct string_list mimetypes; |
192 | struct cgit_filter *about_filter; | 193 | struct cgit_filter *about_filter; |
193 | struct cgit_filter *commit_filter; | 194 | struct cgit_filter *commit_filter; |
194 | struct cgit_filter *source_filter; | 195 | struct cgit_filter *source_filter; |
195 | }; | 196 | }; |
196 | 197 | ||
197 | struct cgit_page { | 198 | struct cgit_page { |
198 | time_t modified; | 199 | time_t modified; |
199 | time_t expires; | 200 | time_t expires; |
200 | size_t size; | 201 | size_t size; |
201 | char *mimetype; | 202 | char *mimetype; |
202 | char *charset; | 203 | char *charset; |
203 | char *filename; | 204 | char *filename; |
204 | char *etag; | 205 | char *etag; |
205 | char *title; | 206 | char *title; |
206 | int status; | 207 | int status; |
207 | char *statusmsg; | 208 | char *statusmsg; |
208 | }; | 209 | }; |
209 | 210 | ||
210 | struct cgit_environment { | 211 | struct cgit_environment { |
211 | char *cgit_config; | 212 | char *cgit_config; |
212 | char *http_host; | 213 | char *http_host; |
213 | char *https; | 214 | char *https; |
214 | char *no_http; | 215 | char *no_http; |
215 | char *path_info; | 216 | char *path_info; |
216 | char *query_string; | 217 | char *query_string; |
217 | char *request_method; | 218 | char *request_method; |
218 | char *script_name; | 219 | char *script_name; |
219 | char *server_name; | 220 | char *server_name; |
220 | char *server_port; | 221 | char *server_port; |
221 | }; | 222 | }; |
222 | 223 | ||
223 | struct cgit_context { | 224 | struct cgit_context { |
224 | struct cgit_environment env; | 225 | struct cgit_environment env; |
225 | struct cgit_query qry; | 226 | struct cgit_query qry; |
226 | struct cgit_config cfg; | 227 | struct cgit_config cfg; |
227 | struct cgit_repo *repo; | 228 | struct cgit_repo *repo; |
228 | struct cgit_page page; | 229 | struct cgit_page page; |
229 | }; | 230 | }; |
230 | 231 | ||
231 | struct cgit_snapshot_format { | 232 | struct cgit_snapshot_format { |
232 | const char *suffix; | 233 | const char *suffix; |
233 | const char *mimetype; | 234 | const char *mimetype; |
234 | write_archive_fn_t write_func; | 235 | write_archive_fn_t write_func; |
235 | int bit; | 236 | int bit; |
236 | }; | 237 | }; |
237 | 238 | ||
238 | extern const char *cgit_version; | 239 | extern const char *cgit_version; |
239 | 240 | ||
240 | extern struct cgit_repolist cgit_repolist; | 241 | extern struct cgit_repolist cgit_repolist; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 3c35b02..a762ccc 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -85,128 +85,132 @@ embedded:: | |||
85 | also: "noheader". | 85 | also: "noheader". |
86 | 86 | ||
87 | enable-index-links:: | 87 | enable-index-links:: |
88 | Flag which, when set to "1", will make cgit generate extra links for | 88 | Flag which, when set to "1", will make cgit generate extra links for |
89 | each repo in the repository index (specifically, to the "summary", | 89 | each repo in the repository index (specifically, to the "summary", |
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 | favicon:: | 102 | favicon:: |
103 | Url used as link to a shortcut icon for cgit. If specified, it is | 103 | 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 | 104 | suggested to use the value "/favicon.ico" since certain browsers will |
105 | ignore other values. Default value: none. | 105 | ignore other values. Default value: none. |
106 | 106 | ||
107 | footer:: | 107 | footer:: |
108 | The content of the file specified with this option will be included | 108 | 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 | 109 | verbatim at the bottom of all pages (i.e. it replaces the standard |
110 | "generated by..." message. Default value: none. | 110 | "generated by..." message. Default value: none. |
111 | 111 | ||
112 | head-include:: | 112 | head-include:: |
113 | The content of the file specified with this option will be included | 113 | The content of the file specified with this option will be included |
114 | verbatim in the html HEAD section on all pages. Default value: none. | 114 | verbatim in the html HEAD section on all pages. Default value: none. |
115 | 115 | ||
116 | header:: | 116 | header:: |
117 | 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 |
118 | verbatim at the top of all pages. Default value: none. | 118 | verbatim at the top of all pages. Default value: none. |
119 | 119 | ||
120 | include:: | 120 | include:: |
121 | Name of a configfile to include before the rest of the current config- | 121 | Name of a configfile to include before the rest of the current config- |
122 | file is parsed. Default value: none. | 122 | file is parsed. Default value: none. |
123 | 123 | ||
124 | index-header:: | 124 | index-header:: |
125 | The content of the file specified with this option will be included | 125 | The content of the file specified with this option will be included |
126 | verbatim above the repository index. This setting is deprecated, and | 126 | verbatim above the repository index. This setting is deprecated, and |
127 | will not be supported by cgit-1.0 (use root-readme instead). Default | 127 | will not be supported by cgit-1.0 (use root-readme instead). Default |
128 | value: none. | 128 | value: none. |
129 | 129 | ||
130 | index-info:: | 130 | index-info:: |
131 | The content of the file specified with this option will be included | 131 | The content of the file specified with this option will be included |
132 | verbatim below the heading on the repository index page. This setting | 132 | verbatim below the heading on the repository index page. This setting |
133 | is deprecated, and will not be supported by cgit-1.0 (use root-desc | 133 | is deprecated, and will not be supported by cgit-1.0 (use root-desc |
134 | instead). Default value: none. | 134 | instead). Default value: none. |
135 | 135 | ||
136 | local-time:: | 136 | local-time:: |
137 | Flag which, if set to "1", makes cgit print commit and tag times in the | 137 | Flag which, if set to "1", makes cgit print commit and tag times in the |
138 | servers timezone. Default value: "0". | 138 | servers timezone. Default value: "0". |
139 | 139 | ||
140 | logo:: | 140 | logo:: |
141 | Url which specifies the source of an image which will be used as a logo | 141 | Url which specifies the source of an image which will be used as a logo |
142 | on all cgit pages. Default value: "/cgit.png". | 142 | on all cgit pages. Default value: "/cgit.png". |
143 | 143 | ||
144 | logo-link:: | 144 | logo-link:: |
145 | Url loaded when clicking on the cgit logo image. If unspecified the | 145 | Url loaded when clicking on the cgit logo image. If unspecified the |
146 | calculated url of the repository index page will be used. Default | 146 | calculated url of the repository index page will be used. Default |
147 | value: none. | 147 | value: none. |
148 | 148 | ||
149 | linenumbers:: | ||
150 | If set to "1" lines in tree view will have numbers. | ||
151 | Default value: "0". | ||
152 | |||
149 | max-commit-count:: | 153 | max-commit-count:: |
150 | Specifies the number of entries to list per page in "log" view. Default | 154 | Specifies the number of entries to list per page in "log" view. Default |
151 | value: "50". | 155 | value: "50". |
152 | 156 | ||
153 | max-message-length:: | 157 | max-message-length:: |
154 | Specifies the maximum number of commit message characters to display in | 158 | Specifies the maximum number of commit message characters to display in |
155 | "log" view. Default value: "80". | 159 | "log" view. Default value: "80". |
156 | 160 | ||
157 | max-repo-count:: | 161 | max-repo-count:: |
158 | Specifies the number of entries to list per page on therepository | 162 | Specifies the number of entries to list per page on therepository |
159 | index page. Default value: "50". | 163 | index page. Default value: "50". |
160 | 164 | ||
161 | max-repodesc-length:: | 165 | max-repodesc-length:: |
162 | Specifies the maximum number of repo description characters to display | 166 | Specifies the maximum number of repo description characters to display |
163 | on the repository index page. Default value: "80". | 167 | on the repository index page. Default value: "80". |
164 | 168 | ||
165 | max-stats:: | 169 | max-stats:: |
166 | Set the default maximum statistics period. Valid values are "week", | 170 | Set the default maximum statistics period. Valid values are "week", |
167 | "month", "quarter" and "year". If unspecified, statistics are | 171 | "month", "quarter" and "year". If unspecified, statistics are |
168 | disabled. Default value: none. See also: "repo.max-stats". | 172 | disabled. Default value: none. See also: "repo.max-stats". |
169 | 173 | ||
170 | mimetype.<ext>:: | 174 | mimetype.<ext>:: |
171 | Set the mimetype for the specified filename extension. This is used | 175 | Set the mimetype for the specified filename extension. This is used |
172 | by the `plain` command when returning blob content. | 176 | by the `plain` command when returning blob content. |
173 | 177 | ||
174 | module-link:: | 178 | module-link:: |
175 | Text which will be used as the formatstring for a hyperlink when a | 179 | Text which will be used as the formatstring for a hyperlink when a |
176 | submodule is printed in a directory listing. The arguments for the | 180 | submodule is printed in a directory listing. The arguments for the |
177 | formatstring are the path and SHA1 of the submodule commit. Default | 181 | formatstring are the path and SHA1 of the submodule commit. Default |
178 | value: "./?repo=%s&page=commit&id=%s" | 182 | value: "./?repo=%s&page=commit&id=%s" |
179 | 183 | ||
180 | nocache:: | 184 | nocache:: |
181 | If set to the value "1" caching will be disabled. This settings is | 185 | If set to the value "1" caching will be disabled. This settings is |
182 | deprecated, and will not be honored starting with cgit-1.0. Default | 186 | deprecated, and will not be honored starting with cgit-1.0. Default |
183 | value: "0". | 187 | value: "0". |
184 | 188 | ||
185 | noplainemail:: | 189 | noplainemail:: |
186 | If set to "1" showing full author email adresses will be disabled. | 190 | If set to "1" showing full author email adresses will be disabled. |
187 | Default value: "0". | 191 | Default value: "0". |
188 | 192 | ||
189 | noheader:: | 193 | noheader:: |
190 | Flag which, when set to "1", will make cgit omit the standard header | 194 | Flag which, when set to "1", will make cgit omit the standard header |
191 | on all pages. Default value: none. See also: "embedded". | 195 | on all pages. Default value: none. See also: "embedded". |
192 | 196 | ||
193 | renamelimit:: | 197 | renamelimit:: |
194 | Maximum number of files to consider when detecting renames. The value | 198 | Maximum number of files to consider when detecting renames. The value |
195 | "-1" uses the compiletime value in git (for further info, look at | 199 | "-1" uses the compiletime value in git (for further info, look at |
196 | `man git-diff`). Default value: "-1". | 200 | `man git-diff`). Default value: "-1". |
197 | 201 | ||
198 | repo.group:: | 202 | repo.group:: |
199 | A value for the current repository group, which all repositories | 203 | A value for the current repository group, which all repositories |
200 | specified after this setting will inherit. Default value: none. | 204 | specified after this setting will inherit. Default value: none. |
201 | 205 | ||
202 | robots:: | 206 | robots:: |
203 | Text used as content for the "robots" meta-tag. Default value: | 207 | Text used as content for the "robots" meta-tag. Default value: |
204 | "index, nofollow". | 208 | "index, nofollow". |
205 | 209 | ||
206 | root-desc:: | 210 | root-desc:: |
207 | Text printed below the heading on the repository index page. Default | 211 | Text printed below the heading on the repository index page. Default |
208 | value: "a fast webinterface for the git dscm". | 212 | value: "a fast webinterface for the git dscm". |
209 | 213 | ||
210 | root-readme:: | 214 | root-readme:: |
211 | The content of the file specified with this option will be included | 215 | The content of the file specified with this option will be included |
212 | verbatim below the "about" link on the repository index page. Default | 216 | verbatim below the "about" link on the repository index page. Default |
@@ -1,102 +1,107 @@ | |||
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 <ctype.h> | 9 | #include <ctype.h> |
10 | #include "cgit.h" | 10 | #include "cgit.h" |
11 | #include "html.h" | 11 | #include "html.h" |
12 | #include "ui-shared.h" | 12 | #include "ui-shared.h" |
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 | 25 | ||
26 | html("<tr><td class='linenumbers'><pre>"); | 26 | if (ctx.cfg.linenumbers) { |
27 | idx = 0; | 27 | html("<tr><td class='linenumbers'><pre>"); |
28 | lineno = 0; | 28 | idx = 0; |
29 | 29 | lineno = 0; | |
30 | if (size) { | 30 | |
31 | htmlf(numberfmt, ++lineno); | 31 | if (size) { |
32 | while(idx < size - 1) { // skip absolute last newline | 32 | htmlf(numberfmt, ++lineno); |
33 | if (buf[idx] == '\n') | 33 | while(idx < size - 1) { // skip absolute last newline |
34 | htmlf(numberfmt, ++lineno); | 34 | if (buf[idx] == '\n') |
35 | idx++; | 35 | htmlf(numberfmt, ++lineno); |
36 | idx++; | ||
37 | } | ||
36 | } | 38 | } |
39 | html("</pre></td>\n"); | ||
40 | } | ||
41 | else { | ||
42 | html("<tr>\n"); | ||
37 | } | 43 | } |
38 | html("</pre></td>\n"); | ||
39 | 44 | ||
40 | if (ctx.repo->source_filter) { | 45 | if (ctx.repo->source_filter) { |
41 | html("<td class='lines'><pre><code>"); | 46 | html("<td class='lines'><pre><code>"); |
42 | ctx.repo->source_filter->argv[1] = xstrdup(name); | 47 | ctx.repo->source_filter->argv[1] = xstrdup(name); |
43 | cgit_open_filter(ctx.repo->source_filter); | 48 | cgit_open_filter(ctx.repo->source_filter); |
44 | write(STDOUT_FILENO, buf, size); | 49 | write(STDOUT_FILENO, buf, size); |
45 | cgit_close_filter(ctx.repo->source_filter); | 50 | cgit_close_filter(ctx.repo->source_filter); |
46 | html("</code></pre></td></tr></table>\n"); | 51 | html("</code></pre></td></tr></table>\n"); |
47 | return; | 52 | return; |
48 | } | 53 | } |
49 | 54 | ||
50 | html("<td class='lines'><pre><code>"); | 55 | html("<td class='lines'><pre><code>"); |
51 | html_txt(buf); | 56 | html_txt(buf); |
52 | html("</code></pre></td></tr></table>\n"); | 57 | html("</code></pre></td></tr></table>\n"); |
53 | } | 58 | } |
54 | 59 | ||
55 | #define ROWLEN 32 | 60 | #define ROWLEN 32 |
56 | 61 | ||
57 | static void print_binary_buffer(char *buf, unsigned long size) | 62 | static void print_binary_buffer(char *buf, unsigned long size) |
58 | { | 63 | { |
59 | unsigned long ofs, idx; | 64 | unsigned long ofs, idx; |
60 | static char ascii[ROWLEN + 1]; | 65 | static char ascii[ROWLEN + 1]; |
61 | 66 | ||
62 | html("<table summary='blob content' class='bin-blob'>\n"); | 67 | html("<table summary='blob content' class='bin-blob'>\n"); |
63 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); | 68 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); |
64 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { | 69 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { |
65 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); | 70 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); |
66 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) | 71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
67 | htmlf("%*s%02x", | 72 | htmlf("%*s%02x", |
68 | idx == 16 ? 4 : 1, "", | 73 | idx == 16 ? 4 : 1, "", |
69 | buf[idx] & 0xff); | 74 | buf[idx] & 0xff); |
70 | html(" </td><td class='hex'>"); | 75 | html(" </td><td class='hex'>"); |
71 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) | 76 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
72 | ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.'; | 77 | ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.'; |
73 | ascii[idx] = '\0'; | 78 | ascii[idx] = '\0'; |
74 | html_txt(ascii); | 79 | html_txt(ascii); |
75 | html("</td></tr>\n"); | 80 | html("</td></tr>\n"); |
76 | } | 81 | } |
77 | html("</table>\n"); | 82 | html("</table>\n"); |
78 | } | 83 | } |
79 | 84 | ||
80 | static void print_object(const unsigned char *sha1, char *path, const char *basename) | 85 | static void print_object(const unsigned char *sha1, char *path, const char *basename) |
81 | { | 86 | { |
82 | enum object_type type; | 87 | enum object_type type; |
83 | char *buf; | 88 | char *buf; |
84 | unsigned long size; | 89 | unsigned long size; |
85 | 90 | ||
86 | type = sha1_object_info(sha1, &size); | 91 | type = sha1_object_info(sha1, &size); |
87 | if (type == OBJ_BAD) { | 92 | if (type == OBJ_BAD) { |
88 | cgit_print_error(fmt("Bad object name: %s", | 93 | cgit_print_error(fmt("Bad object name: %s", |
89 | sha1_to_hex(sha1))); | 94 | sha1_to_hex(sha1))); |
90 | return; | 95 | return; |
91 | } | 96 | } |
92 | 97 | ||
93 | buf = read_sha1_file(sha1, &type, &size); | 98 | buf = read_sha1_file(sha1, &type, &size); |
94 | if (!buf) { | 99 | if (!buf) { |
95 | cgit_print_error(fmt("Error reading object %s", | 100 | cgit_print_error(fmt("Error reading object %s", |
96 | sha1_to_hex(sha1))); | 101 | sha1_to_hex(sha1))); |
97 | return; | 102 | return; |
98 | } | 103 | } |
99 | 104 | ||
100 | html(" ("); | 105 | html(" ("); |
101 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, | 106 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, |
102 | curr_rev, path); | 107 | curr_rev, path); |