gitweb: move highlight config out of guess_file_syntax()
Move highlight config out of guess_file_syntax() so that it can be extended/overridden by system/user configuration. Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alejandro R. Sedeño committed
Jul 28, 2010 at 14:40 UTC
61bf126ecb24977b883079942b71ff96174c19fb
1 file changed
+23
-24
gitweb/gitweb.perl
+23
-24
@@ -232,6 +232,29 @@ our %avatar_size = (
232
# Leave it undefined (or set to 'undef') to turn off load checking.
233
our $maxload = 300;
234
235
+# configuration for 'highlight' (http://www.andre-simon.de/)
236
+# match by basename
237
+our %highlight_basename = (
238
+ #'Program' => 'py',
239
+ #'Library' => 'py',
240
+ 'SConstruct' => 'py', # SCons equivalent of Makefile
241
+ 'Makefile' => 'make',
242
+);
243
+# match by extension
244
+our %highlight_ext = (
245
+ # main extensions, defining name of syntax;
246
+ # see files in /usr/share/highlight/langDefs/ directory
247
+ map { $_ => $_ }
248
+ qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
249
+ # alternate extensions, see /etc/highlight/filetypes.conf
250
+ 'h' => 'c',
251
+ map { $_ => 'cpp' } qw(cxx c++ cc),
252
+ map { $_ => 'php' } qw(php3 php4),
253
+ map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
254
+ 'mak' => 'make',
255
+ map { $_ => 'xml' } qw(xhtml html htm),
256
+);
257
+
258
# You define site-wide feature defaults here; override them with
259
# $GITWEB_CONFIG as necessary.
260
our %feature = (
@@ -3316,30 +3339,6 @@ sub blob_contenttype {
3339
sub guess_file_syntax {
3340
my ($highlight, $mimetype, $file_name) = @_;
3341
return undef unless ($highlight && defined $file_name);
3319
-
3320
- # configuration for 'highlight' (http://www.andre-simon.de/)
3321
- # match by basename
3322
- my %highlight_basename = (
3323
- #'Program' => 'py',
3324
- #'Library' => 'py',
3325
- 'SConstruct' => 'py', # SCons equivalent of Makefile
3326
- 'Makefile' => 'make',
3327
- );
3328
- # match by extension
3329
- my %highlight_ext = (
3330
- # main extensions, defining name of syntax;
3331
- # see files in /usr/share/highlight/langDefs/ directory
3332
- map { $_ => $_ }
3333
- qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
3334
- # alternate extensions, see /etc/highlight/filetypes.conf
3335
- 'h' => 'c',
3336
- map { $_ => 'cpp' } qw(cxx c++ cc),
3337
- map { $_ => 'php' } qw(php3 php4),
3338
- map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
3339
- 'mak' => 'make',
3340
- map { $_ => 'xml' } qw(xhtml html htm),
3341
- );
3342
-
3342
my $basename = basename($file_name, '.in');
3343
return $highlight_basename{$basename}
3344
if exists $highlight_basename{$basename};