* [PATCH 0/3] Add git_project_index, improve href()
@ 2006-09-15 2:53 Jakub Narebski
2006-09-15 2:56 ` [PATCH 1/3] gitweb: Add git_project_index for generating index.aux Jakub Narebski
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 2:53 UTC (permalink / raw)
To: git
This series of patches introduces "project_index" view, which is text/plain
equivalent of projects list view, again. This time it is accompanied by
the patch which adds links to this view.
"project_index" view has at least two uses: first, to automatically generate
gitweb project index file (which we then edit, e.g. removing some projects
from being visible from gitweb and correcting ownership information).
Second, to get list of projects for scripts, in very easily parseable form.
Even if patches 1 and 3 got discarded, patch 2 is I think worth applying.
It finishes consolidation of URL generation.
Shortlog:
[PATCH 1/3] gitweb: Add git_project_index for generating index.aux
[PATCH 2/3] gitweb: Allow for href() to be used for projectless links
[PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page
Diffstat:
gitweb/gitweb.perl | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 44 insertions(+), 7 deletions(-)
P.S. Should shortlog be before, or after diffstat (if it matters)?
--
Jakub Narebski
ShadeHawk on #git
Poland
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] gitweb: Add git_project_index for generating index.aux
2006-09-15 2:53 [PATCH 0/3] Add git_project_index, improve href() Jakub Narebski
@ 2006-09-15 2:56 ` Jakub Narebski
2006-09-15 2:57 ` [PATCH 2/3] gitweb: Allow for href() to be used for projectless links Jakub Narebski
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 2:56 UTC (permalink / raw)
To: git
Add git_project_index, which generates index.aux file that can be used
as a source of projects list, instead of generating projects list from
a directory. Using file as a source of projects list allows for some
projects to be not present in gitweb main (project_list) page, and/or
correct project owner info. And is probably faster.
Additionally it can be used to get the list of all available repositories
for scripts (in easily parseable form).
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b4a890b..7dbcb88 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -296,6 +296,7 @@ my %actions = (
# those below don't need $project
"opml" => \&git_opml,
"project_list" => \&git_project_list,
+ "project_index" => \&git_project_index,
);
if (defined $project) {
@@ -2210,6 +2211,30 @@ sub git_project_list {
git_footer_html();
}
+sub git_project_index {
+ my @projects = git_get_projects_list();
+
+ print $cgi->header(
+ -type => 'text/plain',
+ -charset => 'utf-8',
+ -content_disposition => qq(inline; filename="index.aux"));
+
+ foreach my $pr (@projects) {
+ if (!exists $pr->{'owner'}) {
+ $pr->{'owner'} = get_file_owner("$projectroot/$project");
+ }
+
+ my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
+ # quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
+ $path =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
+ $owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf("%%%02X", ord($1))/eg;
+ $path =~ s/ /\+/g;
+ $owner =~ s/ /\+/g;
+
+ print "$path $owner\n";
+ }
+}
+
sub git_summary {
my $descr = git_get_project_description($project) || "none";
my $head = git_get_head_hash($project);
--
1.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] gitweb: Allow for href() to be used for projectless links
2006-09-15 2:53 [PATCH 0/3] Add git_project_index, improve href() Jakub Narebski
2006-09-15 2:56 ` [PATCH 1/3] gitweb: Add git_project_index for generating index.aux Jakub Narebski
@ 2006-09-15 2:57 ` Jakub Narebski
2006-09-15 6:17 ` Junio C Hamano
2006-09-15 2:59 ` [PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page Jakub Narebski
2006-09-15 17:30 ` [PATCH 2/3 (take 2)] gitweb: Allow for href() to be used for links without project param Jakub Narebski
3 siblings, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 2:57 UTC (permalink / raw)
To: git
Change adding project to params if $params{"project"} is false
to adding project to params if it not exist. It allows for href()
to be used for projectless links by using "project=>undef" as
argument, while still adding project to params by default
in the most common case.
Convert remaining links (except $home_link and anchor links)
to use href(); this required adding 'order => "o"' to @mapping
in href(). This finishes consolidation of URL generation.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7dbcb88..e900713 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -326,11 +326,12 @@ sub href(%) {
hash_base => "hb",
hash_parent_base => "hpb",
page => "pg",
+ order => "o",
searchtext => "s",
);
my %mapping = @mapping;
- $params{"project"} ||= $project;
+ $params{'project'} = $project unless exists $params{'project'};
my @result = ();
for (my $i = 0; $i < @mapping; $i += 2) {
@@ -1304,9 +1305,11 @@ sub git_footer_html {
if (defined $descr) {
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
}
- print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
+ print $cgi->a({-href => href(action=>"rss"),
+ -class => "rss_logo"}, "RSS") . "\n";
} else {
- print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
+ print $cgi->a({-href => href(project=>undef, action=>"opml"),
+ -class => "rss_logo"}, "OPML") . "\n";
}
print "</div>\n" .
"</body>\n" .
@@ -2153,7 +2156,7 @@ sub git_project_list {
print "<th>Project</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=project"),
+ $cgi->a({-href => href(project=>undef, order=>'project'),
-class => "header"}, "Project") .
"</th>\n";
}
@@ -2162,7 +2165,7 @@ sub git_project_list {
print "<th>Description</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
+ $cgi->a({-href => href(project=>undef, order=>'descr'),
-class => "header"}, "Description") .
"</th>\n";
}
@@ -2171,7 +2174,7 @@ sub git_project_list {
print "<th>Owner</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
+ $cgi->a({-href => href(project=>undef, order=>'owner'),
-class => "header"}, "Owner") .
"</th>\n";
}
@@ -2180,7 +2183,7 @@ sub git_project_list {
print "<th>Last Change</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=age"),
+ $cgi->a({-href => href(project=>undef, order=>'age'),
-class => "header"}, "Last Change") .
"</th>\n";
}
--
1.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page
2006-09-15 2:53 [PATCH 0/3] Add git_project_index, improve href() Jakub Narebski
2006-09-15 2:56 ` [PATCH 1/3] gitweb: Add git_project_index for generating index.aux Jakub Narebski
2006-09-15 2:57 ` [PATCH 2/3] gitweb: Allow for href() to be used for projectless links Jakub Narebski
@ 2006-09-15 2:59 ` Jakub Narebski
2006-09-15 9:11 ` [PATCH 3/3 (take 2)] " Jakub Narebski
2006-09-15 17:30 ` [PATCH 2/3 (take 2)] gitweb: Allow for href() to be used for links without project param Jakub Narebski
3 siblings, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 2:59 UTC (permalink / raw)
To: git
Add link to "project_index" view as [TXT] beside link to "opml" view,
(which is marked by [OPML]) to "project_list" page.
While at it add alternate links for "opml" and "project_list" to HTML
header for "project_list" view.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
In the future we might want to change appereance of [TXT] link
to "project_index" view (e.g. green background instead of orange,
smaller width).
gitweb/gitweb.perl | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e900713..1f26365 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1255,6 +1255,13 @@ EOF
printf('<link rel="alternate" title="%s log" '.
'href="%s" type="application/rss+xml"/>'."\n",
esc_param($project), href(action=>"rss"));
+ } else {
+ printf('<link rel="alternate" title="%s" '.
+ 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
+ esc_param($project), href(project=>undef, action=>"project_index"));
+ printf('<link rel="alternate" title="%s" '.
+ 'href="%s" type="text/x-opml"/>'."\n",
+ esc_param($project), href(project=>undef, action=>"opml"));
}
if (defined $favicon) {
print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
@@ -1309,7 +1316,9 @@ sub git_footer_html {
-class => "rss_logo"}, "RSS") . "\n";
} else {
print $cgi->a({-href => href(project=>undef, action=>"opml"),
- -class => "rss_logo"}, "OPML") . "\n";
+ -class => "rss_logo"}, "OPML") . " ";
+ print $cgi->a({-href => href(project=>undef, action=>"project_index"),
+ -class => "rss_logo"}, "TXT") . "\n";
}
print "</div>\n" .
"</body>\n" .
--
1.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] gitweb: Allow for href() to be used for projectless links
2006-09-15 2:57 ` [PATCH 2/3] gitweb: Allow for href() to be used for projectless links Jakub Narebski
@ 2006-09-15 6:17 ` Junio C Hamano
2006-09-15 7:21 ` Jakub Narebski
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2006-09-15 6:17 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Jakub Narebski <jnareb@gmail.com> writes:
> Change adding project to params if $params{"project"} is false
> to adding project to params if it not exist. It allows for href()
> to be used for projectless links by using "project=>undef" as
> argument, while still adding project to params by default
> in the most common case.
This did not parse very well, at least for me.
> @@ -1304,9 +1305,11 @@ sub git_footer_html {
> if (defined $descr) {
> print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
> }
> - print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
> + print $cgi->a({-href => href(action=>"rss"),
> + -class => "rss_logo"}, "RSS") . "\n";
> } else {
> - print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
> + print $cgi->a({-href => href(project=>undef, action=>"opml"),
> + -class => "rss_logo"}, "OPML") . "\n";
> }
> print "</div>\n" .
> "</body>\n" .
Argh. While I very much welcome folding of the long lines, I'd
rather see a separate patch to clean up other loooooooong lines
the current gitweb code has.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] gitweb: Allow for href() to be used for projectless links
2006-09-15 6:17 ` Junio C Hamano
@ 2006-09-15 7:21 ` Jakub Narebski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 7:21 UTC (permalink / raw)
To: git
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> Change adding project to params if $params{"project"} is false
>> to adding project to params if it not exist. It allows for href()
>> to be used for projectless links by using "project=>undef" as
>> argument, while still adding project to params by default
>> in the most common case.
>
> This did not parse very well, at least for me.
O.K. let me rephrase it. Before this patch href() ensured that we had
p=<project> among CGI params, by adding it if it was not provided. Some
actions don't need project parameter, namely "project_list",
"project_index" and "opml". Moreover "project_list" view was sed as a
_home_ link, i.e. default action when project was not provided (just like
summary is default action when project is provided).
The change introduced by this patch allow to use href() to generate links
also for "project_list" and "opml" views. The only links which do not use
href() are anchor links, and $home_link link.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3 (take 2)] gitweb: Add link to "project_index" view to "project_list" page
2006-09-15 2:59 ` [PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page Jakub Narebski
@ 2006-09-15 9:11 ` Jakub Narebski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 9:11 UTC (permalink / raw)
To: git
Add link to "project_index" view as [TXT] beside link to "opml" view,
(which is marked by [OPML]) to "project_list" page.
While at it add alternate links for "opml" and "project_list" to HTML
header for "project_list" view.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Corrected alternate links (dumb error while copy'n'paste).
gitweb/gitweb.perl | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e900713..3079531 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1255,6 +1255,13 @@ EOF
printf('<link rel="alternate" title="%s log" '.
'href="%s" type="application/rss+xml"/>'."\n",
esc_param($project), href(action=>"rss"));
+ } else {
+ printf('<link rel="alternate" title="%s projects list" '.
+ 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
+ $site_name, href(project=>undef, action=>"project_index"));
+ printf('<link rel="alternate" title="%s projects logs" '.
+ 'href="%s" type="text/x-opml"/>'."\n",
+ $site_name, href(project=>undef, action=>"opml"));
}
if (defined $favicon) {
print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
@@ -1309,7 +1316,9 @@ sub git_footer_html {
-class => "rss_logo"}, "RSS") . "\n";
} else {
print $cgi->a({-href => href(project=>undef, action=>"opml"),
- -class => "rss_logo"}, "OPML") . "\n";
+ -class => "rss_logo"}, "OPML") . " ";
+ print $cgi->a({-href => href(project=>undef, action=>"project_index"),
+ -class => "rss_logo"}, "TXT") . "\n";
}
print "</div>\n" .
"</body>\n" .
--
1.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3 (take 2)] gitweb: Allow for href() to be used for links without project param
2006-09-15 2:53 [PATCH 0/3] Add git_project_index, improve href() Jakub Narebski
` (2 preceding siblings ...)
2006-09-15 2:59 ` [PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page Jakub Narebski
@ 2006-09-15 17:30 ` Jakub Narebski
3 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-09-15 17:30 UTC (permalink / raw)
To: git; +Cc: Junio Hamano
Make it possible use href() subroutine to generate link with
query string which does not include project ('p') parameter.
href() used to add project=$project to its parameters, if it
was not set (to be more exact if $params{'project'} was false).
Now you can pass "project => undef" if you don't want for href()
to add project parameter to query string in the generated link.
Links to "project_list", "project_index" and "opml" (all related
to list of all projects/all git repositories) doesn't need project
parameter. Moreover "project_list" is default view (action) if
project ('p') parameter is not set, just like "summary" is default
view (action) if project is set; project list served as a kind
of "home" page for gitweb instalation, and links to "project_list"
view were done without specyfying it as an action.
Convert remaining links (except $home_link and anchor links)
to use href(); this required adding 'order => "o"' to @mapping
in href(). This finishes consolidation of URL generation.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Only commit message has changed.
gitweb/gitweb.perl | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7dbcb88..e900713 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -326,11 +326,12 @@ sub href(%) {
hash_base => "hb",
hash_parent_base => "hpb",
page => "pg",
+ order => "o",
searchtext => "s",
);
my %mapping = @mapping;
- $params{"project"} ||= $project;
+ $params{'project'} = $project unless exists $params{'project'};
my @result = ();
for (my $i = 0; $i < @mapping; $i += 2) {
@@ -1304,9 +1305,11 @@ sub git_footer_html {
if (defined $descr) {
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
}
- print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
+ print $cgi->a({-href => href(action=>"rss"),
+ -class => "rss_logo"}, "RSS") . "\n";
} else {
- print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
+ print $cgi->a({-href => href(project=>undef, action=>"opml"),
+ -class => "rss_logo"}, "OPML") . "\n";
}
print "</div>\n" .
"</body>\n" .
@@ -2153,7 +2156,7 @@ sub git_project_list {
print "<th>Project</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=project"),
+ $cgi->a({-href => href(project=>undef, order=>'project'),
-class => "header"}, "Project") .
"</th>\n";
}
@@ -2162,7 +2165,7 @@ sub git_project_list {
print "<th>Description</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
+ $cgi->a({-href => href(project=>undef, order=>'descr'),
-class => "header"}, "Description") .
"</th>\n";
}
@@ -2171,7 +2174,7 @@ sub git_project_list {
print "<th>Owner</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
+ $cgi->a({-href => href(project=>undef, order=>'owner'),
-class => "header"}, "Owner") .
"</th>\n";
}
@@ -2180,7 +2183,7 @@ sub git_project_list {
print "<th>Last Change</th>\n";
} else {
print "<th>" .
- $cgi->a({-href => "$my_uri?" . esc_param("o=age"),
+ $cgi->a({-href => href(project=>undef, order=>'age'),
-class => "header"}, "Last Change") .
"</th>\n";
}
--
1.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-09-15 17:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-15 2:53 [PATCH 0/3] Add git_project_index, improve href() Jakub Narebski
2006-09-15 2:56 ` [PATCH 1/3] gitweb: Add git_project_index for generating index.aux Jakub Narebski
2006-09-15 2:57 ` [PATCH 2/3] gitweb: Allow for href() to be used for projectless links Jakub Narebski
2006-09-15 6:17 ` Junio C Hamano
2006-09-15 7:21 ` Jakub Narebski
2006-09-15 2:59 ` [PATCH 3/3] gitweb: Add link to "project_index" view to "project_list" page Jakub Narebski
2006-09-15 9:11 ` [PATCH 3/3 (take 2)] " Jakub Narebski
2006-09-15 17:30 ` [PATCH 2/3 (take 2)] gitweb: Allow for href() to be used for links without project param 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).