{"thread":{"id":"10556","subject":"[PATCH 0/3] gitweb: Simplify some gitweb URLs generation","startedAt":"2007-11-01T12:06:25Z","lastAt":"2007-11-02T00:18:43Z","messageCount":7,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"57804","messageId":"1193918789-16421-1-git-send-email-jnareb@gmail.com","threadId":"10556","inReplyTo":null,"subject":"[PATCH 0/3] gitweb: Simplify some gitweb URLs generation","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T12:06:25Z","receivedAt":"2007-11-01T12:06:25Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This series of patches simplifies some gitweb URLs generation by\nproviding -replay option to href() subroutine, and then using this\nfeature in gitweb code.\n\nShortlog:\n gitweb: Easier adding/changing parameters to current URL\n gitweb: Use href(-replay=>1, page=>...) to generate pagination links\n gitweb: Use href(-replay=>1, action=>...) to generate alternate views\n\nDiffstat:\n gitweb/gitweb.perl |   82 ++++++++++++++++++++++-----------------------------\n 1 files changed, 35 insertions(+), 47 deletions(-)\n\n-- \nJakub Narebski\nPoland\n"},{"id":"57806","messageId":"1193918789-16421-2-git-send-email-jnareb@gmail.com","threadId":"10556","inReplyTo":"1193918789-16421-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 0/3] gitweb: Simplify some gitweb URLs generation","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T12:06:26Z","receivedAt":"2007-11-01T12:06:26Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":" gitweb/gitweb.perl |   82 ++++++++++++++++++++++-----------------------------\n 1 files changed, 35 insertions(+), 47 deletions(-)\n gitweb/gitweb.perl |   82 ++++++++++++++++++++++-----------------------------\n 1 files changed, 35 insertions(+), 47 deletions(-)\n [PATCH 1/3] gitweb: Easier adding/changing parameters to current URL\n [PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links\n [PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views\n"},{"id":"57805","messageId":"1193918789-16421-3-git-send-email-jnareb@gmail.com","threadId":"10556","inReplyTo":"1193918789-16421-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 1/3] gitweb: Easier adding/changing parameters to current URL","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T12:06:27Z","receivedAt":"2007-11-01T12:06:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add boolean option '-replay' to href() subroutine, which is used to\ngenerate links in gitweb.  This option \"replays\" current URL,\noverriding it with provided parameters.  It means that current value\nof each CGI parameter is used unless otherwise provided.\n\nThis change is meant to make it easier to generate links which differ\nfrom current page URL only by one parameter, for example the same view\nbut sorted by different column:\n  href(-replay=>1, order=>\"age\")\nor view which differs by some option, e.g. in log views\n  href(-replay=>1, extra_options=>\"--no-merges\")\nor alternate view of the same object, e.g. in the 'blob' view\n  href(-replay=>1, action=>\"blob_plain\")\n\nActual use of this functionality is left for later.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex e36dec1..eaab895 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -611,6 +611,15 @@ sub href(%) {\n \t);\n \tmy %mapping = @mapping;\n \n+\tif ($params{-replay}) {\n+\t\twhile (my ($name, $symbol) = each %mapping) {\n+\t\t\tif (!exists $params{$name}) {\n+\t\t\t\t# to allow for multivalued params we use arrayref form\n+\t\t\t\t$params{$name} = [ $cgi->param($symbol) ];\n+\t\t\t}\n+\t\t}\n+\t}\n+\n \t$params{'project'} = $project unless exists $params{'project'};\n \n \tmy ($use_pathinfo) = gitweb_check_feature('pathinfo');\n-- \n1.5.3.4\n"},{"id":"57808","messageId":"1193918789-16421-4-git-send-email-jnareb@gmail.com","threadId":"10556","inReplyTo":"1193918789-16421-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T12:06:28Z","receivedAt":"2007-11-01T12:06:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Use href(-replay=>1, page=>$page-1) and href(-replay=>1, page=>$page+1)\nto generate previous page and next page links.\n\nGenerate next page link only once.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   44 +++++++++++++++-----------------------------\n 1 files changed, 15 insertions(+), 29 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex eaab895..20d4009 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2518,7 +2518,7 @@ sub format_paging_nav {\n \n \tif ($page > 0) {\n \t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t$cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page-1),\n+\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page-1),\n \t\t\t         -accesskey => \"p\", -title => \"Alt-p\"}, \"prev\");\n \t} else {\n \t\t$paging_nav .= \" &sdot; prev\";\n@@ -2526,7 +2526,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 => href(action=>$action, hash=>$hash, page=>$page+1),\n+\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page+1),\n \t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t} else {\n \t\t$paging_nav .= \" &sdot; next\";\n@@ -4448,7 +4448,7 @@ sub git_log {\n \t}\n \tif ($#commitlist >= 100) {\n \t\tprint \"<div class=\\\"page_nav\\\">\\n\";\n-\t\tprint $cgi->a({-href => href(action=>\"log\", hash=>$hash, page=>$page+1),\n+\t\tprint $cgi->a({-href => href(-replay=>1, page=>$page+1),\n \t\t\t       -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t\tprint \"</div>\\n\";\n \t}\n@@ -5015,27 +5015,20 @@ sub git_history {\n \t\t\t                       file_name=>$file_name)},\n \t\t\t        \"first\");\n \t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base,\n-\t\t\t                       file_name=>$file_name, page=>$page-1),\n+\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page-1),\n \t\t\t         -accesskey => \"p\", -title => \"Alt-p\"}, \"prev\");\n \t} else {\n \t\t$paging_nav .= \"first\";\n \t\t$paging_nav .= \" &sdot; prev\";\n \t}\n-\tif ($#commitlist >= 100) {\n-\t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base,\n-\t\t\t                       file_name=>$file_name, page=>$page+1),\n-\t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n-\t} else {\n-\t\t$paging_nav .= \" &sdot; next\";\n-\t}\n \tmy $next_link = '';\n \tif ($#commitlist >= 100) {\n \t\t$next_link =\n-\t\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base,\n-\t\t\t                       file_name=>$file_name, page=>$page+1),\n+\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page+1),\n \t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n+\t\t$paging_nav .= \" &sdot; $next_link\";\n+\t} else {\n+\t\t$paging_nav .= \" &sdot; next\";\n \t}\n \n \tgit_header_html();\n@@ -5105,30 +5098,23 @@ sub git_search {\n \t\t\t\t                       searchtext=>$searchtext, searchtype=>$searchtype)},\n \t\t\t\t        \"first\");\n \t\t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n-\t\t\t\t                       searchtext=>$searchtext, searchtype=>$searchtype,\n-\t\t\t\t                       page=>$page-1),\n+\t\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page-1),\n \t\t\t\t         -accesskey => \"p\", -title => \"Alt-p\"}, \"prev\");\n \t\t} else {\n \t\t\t$paging_nav .= \"first\";\n \t\t\t$paging_nav .= \" &sdot; prev\";\n \t\t}\n+\t\tmy $next_link = '';\n \t\tif ($#commitlist >= 100) {\n-\t\t\t$paging_nav .= \" &sdot; \" .\n-\t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n-\t\t\t\t                       searchtext=>$searchtext, searchtype=>$searchtype,\n-\t\t\t\t                       page=>$page+1),\n+\t\t\t$next_link =\n+\t\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page+1),\n \t\t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n+\t\t\t$paging_nav .= \" &sdot; $next_link\";\n \t\t} else {\n \t\t\t$paging_nav .= \" &sdot; next\";\n \t\t}\n-\t\tmy $next_link = '';\n+\n \t\tif ($#commitlist >= 100) {\n-\t\t\t$next_link =\n-\t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n-\t\t\t\t                       searchtext=>$searchtext, searchtype=>$searchtype,\n-\t\t\t\t                       page=>$page+1),\n-\t\t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t\t}\n \n \t\tgit_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);\n@@ -5327,7 +5313,7 @@ sub git_shortlog {\n \tmy $next_link = '';\n \tif ($#commitlist >= 100) {\n \t\t$next_link =\n-\t\t\t$cgi->a({-href => href(action=>\"shortlog\", hash=>$hash, page=>$page+1),\n+\t\t\t$cgi->a({-href => href(-replay=>1, page=>$page+1),\n \t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t}\n \n-- \n1.5.3.4\n"},{"id":"57807","messageId":"1193918789-16421-5-git-send-email-jnareb@gmail.com","threadId":"10556","inReplyTo":"1193918789-16421-1-git-send-email-jnareb@gmail.com","subject":"[PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T12:06:29Z","receivedAt":"2007-11-01T12:06:29Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Use href(action=>..., -replay=>1) to generate links to alternate views\nof current page in the $formats_nav (bottom) part of page_nav\nnavigation bar.  This form is used only when all parameters are\nrepeated, and when the replay form is shorter.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   29 +++++++++++------------------\n 1 files changed, 11 insertions(+), 18 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 20d4009..827f977 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3911,11 +3911,11 @@ 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 => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n+\t\t$cgi->a({-href => href(action=>\"blob\", -replay=>1)},\n \t\t        \"blob\") .\n \t\t\" | \" .\n-\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n-\t\t\t\"history\") .\n+\t\t$cgi->a({-href => href(action=>\"history\", -replay=>1)},\n+\t\t        \"history\") .\n \t\t\" | \" .\n \t\t$cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)},\n \t\t        \"HEAD\");\n@@ -4191,18 +4191,15 @@ sub git_blob {\n \t\tif (defined $file_name) {\n \t\t\tif ($have_blame) {\n \t\t\t\t$formats_nav .=\n-\t\t\t\t\t$cgi->a({-href => href(action=>\"blame\", hash_base=>$hash_base,\n-\t\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t\t$cgi->a({-href => href(action=>\"blame\", -replay=>1)},\n \t\t\t\t\t        \"blame\") .\n \t\t\t\t\t\" | \";\n \t\t\t}\n \t\t\t$formats_nav .=\n-\t\t\t\t$cgi->a({-href => href(action=>\"history\", hash_base=>$hash_base,\n-\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t$cgi->a({-href => href(action=>\"history\", -replay=>1)},\n \t\t\t\t        \"history\") .\n \t\t\t\t\" | \" .\n-\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\",\n-\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", -replay=>1)},\n \t\t\t\t        \"raw\") .\n \t\t\t\t\" | \" .\n \t\t\t\t$cgi->a({-href => href(action=>\"blob\",\n@@ -4210,7 +4207,8 @@ sub git_blob {\n \t\t\t\t        \"HEAD\");\n \t\t} else {\n \t\t\t$formats_nav .=\n-\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash)}, \"raw\");\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", -replay=>1)},\n+\t\t\t\t        \"raw\");\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@@ -4273,8 +4271,7 @@ sub git_tree {\n \t\tmy @views_nav = ();\n \t\tif (defined $file_name) {\n \t\t\tpush @views_nav,\n-\t\t\t\t$cgi->a({-href => href(action=>\"history\", hash_base=>$hash_base,\n-\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t$cgi->a({-href => href(action=>\"history\", -replay=>1)},\n \t\t\t\t        \"history\"),\n \t\t\t\t$cgi->a({-href => href(action=>\"tree\",\n \t\t\t\t                       hash_base=>\"HEAD\", file_name=>$file_name)},\n@@ -4742,10 +4739,7 @@ sub git_blobdiff {\n \t# header\n \tif ($format eq 'html') {\n \t\tmy $formats_nav =\n-\t\t\t$cgi->a({-href => href(action=>\"blobdiff_plain\",\n-\t\t\t                       hash=>$hash, hash_parent=>$hash_parent,\n-\t\t\t                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,\n-\t\t\t                       file_name=>$file_name, file_parent=>$file_parent)},\n+\t\t\t$cgi->a({-href => href(action=>\"blobdiff_plain\", -replay=>1)},\n \t\t\t        \"raw\");\n \t\tgit_header_html(undef, $expires);\n \t\tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n@@ -4819,8 +4813,7 @@ sub git_commitdiff {\n \tmy $formats_nav;\n \tif ($format eq 'html') {\n \t\t$formats_nav =\n-\t\t\t$cgi->a({-href => href(action=>\"commitdiff_plain\",\n-\t\t\t                       hash=>$hash, hash_parent=>$hash_parent)},\n+\t\t\t$cgi->a({-href => href(action=>\"commitdiff_plain\", -replay=>1)},\n \t\t\t        \"raw\");\n \n \t\tif (defined $hash_parent &&\n-- \n1.5.3.4\n"},{"id":"57894","messageId":"7v1wb98twi.fsf@gitster.siamese.dyndns.org","threadId":"10556","inReplyTo":"1193918789-16421-1-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH 0/3] gitweb: Simplify some gitweb URLs generation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-01T22:47:57Z","receivedAt":"2007-11-01T22:47:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> This series of patches simplifies some gitweb URLs generation by\n> providing -replay option to href() subroutine, and then using this\n> feature in gitweb code.\n>\n> Shortlog:\n>  gitweb: Easier adding/changing parameters to current URL\n>  gitweb: Use href(-replay=>1, page=>...) to generate pagination links\n>  gitweb: Use href(-replay=>1, action=>...) to generate alternate views\n>\n> Diffstat:\n>  gitweb/gitweb.perl |   82 ++++++++++++++++++++++-----------------------------\n>  1 files changed, 35 insertions(+), 47 deletions(-)\n\nIf this \"-replay\" is used carelessly, it could add parameters\nthat were passed to the page that the original code stripped\naway from passing on purpose.  Have you checked if the\nconversion done with 2/3 and 3/3 are correct (I haven't)?\n"},{"id":"57904","messageId":"200711020118.44015.jnareb@gmail.com","threadId":"10556","inReplyTo":"7v1wb98twi.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/3] gitweb: Simplify some gitweb URLs generation","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-02T00:18:43Z","receivedAt":"2007-11-02T00:18:43Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> This series of patches simplifies some gitweb URLs generation by\n>> providing -replay option to href() subroutine, and then using this\n>> feature in gitweb code.\n>>\n>> Shortlog:\n>>  gitweb: Easier adding/changing parameters to current URL\n>>  gitweb: Use href(-replay=>1, page=>...) to generate pagination links\n>>  gitweb: Use href(-replay=>1, action=>...) to generate alternate views\n>>\n>> Diffstat:\n>>  gitweb/gitweb.perl |   82 ++++++++++++++++++++++-----------------------------\n>>  1 files changed, 35 insertions(+), 47 deletions(-)\n> \n> If this \"-replay\" is used carelessly, it could add parameters\n> that were passed to the page that the original code stripped\n> away from passing on purpose.  Have you checked if the\n> conversion done with 2/3 and 3/3 are correct (I haven't)?\n\nFirst, I guess that I should have marked this series of patches as\nan RFC, but not for the reason you mentioned. This series changes\nsomewhat gitweb behaviour (patches 2/3 and 3/3 to be more exact) in\na way that before gitweb passed 'expanded' hashes to page / alternate\nview links. For example before this series link to second page for\nshortlog view starting from 'HEAD' passed literal sha1 for 'h' parameter,\nans second page started where first page ended. After this patch, if\nrefs have changed between viewing first page and clicking on the link\nto second page, the resulting view would be second page of _new_ 'HEAD',\nnot of old (shown) 'HEAD'.\n\nSecond, you do not need to worry about adding parameters, because in 2/3\nand 3/3 -replay is used to change view to the one which differs from\ncurrent by one parameter. Please take into account that some parameters\nare just not important.\n\n-- \nJakub Narebski\nPoland\n"}]}