* [PATCH 0/3] gitweb: Simplify some gitweb URLs generation
@ 2007-11-01 12:06 Jakub Narebski
2007-11-01 12:06 ` Jakub Narebski
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-01 12:06 UTC (permalink / raw)
To: git
This series of patches simplifies some gitweb URLs generation by
providing -replay option to href() subroutine, and then using this
feature in gitweb code.
Shortlog:
gitweb: Easier adding/changing parameters to current URL
gitweb: Use href(-replay=>1, page=>...) to generate pagination links
gitweb: Use href(-replay=>1, action=>...) to generate alternate views
Diffstat:
gitweb/gitweb.perl | 82 ++++++++++++++++++++++-----------------------------
1 files changed, 35 insertions(+), 47 deletions(-)
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/3] gitweb: Simplify some gitweb URLs generation
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
@ 2007-11-01 12:06 ` Jakub Narebski
2007-11-01 12:06 ` [PATCH 1/3] gitweb: Easier adding/changing parameters to current URL Jakub Narebski
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-01 12:06 UTC (permalink / raw)
To: git
gitweb/gitweb.perl | 82 ++++++++++++++++++++++-----------------------------
1 files changed, 35 insertions(+), 47 deletions(-)
gitweb/gitweb.perl | 82 ++++++++++++++++++++++-----------------------------
1 files changed, 35 insertions(+), 47 deletions(-)
[PATCH 1/3] gitweb: Easier adding/changing parameters to current URL
[PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links
[PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] gitweb: Easier adding/changing parameters to current URL
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
2007-11-01 12:06 ` Jakub Narebski
@ 2007-11-01 12:06 ` Jakub Narebski
2007-11-01 12:06 ` [PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links Jakub Narebski
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-01 12:06 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
Add boolean option '-replay' to href() subroutine, which is used to
generate links in gitweb. This option "replays" current URL,
overriding it with provided parameters. It means that current value
of each CGI parameter is used unless otherwise provided.
This change is meant to make it easier to generate links which differ
from current page URL only by one parameter, for example the same view
but sorted by different column:
href(-replay=>1, order=>"age")
or view which differs by some option, e.g. in log views
href(-replay=>1, extra_options=>"--no-merges")
or alternate view of the same object, e.g. in the 'blob' view
href(-replay=>1, action=>"blob_plain")
Actual use of this functionality is left for later.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e36dec1..eaab895 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -611,6 +611,15 @@ sub href(%) {
);
my %mapping = @mapping;
+ if ($params{-replay}) {
+ while (my ($name, $symbol) = each %mapping) {
+ if (!exists $params{$name}) {
+ # to allow for multivalued params we use arrayref form
+ $params{$name} = [ $cgi->param($symbol) ];
+ }
+ }
+ }
+
$params{'project'} = $project unless exists $params{'project'};
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
--
1.5.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
2007-11-01 12:06 ` Jakub Narebski
2007-11-01 12:06 ` [PATCH 1/3] gitweb: Easier adding/changing parameters to current URL Jakub Narebski
@ 2007-11-01 12:06 ` Jakub Narebski
2007-11-01 12:06 ` [PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views Jakub Narebski
2007-11-01 22:47 ` [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Junio C Hamano
4 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-01 12:06 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
Use href(-replay=>1, page=>$page-1) and href(-replay=>1, page=>$page+1)
to generate previous page and next page links.
Generate next page link only once.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 44 +++++++++++++++-----------------------------
1 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index eaab895..20d4009 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2518,7 +2518,7 @@ sub format_paging_nav {
if ($page > 0) {
$paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page-1),
+ $cgi->a({-href => href(-replay=>1, page=>$page-1),
-accesskey => "p", -title => "Alt-p"}, "prev");
} else {
$paging_nav .= " ⋅ prev";
@@ -2526,7 +2526,7 @@ sub format_paging_nav {
if ($nrevs >= (100 * ($page+1)-1)) {
$paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>$action, hash=>$hash, page=>$page+1),
+ $cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
} else {
$paging_nav .= " ⋅ next";
@@ -4448,7 +4448,7 @@ sub git_log {
}
if ($#commitlist >= 100) {
print "<div class=\"page_nav\">\n";
- print $cgi->a({-href => href(action=>"log", hash=>$hash, page=>$page+1),
+ print $cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
print "</div>\n";
}
@@ -5015,27 +5015,20 @@ sub git_history {
file_name=>$file_name)},
"first");
$paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
- file_name=>$file_name, page=>$page-1),
+ $cgi->a({-href => href(-replay=>1, page=>$page-1),
-accesskey => "p", -title => "Alt-p"}, "prev");
} else {
$paging_nav .= "first";
$paging_nav .= " ⋅ prev";
}
- if ($#commitlist >= 100) {
- $paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
- file_name=>$file_name, page=>$page+1),
- -accesskey => "n", -title => "Alt-n"}, "next");
- } else {
- $paging_nav .= " ⋅ next";
- }
my $next_link = '';
if ($#commitlist >= 100) {
$next_link =
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
- file_name=>$file_name, page=>$page+1),
+ $cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
+ $paging_nav .= " ⋅ $next_link";
+ } else {
+ $paging_nav .= " ⋅ next";
}
git_header_html();
@@ -5105,30 +5098,23 @@ sub git_search {
searchtext=>$searchtext, searchtype=>$searchtype)},
"first");
$paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page-1),
+ $cgi->a({-href => href(-replay=>1, page=>$page-1),
-accesskey => "p", -title => "Alt-p"}, "prev");
} else {
$paging_nav .= "first";
$paging_nav .= " ⋅ prev";
}
+ my $next_link = '';
if ($#commitlist >= 100) {
- $paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page+1),
+ $next_link =
+ $cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
+ $paging_nav .= " ⋅ $next_link";
} else {
$paging_nav .= " ⋅ next";
}
- my $next_link = '';
+
if ($#commitlist >= 100) {
- $next_link =
- $cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype,
- page=>$page+1),
- -accesskey => "n", -title => "Alt-n"}, "next");
}
git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);
@@ -5327,7 +5313,7 @@ sub git_shortlog {
my $next_link = '';
if ($#commitlist >= 100) {
$next_link =
- $cgi->a({-href => href(action=>"shortlog", hash=>$hash, page=>$page+1),
+ $cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
` (2 preceding siblings ...)
2007-11-01 12:06 ` [PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links Jakub Narebski
@ 2007-11-01 12:06 ` Jakub Narebski
2007-11-01 22:47 ` [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Junio C Hamano
4 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-01 12:06 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
Use href(action=>..., -replay=>1) to generate links to alternate views
of current page in the $formats_nav (bottom) part of page_nav
navigation bar. This form is used only when all parameters are
repeated, and when the replay form is shorter.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 20d4009..827f977 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3911,11 +3911,11 @@ sub git_blame2 {
or die_error(undef, "Open git-blame failed");
git_header_html();
my $formats_nav =
- $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
+ $cgi->a({-href => href(action=>"blob", -replay=>1)},
"blob") .
" | " .
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
- "history") .
+ $cgi->a({-href => href(action=>"history", -replay=>1)},
+ "history") .
" | " .
$cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
"HEAD");
@@ -4191,18 +4191,15 @@ sub git_blob {
if (defined $file_name) {
if ($have_blame) {
$formats_nav .=
- $cgi->a({-href => href(action=>"blame", hash_base=>$hash_base,
- hash=>$hash, file_name=>$file_name)},
+ $cgi->a({-href => href(action=>"blame", -replay=>1)},
"blame") .
" | ";
}
$formats_nav .=
- $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
- hash=>$hash, file_name=>$file_name)},
+ $cgi->a({-href => href(action=>"history", -replay=>1)},
"history") .
" | " .
- $cgi->a({-href => href(action=>"blob_plain",
- hash=>$hash, file_name=>$file_name)},
+ $cgi->a({-href => href(action=>"blob_plain", -replay=>1)},
"raw") .
" | " .
$cgi->a({-href => href(action=>"blob",
@@ -4210,7 +4207,8 @@ sub git_blob {
"HEAD");
} else {
$formats_nav .=
- $cgi->a({-href => href(action=>"blob_plain", hash=>$hash)}, "raw");
+ $cgi->a({-href => href(action=>"blob_plain", -replay=>1)},
+ "raw");
}
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
@@ -4273,8 +4271,7 @@ sub git_tree {
my @views_nav = ();
if (defined $file_name) {
push @views_nav,
- $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
- hash=>$hash, file_name=>$file_name)},
+ $cgi->a({-href => href(action=>"history", -replay=>1)},
"history"),
$cgi->a({-href => href(action=>"tree",
hash_base=>"HEAD", file_name=>$file_name)},
@@ -4742,10 +4739,7 @@ sub git_blobdiff {
# header
if ($format eq 'html') {
my $formats_nav =
- $cgi->a({-href => href(action=>"blobdiff_plain",
- hash=>$hash, hash_parent=>$hash_parent,
- hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
- file_name=>$file_name, file_parent=>$file_parent)},
+ $cgi->a({-href => href(action=>"blobdiff_plain", -replay=>1)},
"raw");
git_header_html(undef, $expires);
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
@@ -4819,8 +4813,7 @@ sub git_commitdiff {
my $formats_nav;
if ($format eq 'html') {
$formats_nav =
- $cgi->a({-href => href(action=>"commitdiff_plain",
- hash=>$hash, hash_parent=>$hash_parent)},
+ $cgi->a({-href => href(action=>"commitdiff_plain", -replay=>1)},
"raw");
if (defined $hash_parent &&
--
1.5.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] gitweb: Simplify some gitweb URLs generation
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
` (3 preceding siblings ...)
2007-11-01 12:06 ` [PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views Jakub Narebski
@ 2007-11-01 22:47 ` Junio C Hamano
2007-11-02 0:18 ` Jakub Narebski
4 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2007-11-01 22:47 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Jakub Narebski <jnareb@gmail.com> writes:
> This series of patches simplifies some gitweb URLs generation by
> providing -replay option to href() subroutine, and then using this
> feature in gitweb code.
>
> Shortlog:
> gitweb: Easier adding/changing parameters to current URL
> gitweb: Use href(-replay=>1, page=>...) to generate pagination links
> gitweb: Use href(-replay=>1, action=>...) to generate alternate views
>
> Diffstat:
> gitweb/gitweb.perl | 82 ++++++++++++++++++++++-----------------------------
> 1 files changed, 35 insertions(+), 47 deletions(-)
If this "-replay" is used carelessly, it could add parameters
that were passed to the page that the original code stripped
away from passing on purpose. Have you checked if the
conversion done with 2/3 and 3/3 are correct (I haven't)?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] gitweb: Simplify some gitweb URLs generation
2007-11-01 22:47 ` [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Junio C Hamano
@ 2007-11-02 0:18 ` Jakub Narebski
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Narebski @ 2007-11-02 0:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> This series of patches simplifies some gitweb URLs generation by
>> providing -replay option to href() subroutine, and then using this
>> feature in gitweb code.
>>
>> Shortlog:
>> gitweb: Easier adding/changing parameters to current URL
>> gitweb: Use href(-replay=>1, page=>...) to generate pagination links
>> gitweb: Use href(-replay=>1, action=>...) to generate alternate views
>>
>> Diffstat:
>> gitweb/gitweb.perl | 82 ++++++++++++++++++++++-----------------------------
>> 1 files changed, 35 insertions(+), 47 deletions(-)
>
> If this "-replay" is used carelessly, it could add parameters
> that were passed to the page that the original code stripped
> away from passing on purpose. Have you checked if the
> conversion done with 2/3 and 3/3 are correct (I haven't)?
First, I guess that I should have marked this series of patches as
an RFC, but not for the reason you mentioned. This series changes
somewhat gitweb behaviour (patches 2/3 and 3/3 to be more exact) in
a way that before gitweb passed 'expanded' hashes to page / alternate
view links. For example before this series link to second page for
shortlog view starting from 'HEAD' passed literal sha1 for 'h' parameter,
ans second page started where first page ended. After this patch, if
refs have changed between viewing first page and clicking on the link
to second page, the resulting view would be second page of _new_ 'HEAD',
not of old (shown) 'HEAD'.
Second, you do not need to worry about adding parameters, because in 2/3
and 3/3 -replay is used to change view to the one which differs from
current by one parameter. Please take into account that some parameters
are just not important.
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-11-02 0:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-01 12:06 [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Jakub Narebski
2007-11-01 12:06 ` Jakub Narebski
2007-11-01 12:06 ` [PATCH 1/3] gitweb: Easier adding/changing parameters to current URL Jakub Narebski
2007-11-01 12:06 ` [PATCH 2/3] gitweb: Use href(-replay=>1, page=>...) to generate pagination links Jakub Narebski
2007-11-01 12:06 ` [PATCH 3/3] gitweb: Use href(-replay=>1, action=>...) to generate alternate views Jakub Narebski
2007-11-01 22:47 ` [PATCH 0/3] gitweb: Simplify some gitweb URLs generation Junio C Hamano
2007-11-02 0:18 ` Jakub Narebski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).