[dokuwiki] Re: me and feedparsing - next question

  • From: Werner Flamme <werner.flamme@xxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 03 Feb 2009 10:27:43 +0100

Andreas Gohr [02.02.2009 22:16]:
>> I rewrote the plugin mentioned in my last mail and wrote a new one
>> including SimplePie.php. Works great, only that I want the Dilbert daily
>> cartoon now, and feedburner dislikes SimplePie... Took a while until I
>> got it working, but it runs nearly fine now.
> 
> First of all, you are aware of http://www.dokuwiki.org/plugin:dil, right?

No, I was not. I'm just experimenting...

Now I am...

> 
> Now let's see.
> 
> 1) Don't use SimplePie directly but use the FeedParser wrapper:
> 
> require_once(DOKU_INC.'inc/FeedParser.php');
> $feed = new FeedParser();
> $feed->set_feed_url($url);
>
> It ensures DokuWiki's HTTPClient is used which itself make use of the
> correct proxy settings.

plugin:dil uses 'inc/HTTPClient.php' ;-) ...
Obviously I took "Hint: use the SimplePie library shipped with DokuWiki
to parse the feed." from your last mail wrong :-( And from the
plugin:dil page I learned that I may not use
http://feeds.feedburner.com/DilbertDailyStrip but
http://feedproxy.google.com/DilbertDailyStrip as URL for the feed (since
feedburner refuses feeds to user agent 'SimplePie', that's why I
introduced another user agent string).

> 2) $item->get_permalink() returns a link to the Website the cartoon is
> displayed on. Not the image address. You probably want to parse the
> IMG src attribute from the item description.

OK. I'll work along
<http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes> -
this should work since FeedParser.php is a wrapper around SimplePie.

> 3) 
> '[[http://dilbert.com/|{{http://feedproxy.google.com/~r/DilbertDailyStrip/~3/3Ds_eCGi5XM/}}]]'.
> will not be recognized as image even if it would be an image. See
> http://www.dokuwiki.org/images#dynamic_images

I see that I have to append '&.gif?' (or similar), if the picture file
extension is not the last part of the URL. Frank Thommen had the same
problem just a week ago on this list :-(

> 4) passing DokuWiki syntax to a new  p_render() call is very expensive
> and shouldn't be done except absolutely necessary. Call
> $renderer->externalmedia() instead.

Yes, it is expensive, I noticed the long runtime. And again I learn a
new internal of DW... plugin:dil puzzles together the link manually,
that's what I tried with my last attempt, but I want to be more flexible...

So it would be
$renderer->externalmedia($src,$title,$align,$width,$height,$cache) where
$title is constructed as described on
<http://www.dokuwiki.org/devel:parser> at function externalmedialink
(which is an empty function in renderer.php and does not occur in
xhtml.php).

@Andi W.: yes, normally I do not "believe" other web sites. I will use
hsc(), it has less letters ;-)

Thank you! I'll try soon!

Regards,
Werner
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: