{"thread":{"id":"5293","subject":"[PATCH] gitweb: consolidate action URL generation.","startedAt":"2006-08-15T22:24:30Z","lastAt":"2006-08-16T06:40:55Z","messageCount":2,"participants":["Martin Waitz","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25390","messageId":"20060815222429.GD14459@admingilde.org","threadId":"5293","inReplyTo":null,"subject":"[PATCH] gitweb: consolidate action URL generation.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-15T22:24:30Z","receivedAt":"2006-08-15T22:24:30Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"Use the href() function instead of string concatenation to generate\nmost URLs to our own CGI.\nThis is a work in progress, not everything has been converted yet.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |  171 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 84 insertions(+), 87 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 726dd66..3d171ae 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -384,7 +384,7 @@ sub format_log_line_html {\n \tif ($line =~ m/([0-9a-fA-F]{40})/) {\n \t\tmy $hash_text = $1;\n \t\tif (git_get_type($hash_text) eq \"commit\") {\n-\t\t\tmy $link = $cgi->a({-class => \"text\", -href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$hash_text\")}, $hash_text);\n+\t\t\tmy $link = $cgi->a({-class => \"text\", -href => href(action=>\"commit\", hash=>$hash_text)}, $hash_text);\n \t\t\t$line =~ s/$hash_text/$link/;\n \t\t}\n \t}\n@@ -421,16 +421,15 @@ sub format_ref_marker {\n \n # format, perhaps shortened and with markers, title line\n sub format_subject_html {\n-\tmy ($long, $short, $query, $extra) = @_;\n+\tmy ($long, $short, $href, $extra) = @_;\n \t$extra = '' unless defined($extra);\n \n \tif (length($short) < length($long)) {\n-\t\treturn $cgi->a({-href => \"$my_uri?\" . esc_param($query),\n-\t\t               -class => \"list\", -title => $long},\n+\t\treturn $cgi->a({-href => $href, -class => \"list\",\n+\t\t                -title => $long},\n \t\t       esc_html($short) . $extra);\n \t} else {\n-\t\treturn $cgi->a({-href => \"$my_uri?\" . esc_param($query),\n-\t\t               -class => \"list\"},\n+\t\treturn $cgi->a({-href => $href, -class => \"list\"},\n \t\t       esc_html($long)  . $extra);\n \t}\n }\n@@ -994,8 +993,7 @@ EOF\n \tif (defined $project) {\n \t\tprintf('<link rel=\"alternate\" title=\"%s log\" '.\n \t\t       'href=\"%s\" type=\"application/rss+xml\"/>'.\"\\n\",\n-\t\t       esc_param($project),\n-\t\t       esc_param(\"$my_uri?p=$project;a=rss\"));\n+\t\t       esc_param($project), href(action=>\"rss\"));\n \t}\n \n \tprint \"</head>\\n\" .\n@@ -1006,7 +1004,7 @@ EOF\n \t      \"</a>\\n\";\n \tprint $cgi->a({-href => esc_param($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=summary\")}, esc_html($project));\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n \t\tif (defined $action) {\n \t\t\tprint \" / $action\";\n \t\t}\n@@ -1043,7 +1041,7 @@ sub git_footer_html {\n \t\tif (defined $descr) {\n \t\t\tprint \"<div class=\\\"page_footer_text\\\">\" . esc_html($descr) . \"</div>\\n\";\n \t\t}\n-\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=rss\"), -class => \"rss_logo\"}, \"RSS\") . \"\\n\";\n+\t\tprint $cgi->a({-href => href(action=>\"rss\"), -class => \"rss_logo\"}, \"RSS\") . \"\\n\";\n \t} else {\n \t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"a=opml\"), -class => \"rss_logo\"}, \"OPML\") . \"\\n\";\n \t}\n@@ -1078,27 +1076,25 @@ sub git_print_page_nav {\n \t\t@navs = grep { $_ ne $suppress } @navs;\n \t}\n \n-\tmy %arg = map { $_, ''} @navs;\n+\tmy %arg = map { $_ => {action=>$_} } @navs;\n \tif (defined $head) {\n \t\tfor (qw(commit commitdiff)) {\n-\t\t\t$arg{$_} = \";h=$head\";\n+\t\t\t$arg{$_}{hash} = $head;\n \t\t}\n \t\tif ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {\n \t\t\tfor (qw(shortlog log)) {\n-\t\t\t\t$arg{$_} = \";h=$head\";\n+\t\t\t\t$arg{$_}{hash} = $head;\n \t\t\t}\n \t\t}\n \t}\n-\t$arg{tree} .= \";h=$treehead\" if defined $treehead;\n-\t$arg{tree} .= \";hb=$treebase\" if defined $treebase;\n+\t$arg{tree}{hash} = $treehead if defined $treehead;\n+\t$arg{tree}{hash_base} = $treebase if defined $treebase;\n \n \tprint \"<div class=\\\"page_nav\\\">\\n\" .\n \t\t(join \" | \",\n-\t\t map { $_ eq $current\n-\t\t\t\t\t ? $_\n-\t\t\t\t\t : $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$_$arg{$_}\")}, \"$_\")\n-\t\t\t\t }\n-\t\t @navs);\n+\t\t map { $_ eq $current ?\n+\t\t       $_ : $cgi->a({-href => href(%{$arg{$_}})}, \"$_\")\n+\t\t } @navs);\n \tprint \"<br/>\\n$extra<br/>\\n\" .\n \t      \"</div>\\n\";\n }\n@@ -1109,14 +1105,14 @@ sub format_paging_nav {\n \n \n \tif ($hash ne $head || $page) {\n-\t\t$paging_nav .= $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$action\")}, \"HEAD\");\n+\t\t$paging_nav .= $cgi->a({-href => href(action=>$action)}, \"HEAD\");\n \t} else {\n \t\t$paging_nav .= \"HEAD\";\n \t}\n \n \tif ($page > 0) {\n \t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$action;h=$hash;pg=\" . ($page-1)),\n+\t\t\t$cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page-1),\n \t\t\t         -accesskey => \"p\", -title => \"Alt-p\"}, \"prev\");\n \t} else {\n \t\t$paging_nav .= \" &sdot; prev\";\n@@ -1124,7 +1120,7 @@ sub format_paging_nav {\n \n \tif ($nrevs >= (100 * ($page+1)-1)) {\n \t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$action;h=$hash;pg=\" . ($page+1)),\n+\t\t\t$cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page+1),\n \t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t} else {\n \t\t$paging_nav .= \" &sdot; next\";\n@@ -1138,15 +1134,16 @@ ## functions printing or outputting HTML\n \n sub git_print_header_div {\n \tmy ($action, $title, $hash, $hash_base) = @_;\n-\tmy $rest = '';\n+\tmy %args = ();\n \n-\t$rest .= \";h=$hash\" if $hash;\n-\t$rest .= \";hb=$hash_base\" if $hash_base;\n+\t$args{action} = $action;\n+\t$args{hash} = $hash if $hash;\n+\t$args{hash_base} = $hash_base if $hash_base;\n \n \tprint \"<div class=\\\"header\\\">\\n\" .\n-\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$action$rest\"),\n-\t               -class => \"title\"}, $title ? $title : $action) . \"\\n\" .\n-\t      \"</div>\\n\";\n+\t      $cgi->a({-href => href(%args), -class => \"title\"},\n+\t      $title ? $title : $action) .\n+\t      \"\\n</div>\\n\";\n }\n \n sub git_print_page_path {\n@@ -1157,7 +1154,7 @@ sub git_print_page_path {\n \t\tprint \"<div class=\\\"page_path\\\"><b>/</b></div>\\n\";\n \t} elsif (defined $type && $type eq 'blob') {\n \t\tprint \"<div class=\\\"page_path\\\"><b>\" .\n-\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;f=$file_name\")}, esc_html($name)) . \"</b><br/></div>\\n\";\n+\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name)}, esc_html($name)) . \"</b><br/></div>\\n\";\n \t} else {\n \t\tprint \"<div class=\\\"page_path\\\"><b>\" . esc_html($name) . \"</b><br/></div>\\n\";\n \t}\n@@ -1204,22 +1201,22 @@ sub git_difftree_body {\n \t\t\t\t$mode_chng = sprintf(\" with mode: %04o\", (oct $to_mode) & 0777);\n \t\t\t}\n \t\t\tprint \"<td>\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file),\n \t\t\t              -class => \"list\"}, esc_html($file)) .\n \t\t\t      \"</td>\\n\" .\n \t\t\t      \"<td><span class=\\\"file_status new\\\">[new \" . file_type($to_mode) . \"$mode_chng]</span></td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\")}, \"blob\") .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, \"blob\") .\n \t\t\t      \"</td>\\n\";\n \n \t\t} elsif ($status eq \"D\") { # deleted\n \t\t\tprint \"<td>\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$parent;f=$file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$parent, file_name=>$file),\n \t\t\t               -class => \"list\"}, esc_html($file)) . \"</td>\\n\" .\n \t\t\t      \"<td><span class=\\\"file_status deleted\\\">[deleted \" . file_type($from_mode). \"]</span></td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$parent;f=$file\")}, \"blob\") . \" | \" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=history;hb=$parent;f=$file\")}, \"history\") .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$parent, file_name=>$file)}, \"blob\") . \" | \" .\n+\t\t\t      $cgi->a({-href => href(action=>\"history\", hash_base=>$parent, file_name=>$file)}, \"history\") .\n \t\t\t      \"</td>\\n\"\n \n \t\t} elsif ($status eq \"M\" || $status eq \"T\") { # modified, or type changed\n@@ -1240,20 +1237,20 @@ sub git_difftree_body {\n \t\t\t}\n \t\t\tprint \"<td>\";\n \t\t\tif ($to_id ne $from_id) { # modified\n-\t\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file\"),\n+\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file),\n \t\t\t\t              -class => \"list\"}, esc_html($file));\n \t\t\t} else { # mode changed\n-\t\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\"),\n+\t\t\t\tprint $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file),\n \t\t\t\t              -class => \"list\"}, esc_html($file));\n \t\t\t}\n \t\t\tprint \"</td>\\n\" .\n \t\t\t      \"<td>$mode_chnge</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\")}, \"blob\");\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) { # modified\n-\t\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file\")}, \"diff\");\n+\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, \"diff\");\n \t\t\t}\n-\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=history;hb=$hash;f=$file\")}, \"history\") . \"\\n\";\n+\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"history\", hash_base=>$hash, file_name=>$file)}, \"history\") . \"\\n\";\n \t\t\tprint \"</td>\\n\";\n \n \t\t} elsif ($status eq \"R\") { # renamed\n@@ -1263,14 +1260,14 @@ sub git_difftree_body {\n \t\t\t\t$mode_chng = sprintf(\", mode: %04o\", (oct $to_mode) & 0777);\n \t\t\t}\n \t\t\tprint \"<td>\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file),\n \t\t\t              -class => \"list\"}, esc_html($to_file)) . \"</td>\\n\" .\n \t\t\t      \"<td><span class=\\\"file_status moved\\\">[moved from \" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$parent;f=$from_file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$parent, file_name=>$from_file),\n \t\t\t              -class => \"list\"}, esc_html($from_file)) .\n \t\t\t      \" with \" . (int $similarity) . \"% similarity$mode_chng]</span></td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file\")}, \"blob\");\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) {\n \t\t\t\tprint \" | \" .\n \t\t\t\t      $cgi->a({-href => \"$my_uri?\" .\n@@ -1285,14 +1282,14 @@ sub git_difftree_body {\n \t\t\t\t$mode_chng = sprintf(\", mode: %04o\", (oct $to_mode) & 0777);\n \t\t\t}\n \t\t\tprint \"<td>\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file),\n \t\t\t              -class => \"list\"}, esc_html($to_file)) . \"</td>\\n\" .\n \t\t\t      \"<td><span class=\\\"file_status copied\\\">[copied from \" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$parent;f=$from_file\"),\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$parent, file_name=>$from_file),\n \t\t\t              -class => \"list\"}, esc_html($from_file)) .\n \t\t\t      \" with \" . (int $similarity) . \"% similarity$mode_chng]</span></td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file\")}, \"blob\");\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) {\n \t\t\t\tprint \" | \" .\n \t\t\t\t      $cgi->a({-href => \"$my_uri?\" .\n@@ -1328,11 +1325,11 @@ sub git_shortlog_body {\n \t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n \t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 10)) . \"</i></td>\\n\" .\n \t\t      \"<td>\";\n-\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, \"p=$project;a=commit;h=$commit\", $ref);\n+\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, href(action=>\"commit\", hash=>$commit), $ref);\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$commit\")}, \"commitdiff\") .\n+\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n@@ -1374,12 +1371,12 @@ sub git_history_body {\n \t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 3)) . \"</i></td>\\n\" .\n \t\t      \"<td>\";\n \t\t# originally git_history used chop_str($co{'title'}, 50)\n-\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, \"p=$project;a=commit;h=$commit\", $ref);\n+\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, href(action=>\"commit\", hash=>$commit), $ref);\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$commit\")}, \"commitdiff\") . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$ftype;hb=$commit;f=$file_name\")}, $ftype);\n+\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>$ftype, hash_base=>$commit, file_name=>$file_name)}, $ftype);\n \n \t\tif ($ftype eq 'blob') {\n \t\t\tmy $blob_current = git_get_hash_by_path($hash_base, $file_name);\n@@ -1387,7 +1384,7 @@ sub git_history_body {\n \t\t\tif (defined $blob_current && defined $blob_parent &&\n \t\t\t\t\t$blob_current ne $blob_parent) {\n \t\t\t\tprint \" | \" .\n-\t\t\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff;h=$blob_current;hp=$blob_parent;hb=$commit;f=$file_name\")},\n+\t\t\t\t\t$cgi->a({-href => href(action=>\"blobdiff\", hash=>$blob_current, hash_parent=>$blob_parent, hash_base=>$commit, file_name=>$file_name)},\n \t\t\t\t\t        \"diff to current\");\n \t\t\t}\n \t\t}\n@@ -1427,28 +1424,28 @@ sub git_tags_body {\n \t\t$alternate ^= 1;\n \t\tprint \"<td><i>$tag{'age'}</i></td>\\n\" .\n \t\t      \"<td>\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$tag{'reftype'};h=$tag{'refid'}\"),\n+\t\t      $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'}),\n \t\t               -class => \"list\"}, \"<b>\" . esc_html($tag{'name'}) . \"</b>\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"<td>\";\n \t\tif (defined $comment) {\n-\t\t\tprint format_subject_html($comment, $comment_short, \"p=$project;a=tag;h=$tag{'id'}\");\n+\t\t\tprint format_subject_html($comment, $comment_short, href(action=>\"tag\", hash=>$tag{'id'}));\n \t\t}\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"selflink\\\">\";\n \t\tif ($tag{'type'} eq \"tag\") {\n-\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tag;h=$tag{'id'}\")}, \"tag\");\n+\t\t\tprint $cgi->a({-href => href(action=>\"tag\", hash=>$tag{'id'})}, \"tag\");\n \t\t} else {\n \t\t\tprint \"&nbsp;\";\n \t\t}\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$tag{'reftype'};h=$tag{'refid'}\")}, $tag{'reftype'});\n+\t\t      $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});\n \t\tif ($tag{'reftype'} eq \"commit\") {\n-\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=shortlog;h=$tag{'name'}\")}, \"shortlog\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=log;h=$tag{'refid'}\")}, \"log\");\n+\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'name'})}, \"shortlog\") .\n+\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"log\", hash=>$tag{'refid'})}, \"log\");\n \t\t} elsif ($tag{'reftype'} eq \"blob\") {\n-\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$tag{'refid'}\")}, \"raw\");\n+\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blob_plain\", hash=>$tag{'refid'})}, \"raw\");\n \t\t}\n \t\tprint \"</td>\\n\" .\n \t\t      \"</tr>\";\n@@ -1481,12 +1478,12 @@ sub git_heads_body {\n \t\t$alternate ^= 1;\n \t\tprint \"<td><i>$tag{'age'}</i></td>\\n\" .\n \t\t      ($tag{'id'} eq $head ? \"<td class=\\\"current_head\\\">\" : \"<td>\") .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=shortlog;h=$tag{'name'}\"),\n+\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'name'}),\n \t\t               -class => \"list\"}, \"<b>\" . esc_html($tag{'name'}) . \"</b>\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=shortlog;h=$tag{'name'}\")}, \"shortlog\") . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=log;h=$tag{'name'}\")}, \"log\") .\n+\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'name'})}, \"shortlog\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"log\", hash=>$tag{'name'})}, \"log\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\";\n \t}\n@@ -1704,20 +1701,20 @@ sub git_summary {\n \tclose $fd;\n \tgit_print_header_div('shortlog');\n \tgit_shortlog_body(\\@revlist, 0, 15, $refs,\n-\t                  $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=shortlog\")}, \"...\"));\n+\t                  $cgi->a({-href => href(action=>\"shortlog\")}, \"...\"));\n \n \tmy $taglist = git_get_refs_list(\"refs/tags\");\n \tif (defined @$taglist) {\n \t\tgit_print_header_div('tags');\n \t\tgit_tags_body($taglist, 0, 15,\n-\t\t              $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tags\")}, \"...\"));\n+\t\t              $cgi->a({-href => href(action=>\"tags\")}, \"...\"));\n \t}\n \n \tmy $headlist = git_get_refs_list(\"refs/heads\");\n \tif (defined @$headlist) {\n \t\tgit_print_header_div('heads');\n \t\tgit_heads_body($headlist, $head, 0, 15,\n-\t\t               $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=heads\")}, \"...\"));\n+\t\t               $cgi->a({-href => href(action=>\"heads\")}, \"...\"));\n \t}\n \n \tgit_footer_html();\n@@ -1733,8 +1730,8 @@ sub git_tag {\n \t      \"<table cellspacing=\\\"0\\\">\\n\" .\n \t      \"<tr>\\n\" .\n \t      \"<td>object</td>\\n\" .\n-\t      \"<td>\" . $cgi->a({-class => \"list\", -href => \"$my_uri?\" . esc_param(\"p=$project;a=$tag{'type'};h=$tag{'object'}\")}, $tag{'object'}) . \"</td>\\n\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$tag{'type'};h=$tag{'object'}\")}, $tag{'type'}) . \"</td>\\n\" .\n+\t      \"<td>\" . $cgi->a({-class => \"list\", -href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'object'}) . \"</td>\\n\" .\n+\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'type'}) . \"</td>\\n\" .\n \t      \"</tr>\\n\";\n \tif (defined($tag{'author'})) {\n \t\tmy %ad = parse_date($tag{'epoch'}, $tag{'tz'});\n@@ -1773,8 +1770,8 @@ sub git_blame2 {\n \t\tor die_error(undef, \"Open git-blame failed\");\n \tgit_header_html();\n \tmy $formats_nav =\n-\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name\")}, \"blob\") .\n-\t\t\" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;f=$file_name\")}, \"head\");\n+\t\t$cgi->a({-href => href(action=>\"blobl\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blob\") .\n+\t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \tgit_print_page_path($file_name, $ftype);\n@@ -1800,7 +1797,7 @@ sub git_blame2 {\n \t\t}\n \t\tprint \"<tr class=\\\"$rev_color[$current_color]\\\">\\n\";\n \t\tprint \"<td class=\\\"sha1\\\">\" .\n-\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$full_rev;f=$file_name\")}, esc_html($rev)) . \"</td>\\n\";\n+\t\t\t$cgi->a({-href => href(action=>\"commit\", hash=>$full_rev, file_name=>$file_name)}, esc_html($rev)) . \"</td>\\n\";\n \t\tprint \"<td class=\\\"linenr\\\"><a id=\\\"l$lineno\\\" href=\\\"#l$lineno\\\" class=\\\"linenr\\\">\" . esc_html($lineno) . \"</a></td>\\n\";\n \t\tprint \"<td class=\\\"pre\\\">\" . esc_html($data) . \"</td>\\n\";\n \t\tprint \"</tr>\\n\";\n@@ -1827,8 +1824,8 @@ sub git_blame {\n \t\tor die_error(undef, \"Open git-annotate failed\");\n \tgit_header_html();\n \tmy $formats_nav =\n-\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name\")}, \"blob\") .\n-\t\t\" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;f=$file_name\")}, \"head\");\n+\t\t$cgi->a({-href => href(action=>\"blobl\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blob\") .\n+\t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \tgit_print_page_path($file_name, 'blob');\n@@ -1883,7 +1880,7 @@ HTML\n \n \t\tprint <<HTML;\n   <tr class=\"$line_class[$line_class_num]\">\n-    <td class=\"sha1\"><a href=\"$my_uri?${\\esc_param (\"p=$project;a=commit;h=$long_rev\")}\" class=\"text\">$short_rev..</a></td>\n+    <td class=\"sha1\"><a href=\"${\\href (action=>\"commit\", hash=>$long_rev)}\" class=\"text\">$short_rev..</a></td>\n     <td class=\"$age_class\">$age_str</td>\n     <td>$author</td>\n     <td class=\"linenr\"><a id=\"$lineno\" href=\"#$lineno\" class=\"linenr\">$lineno</a></td>\n@@ -1979,13 +1976,13 @@ sub git_blob {\n \tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n \t\tif (defined $file_name) {\n \t\t\tif ($have_blame) {\n-\t\t\t\t$formats_nav .= $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name\")}, \"blame\") . \" | \";\n+\t\t\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blame\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blame\") . \" | \";\n \t\t\t}\n \t\t\t$formats_nav .=\n-\t\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$hash;f=$file_name\")}, \"plain\") .\n-\t\t\t\t\" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;hb=HEAD;f=$file_name\")}, \"head\");\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash, file_name=>$file_name)}, \"plain\") .\n+\t\t\t\t\" | \" . $cgi->a({-href => href(action=>\"blob\", hash_base=>\"HEAD\", file_name=>$file_name)}, \"head\");\n \t\t} else {\n-\t\t\t$formats_nav .= $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$hash\")}, \"plain\");\n+\t\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash)}, \"plain\");\n \t\t}\n \t\tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n@@ -2129,8 +2126,8 @@ sub git_log {\n \t\t               $commit);\n \t\tprint \"<div class=\\\"title_text\\\">\\n\" .\n \t\t      \"<div class=\\\"log_link\\\">\\n\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") .\n-\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$commit\")}, \"commitdiff\") .\n+\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") .\n+\t\t      \" | \" . $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n \t\t      \"<br/>\\n\" .\n \t\t      \"</div>\\n\" .\n \t\t      \"<i>\" . esc_html($co{'author_name'}) .  \" [$ad{'rfc2822'}]</i><br/>\\n\" .\n@@ -2187,7 +2184,7 @@ sub git_commit {\n \tmy $formats_nav = '';\n \tif (defined $file_name && defined $co{'parent'}) {\n \t\tmy $parent = $co{'parent'};\n-\t\t$formats_nav .= $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;hb=$parent;f=$file_name\")}, \"blame\");\n+\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blame\", hash_parent=>$parent, file_name=>$file_name)}, \"blame\");\n \t}\n \tgit_header_html(undef, $expires);\n \tgit_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',\n@@ -2217,19 +2214,19 @@ sub git_commit {\n \tprint \"<tr>\" .\n \t      \"<td>tree</td>\" .\n \t      \"<td class=\\\"sha1\\\">\" .\n-\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\"), class => \"list\"}, $co{'tree'}) .\n+\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash), class => \"list\"}, $co{'tree'}) .\n \t      \"</td>\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$hash\")}, \"tree\") .\n+\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\") .\n \t      \"</td>\" .\n \t      \"</tr>\\n\";\n \tmy $parents = $co{'parents'};\n \tforeach my $par (@$parents) {\n \t\tprint \"<tr>\" .\n \t\t      \"<td>parent</td>\" .\n-\t\t      \"<td class=\\\"sha1\\\">\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$par\"), class => \"list\"}, $par) . \"</td>\" .\n+\t\t      \"<td class=\\\"sha1\\\">\" . $cgi->a({-href => href(action=>\"commit\", hash=>$par), class => \"list\"}, $par) . \"</td>\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$par\")}, \"commit\") .\n-\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$hash;hp=$par\")}, \"commitdiff\") .\n+\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$par)}, \"commit\") .\n+\t\t      \" | \" . $cgi->a({-href => href(action=>\"commitdiff\", hash=>$hash, hash_parent=>$par)}, \"commitdiff\") .\n \t\t      \"</td>\" .\n \t\t      \"</tr>\\n\";\n \t}\n-- \n1.4.2.rc2.gf055\n\n-- \nMartin Waitz\n"},{"id":"25402","messageId":"7vfyfx41zc.fsf@assigned-by-dhcp.cox.net","threadId":"5293","inReplyTo":"20060815222429.GD14459@admingilde.org","subject":"Re: [PATCH] gitweb: consolidate action URL generation.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-16T06:40:55Z","receivedAt":"2006-08-16T06:40:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Beautiful.\n"}]}