summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Releases/Lib.pm
blob: a5853504eb110e55b3c78b624946903d7a20629b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package VNWeb::Releases::Lib;

use VNWeb::Prelude;
use Exporter 'import';

our @EXPORT = qw/release_extlinks_/;


# Generate the html for an 'external links' dropdown, assumes enrich_extlinks() has already been called on this object.
sub release_extlinks_ {
    my($r, $id) = @_;
    return if !$r->{extlinks}->@*;
    my $has_dd = $r->{extlinks}->@* > ($r->{website} ? 1 : 0);
    my sub icon_ {
        a_ href => $r->{website}||'#', sub {
            txt_ scalar $r->{extlinks}->@* if $has_dd;
            abbr_ class => 'icons external', title => 'External link', '';
        }
    }
    elm_ ReleaseExtLinks => undef, [ ''.($id||$r->{id}), $r->{extlinks} ], \&icon_ if $has_dd;
    icon_ if !$has_dd;
}

1;