From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:57:58
There are often parent pages logically above the gitweb projects
list, e.g. home pages of the organization and department that host
the gitweb server. This change allows you to include links to those
pages in gitweb's breadcrumb trail.
Signed-off-by: Tony Finch <dot@dotat.at>
---
Documentation/gitweb.conf.txt | 8 ++++++++
gitweb/gitweb.perl | 6 ++++++
2 files changed, 14 insertions(+)
@@ -339,6 +339,14 @@ $home_link_str:: as this link leads to the list of projects. Other popular choice it to set it to the name of site.+@extra_breadcrumbs::+ Additional links to be added to the start of the breadcrumb trail,+ that are logically "above" the gitweb projects list. For example,+ links to the organization and department which host the gitweb+ server. Each element of the list is a reference to an array,+ in which element 0 is the link text and element 1 is the+ target URL.+ $logo_url:: $logo_label:: URI and label (title) for the Git logo link (or your site logo,
@@ -85,6 +85,9 @@ our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";# string of the home link on top of all pagesour$home_link_str="++GITWEB_HOME_LINK_STR++";+# extra breadcrumbs preceding the home link+our@extra_breadcrumbs=();+# name of your site or organization to appear in page titles# replace this with something more descriptive for clearer bookmarksour$site_name="++GITWEB_SITENAME++"
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:57:59
(cc-ing Jakub, gitweb wrangler)
Tony Finch wrote:
There are often parent pages logically above the gitweb projects
list, e.g. home pages of the organization and department that host
the gitweb server. This change allows you to include links to those
pages in gitweb's breadcrumb trail.
@@ -339,6 +339,14 @@ $home_link_str:: as this link leads to the list of projects. Other popular choice it to set it to the name of site.+@extra_breadcrumbs::+ Additional links to be added to the start of the breadcrumb trail,+ that are logically "above" the gitweb projects list. For example,+ links to the organization and department which host the gitweb+ server. Each element of the list is a reference to an array,+ in which element 0 is the link text and element 1 is the+ target URL.
Is arbitrary HTML permitted in the link text?
I think it makes sense to permit it for consistency with $home_link_str,
but it might be worth mentioning in the manpage so the administrator
knows not to set it to something user-controlled --- e.g.:
The link text can contain arbitrary HTML --- to escape link
text generated programatically, use esc_html($text).
For what it's worth, with or without such a change,
Reviewed-by: Jonathan Nieder <redacted>
(Patch left unsnipped for reference.)
quoted hunk
+
$logo_url::
$logo_label::
URI and label (title) for the Git logo link (or your site logo,
@@ -85,6 +85,9 @@ our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";# string of the home link on top of all pagesour$home_link_str="++GITWEB_HOME_LINK_STR++";+# extra breadcrumbs preceding the home link+our@extra_breadcrumbs=();+# name of your site or organization to appear in page titles# replace this with something more descriptive for clearer bookmarksour$site_name="++GITWEB_SITENAME++"
From: Jakub Narębski <hidden> Date: 2016-06-15 22:57:59
On Wed, Jul 3, 2013 at 11:59 PM, Jonathan Nieder [off-list ref] wrote:
Tony Finch wrote:
quoted
+@extra_breadcrumbs::
+ Additional links to be added to the start of the breadcrumb trail,
+ that are logically "above" the gitweb projects list. For example,
+ links to the organization and department which host the gitweb
+ server. Each element of the list is a reference to an array,
+ in which element 0 is the link text and element 1 is the
+ target URL.
Is arbitrary HTML permitted in the link text?
I think it makes sense to permit it for consistency with $home_link_str,
but it might be worth mentioning in the manpage so the administrator
knows not to set it to something user-controlled --- e.g.:
The link text can contain arbitrary HTML --- to escape link
text generated programatically, use esc_html($text).
Nb. it would be nice to have relation of @extra_breadcrumbs with
$home_link_str explained.
--
Jakub Narebski
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:57:59
Jakub Narębski [off-list ref] wrote:
On Wed, Jul 3, 2013 at 11:59 PM, Jonathan Nieder [off-list ref] wrote:
quoted
Tony Finch wrote:
quoted
quoted
+@extra_breadcrumbs::
+ Additional links to be added to the start of the breadcrumb trail,
+ that are logically "above" the gitweb projects list. For example,
+ links to the organization and department which host the gitweb
+ server. Each element of the list is a reference to an array,
+ in which element 0 is the link text and element 1 is the
+ target URL.
Is arbitrary HTML permitted in the link text?
I had the same question when I was wondering about abusing $home_link_str
to do this without a patch :-)
quoted
I think it makes sense to permit it for consistency with $home_link_str,
but it might be worth mentioning in the manpage so the administrator
knows not to set it to something user-controlled --- e.g.:
I left this detail out of the man page for consistency with the
documentation for $home_link_str.
Nb. it would be nice to have relation of @extra_breadcrumbs with
$home_link_str explained.
I will make that clearer.
Thanks for reviewing the patch.
Tony.
--
f.anthony.n.finch [off-list ref] http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:57:59
There are often parent pages logically above the gitweb projects
list, e.g. home pages of the organization and department that host
the gitweb server. This change allows you to include links to those
pages in gitweb's breadcrumb trail.
Signed-off-by: Tony Finch <dot@dotat.at>
Reviewed-by: Jonathan Nieder <redacted>
---
This update includes the documentation improvements suggested by
Jonathan Nieder and Jakub NarÄbski.
Documentation/gitweb.conf.txt | 22 ++++++++++++++++++++--
gitweb/gitweb.perl | 6 ++++++
2 files changed, 26 insertions(+), 2 deletions(-)
@@ -336,8 +336,26 @@ $home_link_str:: used as the first component of gitweb's "breadcrumb trail": `<home link> / <project> / <action>`. Can be set at build time using the `GITWEB_HOME_LINK_STR` variable. By default it is set to "projects",- as this link leads to the list of projects. Other popular choice it to- set it to the name of site.+ as this link leads to the list of projects. Another popular choice is to+ set it to the name of site. Note that it is treated as raw HTML so it+ should not be set from untrusted sources.++@extra_breadcrumbs::+ Additional links to be added to the start of the breadcrumb trail before+ the home link, to pages that are logically "above" the gitweb projects+ list, such as the organization and department which host the gitweb+ server. Each element of the list is a reference to an array, in which+ element 0 is the link text (equivalent to `$home_link_str`) and element+ 1 is the target URL (equivalent to `$home_link`).+++For example, the following setting produces a breadcrumb trail like+"home / dev / projects / ..." where "projects" is the home link.+----------------------------------------------------------------------------+ our @extra_breadcrumbs = (+ [ 'home' => 'https://www.example.org/' ],+ [ 'dev' => 'https://dev.example.org/' ],+ );+---------------------------------------------------------------------------- $logo_url:: $logo_label::
@@ -85,6 +85,9 @@ our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";# string of the home link on top of all pagesour$home_link_str="++GITWEB_HOME_LINK_STR++";+# extra breadcrumbs preceding the home link+our@extra_breadcrumbs=();+# name of your site or organization to appear in page titles# replace this with something more descriptive for clearer bookmarksour$site_name="++GITWEB_SITENAME++"
From: Jakub Narębski <hidden> Date: 2016-06-15 22:58:00
On Thu, Jul 4, 2013 at 10:44 AM, Tony Finch [off-list ref] wrote:
Jakub Narębski [off-list ref] wrote:
quoted
On Wed, Jul 3, 2013 at 11:59 PM, Jonathan Nieder [off-list ref] wrote:
quoted
Tony Finch wrote:
quoted
quoted
+@extra_breadcrumbs::
BTW. perhaps (it is only an idea) @top_level_breadcrumbs or
@home_breadcrumbs would be a better name for this variable.
quoted
quoted
quoted
+ Additional links to be added to the start of the breadcrumb trail,
+ that are logically "above" the gitweb projects list. For example,
+ links to the organization and department which host the gitweb
+ server. Each element of the list is a reference to an array,
+ in which element 0 is the link text and element 1 is the
+ target URL.
Is arbitrary HTML permitted in the link text?
I had the same question when I was wondering about abusing $home_link_str
to do this without a patch :-)
Not exactly arbitrary, as it is inside A element, so it cannot contain A links
itself (hyperlinks should not be nested), but it is not esc_html-aped.
quoted
quoted
I think it makes sense to permit it for consistency with $home_link_str,
but it might be worth mentioning in the manpage so the administrator
knows not to set it to something user-controlled --- e.g.:
I left this detail out of the man page for consistency with the
documentation for $home_link_str.
It would be better to improve documentation, than follow current bad
practice... ;-P
quoted
Nb. it would be nice to have relation of @extra_breadcrumbs with
$home_link_str explained.
I will make that clearer.
Perhaps even make ( [ $home_link_str, $home_link ] ) to be default
value for @extra_breadcrumbs, making new feature generalization
of $home_link*, similarly to how it was done for $stylesheet -> @stylesheets
transition.
What do you think about it?
--
Jakub Narębski
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:58:00
Jakub Narębski [off-list ref] wrote:
It would be better to improve documentation, than follow current bad
practice... ;-P
The v2 patch does just that :-)
Perhaps even make ( [ $home_link_str, $home_link ] ) to be default
value for @extra_breadcrumbs, making new feature generalization
of $home_link*, similarly to how it was done for $stylesheet -> @stylesheets
transition.
I don't think that's a win. There's a lot of existing gitweb.conf out
there which sets $home_link_str, so the code would have to either print
the last element of @extra_breadcrumbs or the $home_link variables
depending on whether the variables were modified. And the documentation
would have to explain this complicated arrangement.
Tony.
--
f.anthony.n.finch [off-list ref] http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.
From: Jakub Narębski <hidden> Date: 2016-06-15 22:58:00
On Thu, Jul 4, 2013 at 5:11 PM, Tony Finch [off-list ref] wrote:
Jakub Narębski [off-list ref] wrote:
quoted
It would be better to improve documentation, than follow current bad
practice... ;-P
The v2 patch does just that :-)
Thanks.
quoted
Perhaps even make ( [ $home_link_str, $home_link ] ) to be default
value for @extra_breadcrumbs, making new feature generalization
of $home_link*, similarly to how it was done for $stylesheet -> @stylesheets
transition.
I don't think that's a win. There's a lot of existing gitweb.conf out
there which sets $home_link_str, so the code would have to either print
the last element of @extra_breadcrumbs or the $home_link variables
depending on whether the variables were modified. And the documentation
would have to explain this complicated arrangement.
First, do I understand corrctly that @extra_breadcrumbs are rendered *after*
$home_link*, and in exactly the same manner?
Second, I misremembered how $stylesheet / @stylesheets is handled.
I was thinking more about having in gitweb.perl the following default
initialization for @extra_breadcrumbs:
our @extra_breadcrumbs = ( [ $home_link_str, $home_link ] );
Then one can add breadcrumbs with
push @extra_breadcrumbs, [ $foo_html, $foo_url ], [
esc_html($bar_txt), $bar_url ];
But now I think that we can do better, simply put $home_link_str and $home_link
in @extra_breadcrumbs / @top_level_breadcrumbs / @nav_breadcrumbs before
using it, either via
unshift @nav_breadcrumbs, [ $home_link_str, $home_link ];
or
for $breadcrumb ([ $home_link_str, $home_link ], @nav_breadcrumbs) {
... unless we treat home link in some special way (do we?).
P.S. It is a bit late, but wouldn't { name => $link_name, href => $link_url }
(like %features hash) be a better solution than [ $link_name, $link_url ],
i.e. hashref (named parameters) instead of arrayref (positional parameters).
You wouldn't have to remember which is first: text or URL.
--
Jakub Narebski
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:58:00
Jakub Narębski [off-list ref] wrote:
First, do I understand corrctly that @extra_breadcrumbs are rendered *after*
$home_link*, and in exactly the same manner?
Before the home link, and yes, in the same manner. The extra breadcrumbs
are for links to parent pages above gitweb in some hierarchy.
But now I think that we can do better, simply put $home_link_str and $home_link
in @extra_breadcrumbs / @top_level_breadcrumbs / @nav_breadcrumbs before
using it,
We could save a line that way:
- print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
+ for my $crumb (@extra_breadcrumbs, [ $home_link_str => $home_link ]) {
+ print $cgi->a({-href => esc_url($crumb->[1])}, $crumb->[0]) . " / ";
+ }
P.S. It is a bit late, but wouldn't { name => $link_name, href => $link_url }
(like %features hash) be a better solution than [ $link_name, $link_url ],
i.e. hashref (named parameters) instead of arrayref (positional parameters).
You wouldn't have to remember which is first: text or URL.
I thought the fat arrow would be mnemonic enough, and less verbose.
Tony.
--
f.anthony.n.finch [off-list ref] http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.
From: Jakub Narębski <hidden> Date: 2016-06-15 22:58:00
On Thu, Jul 4, 2013 at 5:56 PM, Tony Finch [off-list ref] wrote:
Jakub Narębski [off-list ref] wrote:
quoted
First, do I understand correctly that @extra_breadcrumbs are rendered *after*
$home_link*, and in exactly the same manner?
Before the home link, and yes, in the same manner. The extra breadcrumbs
are for links to parent pages above gitweb in some hierarchy.
Hmmm... I would have thought that they were after home link. I wonder
if leaving it up to user to configure @extra_breadcrumbs to include $home_link
in appropriate place (the unshift / push solution to adding to
@extra_breadcrumbs,
starting with $home_link) would be good idea, or over-engineering.
In what situation do you need those extra breadcrumbs useful? What
necessity / itch to scratch is behind idea of this patch?
quoted
But now I think that we can do better, simply put $home_link_str and $home_link
in @extra_breadcrumbs / @top_level_breadcrumbs / @nav_breadcrumbs before
using it,
We could save a line that way:
- print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
+ for my $crumb (@extra_breadcrumbs, [ $home_link_str => $home_link ]) {
+ print $cgi->a({-href => esc_url($crumb->[1])}, $crumb->[0]) . " / ";
+ }
And avoid a bit of code duplication; now we are sure that both
@extra_breadcrumbs and $home_link are rendered in the same way.
quoted
P.S. It is a bit late, but wouldn't { name => $link_name, href => $link_url }
(like %features hash) be a better solution than [ $link_name, $link_url ],
i.e. hashref (named parameters) instead of arrayref (positional parameters).
You wouldn't have to remember which is first: text or URL.
I thought the fat arrow would be mnemonic enough, and less verbose.
Yes, hashref solution is a bit verbose. I don't like abusing fat arrow notation,
but here it gives nice mnemonic (hopefully explained in documentation).
--
Jakub Narebski
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:58:00
Jakub Narębski [off-list ref] wrote:
In what situation do you need those extra breadcrumbs useful? What
necessity / itch to scratch is behind idea of this patch?
For an example, see https://git.csx.cam.ac.uk/x/ucs/git/git.git
I have three items in @extra_breadcrumbs which point to the University
home page, my department home page, and my git server's home page; there
are a number of gitolite accounts on the server each of which has a
project listing which is where gitweb's home link points.
(I expect to change the link texts to make it less confusing when you
happen to be looking at my department's account on the git server...)
our @extra_breadcrumbs = (
[ cam => 'http://www.cam.ac.uk/' ],
[ ucs => 'http://www.ucs.cam.ac.uk/' ],
[ git => 'https://git.csx.cam.ac.uk/' ],
);
This is in line with our house style (none of which I have implemented on
this server yet) - there are other examples of similar breadcrumb trails
at https://raven.cam.ac.uk and http://new-webmail.hermes.cam.ac.uk
There is a more generic version of this description and config example in
v2 of my patch. I hope it is clear enough. I'll send a v3 patch with the
code tweak.
Tony.
--
f.anthony.n.finch [off-list ref] http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.
From: Tony Finch <dot@dotat.at> Date: 2016-06-15 22:58:00
There are often parent pages logically above the gitweb projects
list, e.g. home pages of the organization and department that host
the gitweb server. This change allows you to include links to those
pages in gitweb's breadcrumb trail.
Signed-off-by: Tony Finch <dot@dotat.at>
Reviewed-by: Jonathan Nieder <redacted>
---
Documentation/gitweb.conf.txt | 22 ++++++++++++++++++++--
gitweb/gitweb.perl | 7 ++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
@@ -336,8 +336,26 @@ $home_link_str:: used as the first component of gitweb's "breadcrumb trail": `<home link> / <project> / <action>`. Can be set at build time using the `GITWEB_HOME_LINK_STR` variable. By default it is set to "projects",- as this link leads to the list of projects. Other popular choice it to- set it to the name of site.+ as this link leads to the list of projects. Another popular choice is to+ set it to the name of site. Note that it is treated as raw HTML so it+ should not be set from untrusted sources.++@extra_breadcrumbs::+ Additional links to be added to the start of the breadcrumb trail before+ the home link, to pages that are logically "above" the gitweb projects+ list, such as the organization and department which host the gitweb+ server. Each element of the list is a reference to an array, in which+ element 0 is the link text (equivalent to `$home_link_str`) and element+ 1 is the target URL (equivalent to `$home_link`).+++For example, the following setting produces a breadcrumb trail like+"home / dev / projects / ..." where "projects" is the home link.+----------------------------------------------------------------------------+ our @extra_breadcrumbs = (+ [ 'home' => 'https://www.example.org/' ],+ [ 'dev' => 'https://dev.example.org/' ],+ );+---------------------------------------------------------------------------- $logo_url:: $logo_label::
@@ -85,6 +85,9 @@ our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";# string of the home link on top of all pagesour$home_link_str="++GITWEB_HOME_LINK_STR++";+# extra breadcrumbs preceding the home link+our@extra_breadcrumbs=();+# name of your site or organization to appear in page titles# replace this with something more descriptive for clearer bookmarksour$site_name="++GITWEB_SITENAME++"
From: Jakub Narębski <hidden> Date: 2016-06-15 22:58:00
On Thu, Jul 4, 2013 at 7:08 PM, Tony Finch [off-list ref] wrote:
Jakub Narębski [off-list ref] wrote:
quoted
In what situation do you need those extra breadcrumbs useful? What
necessity / itch to scratch is behind idea of this patch?
For an example, see https://git.csx.cam.ac.uk/x/ucs/git/git.git
I have three items in @extra_breadcrumbs which point to the University
home page, my department home page, and my git server's home page; there
are a number of gitolite accounts on the server each of which has a
project listing which is where gitweb's home link points.
Of course those @external_breadcrumbs are really useful iff they are
repeated consistently in at least similar form in all those external pages...
(I expect to change the link texts to make it less confusing when you
happen to be looking at my department's account on the git server...)
From: Jakub Narębski <hidden> Date: 2016-06-15 22:58:00
On Thu, Jul 4, 2013 at 7:02 PM, Tony Finch [off-list ref] wrote:
There are often parent pages logically above the gitweb projects
list, e.g. home pages of the organization and department that host
the gitweb server. This change allows you to include links to those
pages in gitweb's breadcrumb trail.
Signed-off-by: Tony Finch <dot@dotat.at>
Reviewed-by: Jonathan Nieder <redacted>
For what it is worth:
Acked-by: Jakub Narebski <redacted>
@@ -336,8 +336,26 @@ $home_link_str:: used as the first component of gitweb's "breadcrumb trail": `<home link> / <project> / <action>`. Can be set at build time using the `GITWEB_HOME_LINK_STR` variable. By default it is set to "projects",- as this link leads to the list of projects. Other popular choice it to- set it to the name of site.+ as this link leads to the list of projects. Another popular choice is to+ set it to the name of site. Note that it is treated as raw HTML so it+ should not be set from untrusted sources.
I wonder if we should change this... but it is issue unrelated to current
patch, which doesn't make situation worse.
+
+@extra_breadcrumbs::
@external_breadcrumbs ???
quoted hunk
+ Additional links to be added to the start of the breadcrumb trail before
+ the home link, to pages that are logically "above" the gitweb projects
+ list, such as the organization and department which host the gitweb
+ server. Each element of the list is a reference to an array, in which
+ element 0 is the link text (equivalent to `$home_link_str`) and element
+ 1 is the target URL (equivalent to `$home_link`).
++
+For example, the following setting produces a breadcrumb trail like
+"home / dev / projects / ..." where "projects" is the home link.
+----------------------------------------------------------------------------
+ our @extra_breadcrumbs = (
+ [ 'home' => 'https://www.example.org/' ],
+ [ 'dev' => 'https://dev.example.org/' ],
+ );
+----------------------------------------------------------------------------
$logo_url::
$logo_label::
@@ -85,6 +85,9 @@ our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";# string of the home link on top of all pagesour$home_link_str="++GITWEB_HOME_LINK_STR++";+# extra breadcrumbs preceding the home link+our@extra_breadcrumbs=();+# name of your site or organization to appear in page titles# replace this with something more descriptive for clearer bookmarksour$site_name="++GITWEB_SITENAME++"