aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-11-12 22:27:53 -0800
committerJunio C Hamano <gitster@pobox.com>2008-11-12 22:27:53 -0800
commit168d5bd57b8183f8da0ea30a0d4d3c2422eec4e4 (patch)
treedd86f73c1a1a92a67e48a9977b1a01c14318d070
parentac538e5dbaf13180b7e7a9c4471f1007b8b11d68 (diff)
parent2b11e059ee55ae7fb9913acf84fcc065e3e33287 (diff)
downloadgit-168d5bd57b8183f8da0ea30a0d4d3c2422eec4e4.tar.gz
git-168d5bd57b8183f8da0ea30a0d4d3c2422eec4e4.tar.xz
Merge branch 'jn/gitweb-customlinks'
* jn/gitweb-customlinks: gitweb: Better processing format string in custom links in navbar
-rwxr-xr-xgitweb/gitweb.perl19
1 files changed, 12 insertions, 7 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d4c500b3b..933e13738 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -297,10 +297,10 @@ our %feature = (
# The 'default' value consists of a list of triplets in the form
# (label, link, position) where position is the label after which
- # to inster the link and link is a format string where %n expands
+ # to insert the link and link is a format string where %n expands
# to the project name, %f to the project path within the filesystem,
# %h to the current hash (h gitweb parameter) and %b to the current
- # hash base (hb gitweb parameter).
+ # hash base (hb gitweb parameter); %% expands to %.
# To enable system wide have in $GITWEB_CONFIG e.g.
# $feature{'actions'}{'default'} = [('graphiclog',
@@ -3085,14 +3085,19 @@ sub git_print_page_nav {
$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
my @actions = gitweb_check_feature('actions');
+ my %repl = (
+ '%' => '%',
+ 'n' => $project, # project name
+ 'f' => $git_dir, # project path within filesystem
+ 'h' => $treehead || '', # current hash ('h' parameter)
+ 'b' => $treebase || '', # hash base ('hb' parameter)
+ );
while (@actions) {
- my ($label, $link, $pos) = (shift(@actions), shift(@actions), shift(@actions));
+ my ($label, $link, $pos) = splice(@actions,0,3);
+ # insert
@navs = map { $_ eq $pos ? ($_, $label) : $_ } @navs;
# munch munch
- $link =~ s#%n#$project#g;
- $link =~ s#%f#$git_dir#g;
- $treehead ? $link =~ s#%h#$treehead#g : $link =~ s#%h##g;
- $treebase ? $link =~ s#%b#$treebase#g : $link =~ s#%b##g;
+ $link =~ s/%([%nfhb])/$repl{$1}/g;
$arg{$label}{'_href'} = $link;
}