NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item11383 for general documentation changes for release 1.1.5. Use Item9693 for docu changes for release 2.0.

Item8425: MailerContrib creates bad links for TOC

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal New Extension MailerContrib  
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

 

ItemTemplate edit

Summary MailerContrib creates bad links for TOC
ReportedBy ChristianZiemski
Codebase 1.0.9
SVN Range
AppliesTo Extension
Component MailerContrib
Priority Normal
CurrentState New
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn
Topic revision: r3 - 27 Jan 2010 - 09:22:45 - ChristianZiemski
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads