[pmwiki-users] Getting an URL from a cookbook recipe
Dominique Faure
dominique.faure at gmail.com
Wed Jan 25 10:13:36 CST 2006
2006/1/25, Dominique Faure <dominique.faure at gmail.com>:
> 2006/1/25, Patrick R. Michaud <pmichaud at pobox.com>:
> > On Wed, Jan 25, 2006 at 04:17:42PM +0100, Dominique Faure wrote:
> > > I often need to catch urls from cookbook recipe's markup extensions,
> > > whatever form it could have (according to PmWiki syntax). For now, the
> > > easiest way I found to do that was to "regexp" clean the MakeLink
> > > function output:
> > >
> > > Markup('mymarkup', 'directives',
> > > "/\\(:mymarkup\\s+(.*)\\s*:\\)/e",
> > > "MyMarkupFunc(\$pagename, PSS('$1'))");
> > >
> > > function MyMarkupFunc($pagename, $target) {
> > > $link = preg_replace("/.*href='([^']+)'.*/", '\1',
> > > MakeLink($pagename, $target, ''));
> > >
> > > # ...
> > > }
> > >
> > > This working solution has several drawbacks, as for example not
> > > allowing to know if the given url needs approbation or not.
> > >
> > > Any better idea would be appreciated.
> >
> > I think I need a fuller description of what you're trying to
> > accomplish -- perhaps a more concrete example.
> >
>
> As a concrete example you may refer to the
> http://www.pmwiki.org/wiki/Cookbook/PTViewer recipe which take a
> file=... parameter. This param should allow all PmWiki standards to
> refer to an image file. In fact, the problem arise everywhere you want
> to address external resources.
>
An almost better attempt (now I catch unapproved urls), but still
relying on generated html:
function MyMarkupFunc($pagename, $target) {
$link = MakeLink($pagename, $target);
preg_match("/.*class='([^']+)'.*href='([^']+)'.*/", $link, $m);
if($m[1] == 'apprlink') return Keep($m[0]);
$link = $m[2];
# ...
}
More information about the pmwiki-users
mailing list