App-Pods2Site

 view release on metacpan or  search on metacpan

lib/App/Pods2Site/SiteBuilder/BasicFramesTreeTOC.pm  view on Meta::CPAN

{
	my $self = shift;
	my $sitedir = shift;
	my $ref = shift;
	my $podInfo = shift;
	my $treeloc = shift;
	my $depth = shift;
	my $n = shift;
	my $np = shift;

	$self->{maxtocdepth} = $depth if $depth > $self->{maxtocdepth};
	
	my $hasSubNodes = keys(%$treeloc) ? 1 : 0;
	
	my $r = '';
	if ($n)
	{
		$r = "${n}::";

		$$ref .= qq(<details class="toc-$depth">\n) if $hasSubNodes;
		
		$$ref .= ($hasSubNodes ? qq(<summary class="toc-$depth">) : qq(<div class="toc-$depth">));
		my $p = $podInfo->{$n}->{htmlfile};
		if ($p)
		{
			$p =~ s#\Q$sitedir\E.##;
			$p = slashify($p, '/');
			$$ref .= qq(<a href="$p" target="main_frame">$np</a>);
		}
		else
		{
			$$ref .= qq($np);
		}
		$$ref .= ($hasSubNodes ? qq(</summary>) : qq(</div>));
		$$ref .= "\n";
	}
	
	foreach my $subnp (sort { lc($a) cmp lc($b) } (keys(%$treeloc)))
	{
		my $subn = "$r$subnp";
		
		$depth++;
		$self->_genRefs($sitedir, $ref, $podInfo, $treeloc->{$subnp}, $depth, $subn, $subnp);
		$depth--;
	}
	
	if ($n)
	{
		$$ref .= qq(</details>\n) if $hasSubNodes;
	}
}

sub _rewriteCss
{
	my $self = shift;
	my $args = shift;

	my $tocrules = <<TOCTOPRULES;
summary.toc-top
{
	font-weight: bolder;
}

TOCTOPRULES

	for my $num (0 .. $self->{maxtocdepth})
	{
		my $sumem = $num + 1;
		my $divem = $num + 2;
		$tocrules .= <<TOCNUMRULES;
summary.toc-$num
{
	font-size: small;
	margin-left: ${sumem}em;
}

div.toc-$num
{
	font-size: small;
	margin-left: ${divem}em;
}

TOCNUMRULES
	}

	my $sitedir = $args->getSiteDir();
	my $sbName = $self->getStyleName();
	my $sbCssFile = slashify("$sitedir/$sbName.css");
	my $cssContent = readUTF8File($sbCssFile);
	writeUTF8File($sbCssFile, "$cssContent\n$tocrules"); 	
}

1;



( run in 0.918 second using v1.01-cache-2.11-cpan-5a3173703d6 )