Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » [Archived] bit_rss

#1 2006-06-10 12:31:32

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

[Archived] bit_rss

bit_rss

bit_rss is an RSS parser plugin that takes RSS feeds and outputs them as TxP articles.

bit_rss v0.4.1 uses SimplePie 1.0 b3.2 which includes support for IDN.
(The IDN class has been appended to the simplepie include file.)

This plugin began as a modified version of tcm_rss by Tom McWright.

Download it here.
Just in case, you can still get v0.3 here.

Comments and suggestions are very welcome. :-)

Installation

After installing the plugin itself, you’re going to have to upload simplepie.inc and npdata.ser to your web server. The plugin will look for it in /path_to_txp/lib/, but you can place it anywhere the web server can get to and declare its location in the tag itself. That should be pretty much it. :-)

Tags

bit_rss provides the following tags:

<txp:bit_rss />
bit_rss can accept a comma-delimited list of feed URLs. All feed items from all of the selected feeds will be output as one list of items and sorted in proper order accdg. to the posted date of each item.

Attributes:

feed
Comma-delimited list of URLs of the feeds to be used
Example: feed='http:/bitdesigns.net/blog/atom'

simplepie (optional)
Absolute path to the SimplePie class file (simplepie.inc).
Default: $txpcfg['txpath'].'/lib/simplepie.inc'
Example: simplepie='/var/www/httpdocs/textpattern/lib/simplepie.inc'

caching (optional)
Whether caching is enabled or not.
Caching is disabled if it is set to false, no, or 0.
Default: true

cache_dir (optional)
Absolute path to the SimplePie cache directory. This directory must be writeable.
Default: $txpcfg['txpath'].'/tmp'
Example: simplepie='/var/www/httpdocs/textpattern/tmp'

cache_time (optional)
The length of time (in minutes) that the cache files are stored before being refreshed.
Default: 60

strip_html (optional)
SimplePie strips potentially dangerous/annoying tags by default.
The list of tags to be stripped can be changed by setting this attribute to a comma-delimited list of HTML tags.
Default: 'base, blink, body, doctype, embed, font, form, frame, frameset, html, iframe, input, marquee, meta, noscript, object, param, script, style'

strip_atts (optional)
SimplePie strips potentially dangerous/annoying attributes by default.
The list of attributes to be stripped can be changed by setting this attribute to a comma-delimited list of HTML attributes.
Default: 'bgsound, class, expr, id, style, onclick, onfinish, onmouseover, onmouseout, onfocus, onblur'

encode_html (optional)
Sets whether or not to encode the HTML tags instead of stripping them
HTML tags will be encoded when this is set to '1', 'true', or 'yes'.
Default: '0'

strip_ads (optional)
Sets whether or not to certain strip ads from the feed items.
Ads will be stripped when this is set to '1', 'true', or 'yes'.
Default: '0'

remove_div (optional)
Accdg. to the SimplePie docs, “Some feeds (such as from tantek.com) contain &lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;XHTML Content Goes Here&lt;/div&gt;.
This can cause XHTML validation errors…”
This attribute allows you to strip that div out.
The aforementioned div will be stripped when this is set to '1', 'true', or 'yes'.
Default: '0'

replace_headers (optional)
Some feed items will contain heading (h#) tags and will mess up your HTML code.
These heading tags will be replaced with a more friendly h4 tag when this is set to '1', 'true', or 'yes'.
Default: '0'

form (optional)
Form to be used to display each item in the feed.
The article tags, <txp:title />, <txp:posted />, <txp:body />, and <txp:permlink /> will work normally in the form used. <txp:category1 />, and <txp:category2 /> will also function normally with appropriate feeds.
Default: 'rss'

limit (optional)
Maximum number of items to fetch.
Default: number of items in the feed

offset (optional)
Number of entries to skip.
Default: 0

order (optional)
Order of items based on date. asc (ascending – oldest first) or desc (descending – newest first).
Default: desc

emptymsg (optional)
The text to output if no feed items were retrieved.
Default: No feed items could be found.

<txp:bit_author />
This tag replaces the <txp:author /> tag in the article forms that will be used by bit_rss. This is a workaround for the way TxP handles author names. The ‘link’ attribute of the original author-tag will have no effect in this tag.

<txp:bit_feed_title />
Article form tag. This tag outputs the title of the parent feed of the item.
Example: <txp:bit_feed_title />

<txp:bit_feed_link />
Article form tag. This tag outputs the link of the parent feed of the item. It can be used as a container tag or as a single tag. Its attributes are exactly like the attributes of permlink except for the title attribute – the title attribute of the resulting link will be the feed title by default.
Example 1: <txp:bit_feed_link />
Example 2: <txp:bit_feed_link><txp:bit_feed_title /></txp:bit_feed_link>

Important Notes

  • Although caching is optional, it is highly recommended that you enable caching especially if you use bit_rss to parse multiple feeds and/or you plan to use bit_rss on a high-traffic page. The item sorting algorithm and the parsing itself is as efficient as it can be but it is still relatively intensive.
  • If you intend to use bit_rss to parse multiple feeds, do not include feeds that do not have item publish dates because the resulting order of the posts rely on the date of publication of each item. It won’t result in any errors but your feed items without any dates won’t appear in its “proper” place in the item order.
  • Because of the different feed formats out there, an excerpt won’t always be available and therefore this plugin doesn’t support using the <txp:excerpt /> tag in its article form. It has been reported though that bit_rss will play nice with rss_auto_excerpt if you need excerpts.
  • If you experience any problems with parsing a particular feed, please try using the SimplePie demo to read your feed. There are really three possible breaking points with this plugin – the feed (a lot of feeds are not properly formatted), the SimplePie parsing engine (best parser, IMHO, but not 100% perfect), and the plugin itself.

Changelog

v0.4.1
+ Fixed item output
+ Added several SimplePie configuration settings as attributes

v0.4
+ Updated included SimplePie class to 1.0 b2.3
+ Added bit_feed_link and bit_feed_title tags

v.0.3
+ Added ability to handle multiple feeds

v0.2.3
+ Fixed limit attribute
+ Added offset attribute

v0.2.2
+ A bit more efficient with iterating through each item
+ Addition of the caching attribute

v0.2.1
+ RSS 0.9×-1.x feeds will be displayed in proper order by default
+ Addition of the <txp:bit_author /> tag to replace <txp:author /> in the article forms for this plugin

v0.2
+ Updated for latest version of Simplepie
+ Added order attribute, partly to temporarly fix the dateless feeds problem.

v0.1
+ First one

Last edited by bit (2007-03-13 11:43:58)


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

#2 2006-06-10 14:03:20

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: [Archived] bit_rss

I try this but it don’t work :

< txp:bit_rss feed=‘http://annuaire-algerie.douar.net/rss.php’ limit=‘5’ / >

I put the form rss (an article form) like this :

< p >< txp:permlink >< txp:title >< /txp:permlink >< br / >
< txp:body >< /p >

I put simplepie.inc in lib directory of txp!

Is there something wrong!

NB: After some try I disable the plugin it cause a fatal error from txp (evaldate() fonction)!!

Last edited by Dragondz (2006-06-10 14:36:22)

Offline

#3 2006-06-10 17:58:45

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

Re: [Archived] bit_rss

OK. I tinkered and found that I had built the plugin around an older version of Simplepie but the Simplepie file I included was the latest. The functions I was using are already deprecated in the latest version. I’ve rewritten the appropriate parts so now it should work.

In the process of testing, I also found the bug involving dateless feeds. Simplepie attempts to sort all feeds by date in reverse, but when it processes a dateless feed, the feed items are output with the oldest first. I’ve added an order attribute to temporarily fix that. It’ll accept asc (oldest first) or desc (newest first) and default to desc.

Download v0.2 here.

Last edited by dreamstormer (2006-06-10 18:58:42)


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

#4 2006-06-11 02:56:48

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: [Archived] bit_rss

OK, everything is working fine except I get one error rendered at the top of the page:

<code>tag_error <txp:bit_rss feed=“http://www.graphicpush.com/feed.xml” limit=“3” form=“rss” order=“asc” /> -> Warning: Missing argument 1 for get_author() on line 2837</code>

The actual links appear on the page, and for all intensive purposes, the plugin works. Any clues?


Kevin
(graphicpush)

Offline

#5 2006-06-11 03:35:17

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: [Archived] bit_rss

OK, I simply took the offending code out and it seems to work just fine: you can see it in action


Kevin
(graphicpush)

Offline

#6 2006-06-11 05:58:46

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

Re: [Archived] bit_rss

I found what was wrong. If you don’t mind going into the code of the plugin, you just need to look for all instances of $item->get_author() and replace them with $item->get_author(0). (There should only be two instances on two consecutive lines.)

I’ve also moved the plugin files (with this bug fixed) to a permanent location here.

The current limitation for the author though would now be that you can’t retrieve more than the first author. Although I think I can easily fix this when I get the time.


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

#7 2006-06-11 08:21:23

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: [Archived] bit_rss

Hi dream,

The plugin work now, but not with all feed, I tried it with a textpattern feed and it works fine, but with another feed : http://annuaire-algerie.douar.net/rss.php, it doesn’t work, but this feed is correctly readed by FireFox 1.5!!

When i dispaly the two feeds (from txp and the second) in the browser there are different, but both are fetched correctly by FireFox rss reader! any idea?

PS: Thanks a lot for this plugin dream

Offline

#8 2006-06-11 09:04:52

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

Re: [Archived] bit_rss

I’m still reading up on the various RSS feeds. So many to have to support. :-P

And I tried opening http://annuaire-algerie.douar.net/rss.php in SimplePie’s demo reader on their site and it also returned an error. It unfortunately seems like your feed in particular isn’t supported by SimplePie. :-(

I’m not completely familiar with RSS 2.0, but you might have to tweak your XML output to make it work. If anyone else has any ideas, feel free to speak up. :-)

And just for future reference for everyone, it’d probably be wise to test the feeds you intend to use with bit_rss at the SimplePie demo page just to find out if the parser will work with the feed.


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

#9 2006-06-11 09:10:37

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: [Archived] bit_rss

I will try to change the rss creator of the feed to make it readable by the pluggin, i will let you know if i solved it!!

Thanks

I finally resolve the pb by changing the code generating the feed and now it works nice!!

Thanks a lot for this good job!

Last edited by Dragondz (2006-06-11 11:53:34)

Offline

#10 2006-06-11 13:11:44

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

Re: [Archived] bit_rss

Thanks dude!
Just keep posting bugs and/or suggestions.
This is my first plugin so I’d like to make sure that I get it right. Hehe.


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

#11 2006-06-12 09:31:27

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,536
Website GitHub Twitter

Re: [Archived] bit_rss

Hi dream,

I thinked for a possible improvement of the plugin is the possibility to make an excerp of the body with an optional tag like : excerp="100" wich display only the 100th first caracteres! is it a good idea?

If you wanna see the result of using your plugin look at this url (look at red rectangle writed with white)!

A+

Offline

#12 2006-06-13 11:24:42

bit
Archived Plugin Author
From: Philippines
Registered: 2005-02-14
Posts: 65
Website

Re: [Archived] bit_rss

I believe there’s an plugin that can replace the <txp:body /> tag with one with which you can specify the number of characters printed out. Pretty sure it’d be compatible, if you really need it.

Personally, I don’t feel like it’s a clean way of creating excerpts. To each his own.

Last edited by dreamstormer (2006-06-15 03:09:12)


“The neighboring marshmallow factory fared no better, having been unable to absorb the incredible pressure wave.”

Offline

  1. Index
  2. » Archives
  3. » [Archived] bit_rss

Board footer

Powered by FluxBB