Skip to content

Commit

Permalink
gitweb: move highlight config out of guess_file_syntax()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alejandro R. Sedeño authored and Junio C Hamano committed Jul 28, 2010
1 parent 43e331e commit 61bf126
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,29 @@ sub evaluate_uri {
# Leave it undefined (or set to 'undef') to turn off load checking.
our $maxload = 300;

# configuration for 'highlight' (http://www.andre-simon.de/)
# match by basename
our %highlight_basename = (
#'Program' => 'py',
#'Library' => 'py',
'SConstruct' => 'py', # SCons equivalent of Makefile
'Makefile' => 'make',
);
# match by extension
our %highlight_ext = (
# main extensions, defining name of syntax;
# see files in /usr/share/highlight/langDefs/ directory
map { $_ => $_ }
qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
# alternate extensions, see /etc/highlight/filetypes.conf
'h' => 'c',
map { $_ => 'cpp' } qw(cxx c++ cc),
map { $_ => 'php' } qw(php3 php4),
map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
'mak' => 'make',
map { $_ => 'xml' } qw(xhtml html htm),
);

# You define site-wide feature defaults here; override them with
# $GITWEB_CONFIG as necessary.
our %feature = (
Expand Down Expand Up @@ -3316,30 +3339,6 @@ sub blob_contenttype {
sub guess_file_syntax {
my ($highlight, $mimetype, $file_name) = @_;
return undef unless ($highlight && defined $file_name);

# configuration for 'highlight' (http://www.andre-simon.de/)
# match by basename
my %highlight_basename = (
#'Program' => 'py',
#'Library' => 'py',
'SConstruct' => 'py', # SCons equivalent of Makefile
'Makefile' => 'make',
);
# match by extension
my %highlight_ext = (
# main extensions, defining name of syntax;
# see files in /usr/share/highlight/langDefs/ directory
map { $_ => $_ }
qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
# alternate extensions, see /etc/highlight/filetypes.conf
'h' => 'c',
map { $_ => 'cpp' } qw(cxx c++ cc),
map { $_ => 'php' } qw(php3 php4),
map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
'mak' => 'make',
map { $_ => 'xml' } qw(xhtml html htm),
);

my $basename = basename($file_name, '.in');
return $highlight_basename{$basename}
if exists $highlight_basename{$basename};
Expand Down

0 comments on commit 61bf126

Please sign in to comment.