]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwstream: linkify coderepo URLs
authorEric Wong <e@80x24.org>
Fri, 18 Dec 2020 20:53:09 +0000 (20:53 +0000)
committerEric Wong <e@80x24.org>
Sun, 20 Dec 2020 20:38:47 +0000 (20:38 +0000)
It seems like a good idea to get more cgit visibility.

lib/PublicInbox/WwwStream.pm

index 66e34a12e885c12c95454933cb42f5082545c53e..49940262eeb6469fbc0cf3a82970ece740440dcd 100644 (file)
@@ -78,22 +78,20 @@ sub html_top ($) {
 
 sub coderepos ($) {
        my ($ctx) = @_;
-       my $ibx = $ctx->{ibx};
+       my $cr = $ctx->{ibx}->{coderepo} // return ();
+       my $cfg = $ctx->{www}->{pi_cfg};
        my @ret;
-       if (defined(my $cr = $ibx->{coderepo})) {
-               my $cfg = $ctx->{www}->{pi_cfg};
-               my $env = $ctx->{env};
-               for my $cr_name (@$cr) {
-                       my $urls = $cfg->{"coderepo.$cr_name.cgiturl"};
-                       if ($urls) {
-                               $ret[0] //= <<EOF;
+       for my $cr_name (@$cr) {
+               my $urls = $cfg->{"coderepo.$cr_name.cgiturl"} // next;
+               $ret[0] //= <<EOF;
 code repositories for the project(s) associated with this inbox:
 EOF
-                               $ret[0] .= "\n\t".prurl($env, $_) for @$urls;
-                       }
+               for my $u (@$urls) {
+                       $u = ascii_html(prurl($ctx->{env}, $u));
+                       $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>);
                }
        }
-       @ret; # may be empty
+       @ret; # may be empty, this sub is called as an arg for join()
 }
 
 sub code_footer ($) {