sub downloads()

in ARCHIVE/OLD-from-apache-cms/lib/view.pm [104:161]


sub downloads {
	my %args = @_;	
    my $file = "content$args{path}";
    my $template = $args{template};
    $args{path} =~ s/\.list$/\.html/;
    $args{breadcrumbs} = breadcrumbs($args{path});
    $args{svninfo} = svninfo($file);
	
    read_text_file $file, \%args;

    my $result = "|Artifact | Version | Binary | Source|\n|--|--|--|--|\n";
    my $maven = "|Artifact | Version | Binary | Source|\n|--|--|--|--|\n";
    my $launchpad = "| Artifact | Version | Provides | Package |\n|-|-|-|-|\n";
    my $ide = "|Artifact | Version | Provides | Update site |\n|--|--|--|--|\n";

    my @lines = split( /\n/, $args{content} );
    @lines = sort @lines;
    for my $line (@lines) {
    	next if (!$line || $line =~ /^\s*#/);
    	
    	my ($title, $artifact, $version, $classifier, $ext) = split(/\|/, $line);
    	$ext = "jar" unless ($ext);
    	$classifier = ($classifier) ? "-$classifier" : "";
    	
    	if ($title eq "sling") {
    		
            $launchpad .="| Sling Standalone Application | $artifact | A self-runnable Sling jar. | " . downloadLink("org.apache.sling.launchpad-$artifact.jar"). "|\n";
            $launchpad .="| Sling Web Application | $artifact | A ready-to run Sling webapp as a war file. | " . downloadLink("org.apache.sling.launchpad-$artifact-webapp.war"). "|\n";
            $launchpad .="| Sling Source Release | $artifact | The released Sling source code. | " . downloadLink("org.apache.sling.launchpad-$artifact-source-release.zip")." |\n";
        } elsif ( $title eq "sling-ide-tooling" ) {

            $ide .= "| Sling IDE Tooling for Eclipse | $artifact | A p2 update site which can be installed in Eclipse. | " . downloadLinkWithoutSigs("eclipse/$artifact", "Update site") . " " . downloadLink("org.apache.sling.ide.p2update-$artifact.zip", "(zip download)") ." |\n";
    	} else {
	    	
	    	my $target = \$result;
	    	my $artifactLabel;
	    	if ($ext eq "war") {
                $artifactLabel = "Web Application";
	    	} elsif ($classifier eq "-app") {
                $artifactLabel = "Java Application";
	    	} elsif ($artifact =~/^maven-.*-plugin|.*-maven-plugin/) {
	    		$target = \$maven;
                $artifactLabel = "Maven Plugin";
	    	} else {
	    		$artifactLabel = "Bundle";
	    	}
	    	
	        ${$target} .= "|$title|$version|" . downloadLink("$artifact-$version$classifier.$ext", $artifactLabel) . " | " . downloadLink("$artifact-$version-source-release.zip", "Source ZIP") . "|\n";
    	}
    }

    $args{launchpad} = $launchpad;
    $args{content} = $result;
    $args{maven} = $maven;
    $args{ide} = $ide;
    
    return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
}