Item8425: MailerContrib creates bad links for TOC

pencil
Priority: Normal
Current State: New
Released In:
Target Release: n/a
Applies To: Extension
Component: MailerContrib
Branches:
Reported By: ChristianZiemski
Waiting For:
Last Change By: ChristianZiemski
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, ChristianZiemski - This page was cached on 26 Jun 2016 - 10:22.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License