Item8425: MailerContrib creates bad links for TOC
Priority: Normal
Current State: New
Released In:
Target Release: n/a
I'm using
MailerContrib for sending topics as newsletter (complete content).
It is working fine with one exception:
If there is a Table-of-contents (%TOC%) in a topic the links created by
MailerContrib representing its items are broken:
<a href="http://some.server.com/foswiki/bin#Topic1"> Topic1</a>
But it should be:
1)
<a href="http://some.server.com/foswiki/bin/view/MYWEB/TestPage#Topic1" Topic1</a>
or perhaps even better:
2)
<a href="#Topic1"> Topic1 </a>
#1 could be done with the following change in
MailerContrib.pm:
# Rewrite absolute URLs
#my $base = $Foswiki::cfg{DefaultUrlHost} . $Foswiki::cfg{ScriptUrlPath};
my $base = $Foswiki::cfg{DefaultUrlHost} . $Foswiki::cfg{ScriptUrlPath} . "/view/" . $web . "/" . $topic; # cz
$tmpl =~ s/(href=\")([^"]+)/$1.relativeURL($base,$2)/goei;
At least that works for me ...
Christian
--
ChristianZiemski - 26 Jan 2010
Now I found a way to make #2 work as well.
I added an if() in
MailerContrib.pm here:
sub relativeURL {
my ( $base, $link ) = @_;
if ( ! $link =~ "^#" ) {
return URI->new_abs( $link, URI->new($base) )->as_string;
} else {
return $link
}
}
--
ChristianZiemski - 27 Jan 2010