[pmwiki-users] Default styling of links to non-existent pages

Patrick R. Michaud pmichaud at pobox.com
Sat Jan 28 10:03:18 CST 2006


On Sat, Jan 28, 2006 at 11:34:53AM +0100, christian.ridderstrom at gmail.com wrote:
> On Fri, 27 Jan 2006, Patrick R. Michaud wrote:
> 
> > On Fri, Jan 27, 2006 at 11:10:21PM +0100, christian.ridderstrom at gmail.com wrote:
> > > On Fri, 27 Jan 2006, Patrick R. Michaud wrote:
> > > 
> > > > 5+:  $IMapLinkFmt['http:']     http: links
> > > >      $IMapLinkFmt['https:']    https: links
> > > >      $IMapLinkFmt['PmWiki:']   links to PmWiki: InterMap shortcut
> > > >      $IMapLinkFmt['Cookbook:'] links to Cookbook: InterMap shortcut
> > > 
> > > Would it be possible to replace the format string with a hook if so
> > > desired?  Perhaps I could then use that for my 'uploads:'-links (see my
> > > other rather long post). The hook function that I supply would then check
> > > if the uploaded file exists, and return either a customized format string,
> > > or simply the relevant HTML depending on this condition.
> > 
> > There's already a hook -- that's what the $LinkFunctions array does. :-)
> 
> Yes, I know about that hook, but the solution feels a bit crude to me. In
> order to use it, I will have to override the entire function for an entire
> class of links, while I just might want to do something for some of the
> links. This is more of a gut feeling righ now than a concrete reason
> though...

If I'm understanding you correctly, they're exactly equivalent.
You were asking about the possibility of having $IMapLinkFmt['uploads:']
be a hook.  $LinkFunctions['uploads:'] is that hook, and it affects
exactly the same class of links -- all links beginning with 'uploads:'.

Put another way, even if $IMapLinkFmt['uploads:'] is a hook, the
hook function would end up looking almost exactly like the function
needed for $LinkFunctions['uploads:'].  So, it's best to skip the
indirection entirely and just use $LinkFunctions['uploads'].

> Btw, I assume that '<:page>' stands for handling normal links such as
> [[SomePage]]?  (This info about $LinkFunctions and link handling should be
> documented somewhere on PmWiki I think).

Yes.

> Maybe this is an example... if I'd like to treat and/or format links going
> to (http/https/ftp)://*.lyx.org in a special manner, I'd have to replace
> the corresponding entries in $LinkFunctions with my own hook. 
> 
> I could now let the hook implement the funcionality of LinkHTTP()  and
> LinkIMap(), or I could let the hook modify the arguments and then invoke 
> either LinkHTTP() or LinkIMap() depending on the type of link.

The latter is generally easier -- that's essentially what the urlapprove
and uploads scripts do now.  They do special handling of link
arguments, and then call the appropriate function afterwards.

Pm




More information about the pmwiki-users mailing list