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

[RFC PATCHv3 01/10] gitweb: href(..., -path_info => 0|1)

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 16, 2010, 19:36 UTC
Message-ID
<1266349005-15393-2-git-send-email-jnareb@gmail.com>
In-Reply-To
<1266349005-15393-1-git-send-email-jnareb@gmail.com>

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>
---
There is no change in the patch with v3, as compared to v2.

Note that in the caching patch by J.H. from "Gitweb caching v5" thread (and top commit in git://git.kernel.org/pub/scm/git/warthog9/gitweb.git, gitweb-ml-v5 branch) the key was generated as "$my_url?".$ENV{'QUERY_STRING'} which wouldn't work with path_info URLs, but on the other hand gitweb at git.kernel.org doesn't use path_info URLs (perhaps even doesn't support them).

Using href(replay=>1,full=>1,path_info=>0) has additional advantage over using $cgi->self_url() in that it also does not depend on ordering of parameters in handcrafted URLs.

 gitweb/gitweb.perl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1f6978a..97ea3ec 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -970,6 +970,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
@@ -986,7 +990,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
-- 
1.6.6.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 16 in “[RFC PATCHv3 00/10] gitweb: Simple file based output caching”
  1. Jakub NarebskiFeb 16, 2010
  2. 01/10 gitweb: href(..., -path_info => 0|1)Jakub Narebski, Feb 16, 2010
  3. 02/10 gitweb/cache.pm - Very simple file based cacheJakub Narebski, Feb 16, 2010
  4. 03/10 gitweb/cache.pm - Stat-based cache expirationJakub Narebski, Feb 16, 2010
  5. 04/10 gitweb: Use Cache::Cache compatibile (get, set) output cachingJakub Narebski, Feb 16, 2010
  6. 05/10 gitweb/cache.pm - Adaptive cache expiration timeJakub Narebski, Feb 16, 2010
  7. 06/10 gitweb: Use CHI compatibile (compute method) cachingJakub Narebski, Feb 16, 2010
  8. 07/10 gitweb/cache.pm - Use locking to avoid 'cache miss stampede' problemJakub Narebski, Feb 16, 2010
  9. 08/10 gitweb/cache.pm - Serve stale data when waiting for filling cacheJakub Narebski, Feb 16, 2010
  10. 09/10 gitweb/cache.pm - Regenerate (refresh) cache in backgroundJakub Narebski, Feb 16, 2010
  11. 10/10 gitweb: Show appropriate "Generating..." page when regenerating cacheJakub Narebski, Feb 16, 2010
  12. J.H.Feb 18, 2010
  13. Jakub NarebskiFeb 19, 2010
  14. gitweb: Simple file based output caching TODO (was: Re: [RFC PATCHv3 00/10] gitweb: Simple file based output caching)Jakub Narebski, Feb 28, 2010
  15. Jakub NarebskiFeb 28, 2010
  16. Petr BaudisFeb 28, 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.