Apache-MiniWiki

 view release on metacpan or  search on metacpan

MiniWiki.pm  view on Meta::CPAN

		<br/><br/>
		|;
  }

  foreach my $rawname (@sorted_files) {
    $rawname =~ s/,v$//;
    $rawname = &uri_to_filename($rawname);
    next if ($rawname eq "template" or $rawname =~ /^template-/i);
	my $title;
	if (&is_binary($rawname)) {
		$title = $rawname;
	} else {
		$title = &get_page_title($rawname);
	}
	my $a_id = "aa" . encode_entities($rawname); # must start with a letter
	$a_id =~ s/(\.| )//g; # could result in some dups but that's ok, we need good Id's
	$title = encode_entities($title);
    $linklist .= qq|<a id="$a_id">$title</a>: <a href="$vroot/$rawname">view page</a>|;
	if ($do_externals && !&is_binary($rawname)) {
		open(IN, '<', "${datadir}/${rawname}");
		my $text = join("", <IN>);
		close IN;

		# $r->log_error("doing $rawname");

		my $htmltext = &prettify($text);
		my $newtext = &render($htmltext);

		my $spanhtml = "";
		my $spanlinks = 0;

		$parser->parse($newtext);
		$total_bytes += length($newtext);

		my (@links) = $parser->links;
		my $ul_id = "links_${rawname}";
		$ul_id =~ s/(\.| )//g; 
		$spanhtml .= qq|<ul id="$ul_id" style="display:none">\n|;
		foreach my $link (@links) {
			my $href = $link->[2];
			next if ($href =~ /\(edit\)|template-/i or $href eq "${vroot}/template");
			next if ($href eq "http://"); # not real
			if ($href =~ /^${vroot}/) {
				next if (!-f &strip_virtual($href));
				$href = "#" . &strip_virtual($href);
				$total_in++;
			} else {
				# encode ?, &, etc for XHTML1.1 validator
				$href = &encode_entities($href);
				$total_out++;
			}
			$spanlinks++;
			my $display = $href;
			if (length($display) > 80) {
				$display = substr($display, 0, 80) . "...";
			}
			$spanhtml .= qq|<li><a onClick="checkInLink(this)" href="$href">$display</a></li>\n|;
		}
		$spanhtml .= qq|</ul>|;

		$linklist .= qq|,&nbsp;<a name="expand_link" href="javascript:void(0)" onClick="expand(this, '$ul_id')">view links ($spanlinks)</a><br/>\n|;
		$linklist .= $spanhtml;
		$parser->eof();
	} else {
		$linklist .= "<br/>\n";
	}

  }

  if ($do_externals) {
	$linklist .= "<br/><hr/>$total_in inside links, $total_out outside links, for a total of $total_bytes bytes of rendered body html.<br/>";
	$linklist .= qq|
		Links: <a href="javascript:showAllLinks()">Expand All</a>, 
		<a href="javascript:hideAllLinks()">Collapse All</a>
		|;
  }
  
  return $linklist;
}

# This function lists all the external http links on the site, 
# grouped by page title
sub get_listlinks {
  my ($r) = @_;

  return &get_list($r, 1);
}

# obtain the title of the page, which should be the
# first line of the page normally.
# Only do this if it is a text file. For binary files,
# the filename will be used.
sub get_page_title {
	my ($page) = @_;

	my $title;
	if (-T $page and !is_binary($page)) {
		open (FILE, "< $datadir/$page") || return $page;
		while ($title = (<FILE>)) {
			last if ($title);
		}
		close (FILE);
	}

	$title || $page;
}

# This function does up a pretty list of all the changes in the
# Wiki, and returns the HTML for it.
# Does checks for ?maxdays=x&maxpages=y
sub get_listchanges {
	my $r = shift;

	my %args = $r->args;

	$args{maxpages} ||= 0;
	$args{maxdays} ||= 0;

	if ($args{maxpages} !~ /^([\d]+)$/) {
		$args{maxpages} = 0;
	}



( run in 1.803 second using v1.01-cache-2.11-cpan-97f6503c9c8 )