git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] gitweb: href(..., -path_info => 0|1)

From
Jakub Narebski <jnareb@gmail.com>
Date
Apr 24, 2010, 13:53 UTC
Message-ID
<20100424135024.30511.78790.stgit@localhost.localdomain>
In-Reply-To
<20100424132255.30511.98829.stgit@localhost.localdomain>

If named boolean option -path_info is passed to href() subroutine, it would use its value to decide whether to generate path_info URL form. If this option is not passed, href() queries 'pathinfo' feature to check whether to generate path_info URL (if generating path_info link is possible at all).

href(-replay=>1, -path_info=>0) is meant to be used to generate a key
for caching gitweb output; alternate solution would be to use freeze()
from Storable (core module) on %input_params hash (or its reference),
e.g.:
  $key = freeze \%input_params;
or other serialization of %input_params.
While at it document extra options/flags to href().
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The commit message explicitly mentions caching support, but in fast
this feature is just about having a way to request *canonical* URL
(canonical link).
 gitweb/gitweb.perl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c356e95..6cefb09 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -977,6 +977,10 @@ exit;
 ## ======================================================================
 ## action links
 
+# possible values of extra options
+# -full => 0|1      - use absolute/full URL ($my_uri/$my_url as base)
+# -replay => 1      - start from a current view (replay with modifications)
+# -path_info => 0|1 - don't use/use path_info URL (if possible)
 sub href {
 	my %params = @_;
 	# default is to use -absolute url() i.e. $my_uri
@@ -993,7 +997,8 @@ sub href {
 	}
 
 	my $use_pathinfo = gitweb_check_feature('pathinfo');
-	if ($use_pathinfo and defined $params{'project'}) {
+	if (defined $params{'project'} &&
+	    (exists $params{-path_info} ? $params{-path_info} : $use_pathinfo)) {
 		# try to put as many parameters as possible in PATH_INFO:
 		#   - project name
 		#   - action
Previous: Jakub NarebskiNext: Jakub Narebski
Message 4 of 10 in “gitweb: Miscellaneous improvements, in preparation for caching support”
  1. 0/5 gitweb: Miscellaneous improvements, in preparation for caching supportJakub Narebski, Apr 24, 2010
  2. 1/5 Export more test-related variables when running external testsJakub Narebski, Apr 24, 2010
  3. Jakub NarebskiApr 25, 2010
  4. 2/5 gitweb: href(..., -path_info => 0|1)Jakub Narebski, Apr 24, 2010
  5. 3/5 gitweb: Use nonlocal jump instead of 'exit' in die_errorJakub Narebski, Apr 24, 2010
  6. Jakub NarebskiMay 4, 2010
  7. 4/5 gitweb: Add custom error handler using die_errorJakub Narebski, Apr 24, 2010
  8. 5/5 gitweb: Move generating page title to separate subroutineJakub Narebski, Apr 24, 2010
  9. Petr BaudisApr 25, 2010
  10. Jakub NarebskiApr 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.