@matheusbsbs / matheus-bagliano / commits / 06a9d86b49
Fork 0

gitweb: provide function to format the URL for an action link.

Provide a new function which can be used to generate an URL for the CGI. This makes it possible to consolidate the URL generation in order to make it easier to change the encoding of actions into URLs. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Martin Waitz committed Aug 16, 2006 at 00:23 UTC 06a9d86b49b826562e2b12b5c7e831e20b8f7dce
1 file changed +27
gitweb/gitweb.perl
+27
@@ -184,6 +184,33 @@ if (!defined($actions{$action})) {
184 $actions{$action}->();
185 exit;
186
187 +## ======================================================================
188 +## action links
189 +
190 +sub href(%) {
191 + my %mapping = (
192 + action => "a",
193 + project => "p",
194 + file_name => "f",
195 + hash => "h",
196 + hash_parent => "hp",
197 + hash_base => "hb",
198 + page => "pg",
199 + searchtext => "s",
200 + );
201 +
202 + my %params = @_;
203 + $params{"project"} ||= $project;
204 +
205 + my $href = "$my_uri?";
206 + $href .= esc_param( join(";",
207 + map { "$mapping{$_}=$params{$_}" } keys %params
208 + ) );
209 +
210 + return $href;
211 +}
212 +
213 +
214 ## ======================================================================
215 ## validation, quoting/unquoting and escaping
216