[Pmwiki-users] Re: Embedding Javascript?

Patrick R. Michaud pmichaud
Sat Dec 11 13:51:53 CST 2004


On Sat, Dec 11, 2004 at 08:51:46AM -0900, Chris Lott wrote:
> I need to be able to specify the name of the feed... and there are
> actually a couple of other options that could be specified as well...
> 
> (:rssfeed:) would be great. I tried adapting a script from the ver1
> cookbook, but it doesn't seem to work with pmwiki2 and I'm not
> familiar enough with PmWiki (yet) to figure it out...

See if http://www.pmwiki.org/wiki/Test/JSFeed does what you want.

The basic markup is (:rssfeed http://... :), although I 
set it up so that (:rssfeed src=http://... :) also works in case
someone is used to entering src.  Any options are just placed at
the end, as in

    (:rssfeed http://... num=10 date=y html=a :)

The code to enable this is below (add to a local customization
file).  Enjoy!

Pm

<?php

function RSSFeed($src, $opt) {
  $opt = preg_split('/\\s+/', $opt, PREG_SPLIT_NO_EMPTY);
  $src = urlencode($src);
  $ref = "http://jade.mcli.dist.maricopa.edu/feed/feed2js.php?src=$src";
  if ($opt) { $ref .= '&' . join('&', $opt); }
  return "<script language='JavaScript' src='$ref'></script>
    <noscript><a href='$ref'>View RSS feed</a></noscript>";
}

Markup('rssfeed', 'directives',
  '/\\(:rssfeed\\s*(src=)?(\\S+)\\s*(.*?):\\)/e',
  "Keep(RSSFeed('$2', '$3'))");

?>




More information about the pmwiki-users mailing list