X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwStream.pm;h=9ba8fa114de43a6c5621915f2e035d548fa348b9;hb=2adbbf87748719b422ba08d674ccb35637cb76b5;hp=f7e09c24800eabdf444280dbc3aa2112eee19a7d;hpb=0a1e15ad863782650a36025b9d52a6e9de5eadf3;p=public-inbox.git diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index f7e09c24..9ba8fa11 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -12,11 +12,12 @@ our @EXPORT_OK = qw(html_oneshot); use bytes (); # length use PublicInbox::Hval qw(ascii_html prurl ts2str); our $TOR_URL = 'https://www.torproject.org/'; -our $CODE_URL = 'https://public-inbox.org/public-inbox.git'; +our $CODE_URL = [ qw(http://ou63pmih66umazou.onion/public-inbox.git + https://public-inbox.org/public-inbox.git) ]; sub base_url ($) { my $ctx = shift; - my $base_url = $ctx->{-inbox}->base_url($ctx->{env}); + my $base_url = $ctx->{ibx}->base_url($ctx->{env}); chop $base_url; # no trailing slash for clone $base_url; } @@ -35,7 +36,7 @@ sub async_eml { # for async_blob_cb sub html_top ($) { my ($ctx) = @_; - my $ibx = $ctx->{-inbox}; + my $ibx = $ctx->{ibx}; my $desc = ascii_html($ibx->description); my $title = delete($ctx->{-title_html}) // $desc; my $upfx = $ctx->{-upfx} || ''; @@ -54,7 +55,7 @@ sub html_top ($) { qq(color / ). qq(mirror / ). qq(Atom feed); - if ($ibx->search) { + if ($ibx->isrch) { my $q_val = delete($ctx->{-q_value_html}) // ''; $q_val = qq(\nvalue="$q_val") if $q_val ne ''; # XXX gross, for SearchView.pm @@ -76,6 +77,24 @@ sub html_top ($) { ''. $top . (delete($ctx->{-html_tip}) // ''); } +sub coderepos ($) { + my ($ctx) = @_; + my $cr = $ctx->{ibx}->{coderepo} // return (); + my $cfg = $ctx->{www}->{pi_cfg}; + my @ret; + for my $cr_name (@$cr) { + my $urls = $cfg->{"coderepo.$cr_name.cgiturl"} // next; + $ret[0] //= <{env}, $u)); + $ret[0] .= qq(\n\t$u); + } + } + @ret; # may be empty, this sub is called as an arg for join() +} + sub code_footer ($) { my ($env) = @_; my $u = prurl($env, $CODE_URL); @@ -89,7 +108,7 @@ sub _html_end { id=mirror>This inbox may be cloned and mirrored by anyone: EOF - my $ibx = $ctx->{-inbox}; + my $ibx = $ctx->{ibx}; my $desc = ascii_html($ibx->description); my @urls; @@ -123,10 +142,10 @@ EOF } $urls .= "\n" . join('', map { "\tgit clone --mirror $_\n" } @urls); - my $addrs = $ibx->{address}; - $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY'; - my $v = defined $max ? '-V2' : '-V1'; - $urls .= <{address}) { + $addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY'; + my $v = defined $max ? '-V2' : '-V1'; + $urls .= <{-upfx} // '').'_/text/config/raw'; $urls .= <
'.join("\n\n",
 		$desc,
 		$urls,
+		coderepos($ctx),
 		code_footer($ctx->{env})
 	).'
'; } @@ -163,7 +184,7 @@ sub getline { my $cb = $ctx->{cb} or return; while (defined(my $x = $cb->($ctx))) { # x = smsg or scalar non-ref if (ref($x)) { # smsg - my $eml = $ctx->{-inbox}->smsg_eml($x) or next; + my $eml = $ctx->{ibx}->smsg_eml($x) or next; $ctx->{smsg} = $x; return $ctx->translate($cb->($ctx, $eml)); } else { # scalar