sub basic()

in lib/view.pm [74:135]


sub basic {
    my %args = @_;
    my $filepath = "content$args{path}";

    print "basic $filepath";

    read_text_file($filepath, \%args);

    $args{path} =~ s/\.mdtext$/\.html/;
    $args{base} = _base($args{path});
    $args{breadcrumbs} = _breadcrumbs($args{path}, $args{base});

    my $template_path = "templates/$args{template}";

    my @includes = ($args{content} =~ m/{include:([^ ]+?)}/g);

    foreach my $include (@includes) {
        next unless ( -e "content/$include");

        my %a = ();
        read_text_file("content/$include", \%a);
        my $text = $a{content};
        $args{headers}{title} = $a{headers}{title} unless $args{headers}{title};

        # If the file to be included is in a child directory, resolve all the links
        # in the included content to be relative to this document
        if ($include =~ m,/,) {
            my $ipath = $include;
            $ipath =~ s,/[^/]*$,,;
            $text =~ s,(\[[^[]+])\(([^/][^)]+)\),$1($ipath/$2),g;
        }

        $args{content} =~ s/{include:$include}/$text/g;
    }

    if ($args{headers}{version}) {
        my $url = "http://repository.apache.org/content/groups/snapshots/org/apache/openejb/apache-tomee/$args{headers}{version}-SNAPSHOT/maven-metadata.xml";
        my $_ = get($url);
        s/\n| //g;
        my ($timestamp, $buildNumber) = m,<timestamp>(.*)</timestamp>.*<buildNumber>(.*)</buildNumber>.*,;
        $args{headers}{build} = "$timestamp-$buildNumber";

        $args{changelog} = `java -jar lib/release-tools-1.0-SNAPSHOT-jar-with-dependencies.jar releasenotes -DtomeeVersion=$args{headers}{version} -DopenejbVersion=$args{headers}{oversion}`;
        print $args{changelog};
    }

    if ($args{headers}{oversion}) {
        my $url = "http://repository.apache.org/content/groups/snapshots/org/apache/openejb/openejb-standalone/$args{headers}{oversion}-SNAPSHOT/maven-metadata.xml";
        my $_ = get($url);
        s/\n| //g;
        my ($timestamp, $buildNumber) = m,<timestamp>(.*)</timestamp>.*<buildNumber>(.*)</buildNumber>.*,;
        $args{headers}{obuild} = "$timestamp-$buildNumber";
    }

    print " - rendering";

    my $rendered = Dotiac::DTL->new($template_path)->render(\%args);

    print " - complete\n";

    return ($rendered, 'html', \%args);
}