[pmwiki-users] Getting an URL from a cookbook recipe

Patrick R. Michaud pmichaud at pobox.com
Thu Jan 26 07:37:50 CST 2006


On Thu, Jan 26, 2006 at 02:22:36AM +0100, christian.ridderstrom at gmail.com wrote:
> On Wed, 25 Jan 2006, Patrick R. Michaud wrote:
> >     MakeLink($pagename, "SomePage")
> >       returns  "<a href='.../Group/SomePage'>SomePage</a>"
> 
> What about $suffix, is that simply:
> 
>      MakeLink($pagename, "some page", "other text", "-suffix")
>        returns  "<a href='.../Group/SomePage'>other text-suffix</a>"

Yes, although suffix is normally used when there's no link text,
so that we get

    MakeLink($pagename, "install(ation)", NULL, "ed")
      returns  "<a href='.../Group/Installation'>installed</a>"

> and perhaps you can give an example for $fmt. Here's a guess:
> 
>      MakeLink($pagename, "SomePage", '', '',
> 	      "<a href='.../\$LinkUrl'>\$LinkText</a>")
>        returns  "<a href='.../Group/SomePage'>SomePage</a>"

Yes.  Another example for format is $ImgTagFmt:

   MakeLink($pagename, "Attach:foo.gif", '', '', $ImgTagFmt)
     returns "<img src='.../uploads/foo.gif' alt='' />";

> I think the documentation of MakeLink() is almost done. Next time I'll ask 
> you about LinkIMap() and LinkUpload() I think :-)

I'll start with LinkIMap().

LinkIMap() simply handles links of the form scheme:path, which includes
http:, https:, ftp:, as well as the InterMap links like Cookbook:, PmWiki:,
etc.

The primary array used by LinkIMap() is the $IMap array, it says how
to format a url according to the given scheme.  By default, this is
generally set to

    $IMap['http:'] = 'http:$1';
    $IMap['https:'] = 'https:$1';
    $IMap['ftp:'] = 'ftp:$1';
    $IMap['mailto:'] = 'mailto:$1';
    ...
    $IMap['Cookbook:'] = 'http://www.pmwiki.org/wiki/Cookbook/$1';
    $IMap['PmWiki:'] = 'http://www.pmwiki.org/wiki/PmWiki/$1';
    $IMap['Wikipedia:'] = 'http://www.wikipedia.com/wiki/$1';

The $1 in each case indicates where the path component is supposed
to be placed.

LinkIMap() then uses the value of $UrlLinkFmt to generate the link;
it defaults to:

   "<a class='urllink' href='\$LinkUrl' rel='nofollow'>\$LinkText</a>"

There's also an $IMapLinkFmt array that allows each scheme to have
its own custom formatting default, but AFAICT PmWiki isn't using this
capability yet (although I think some recipes may be doing so).

Pm




More information about the pmwiki-users mailing list