RSS Feed Generation Help Needed

Archive of notes and cross input on Dev versions of Coranto (1.25.1 and Older)

Moderators: Dale Ray, SrNupsen, Bluetooth, Jackanape

RSS Feed Generation Help Needed

Postby PPNSteve » Thu Mar 11, 2004 6:04 pm

Hi! I currently am using NP 3.8 with some minor mods and a lot of addons Yes i'm quite happy with it, anyway I NEED to generate a rss feed so other can use my news (syndicate) on their site(s)

I've search high and low for a addon to do this, but no luck.. So my request is one of 2 things:
a) Can any of you point me in the right direction to get what I need?
b) How hard would it be to modify the RSS File Beta Build 4 addon for coranto to work with NP3.8? Whats needed, vars, calls, etc...

Can anyone help?
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Netcenter Channel 1.01 ??

Postby PPNSteve » Mon Jun 07, 2004 11:57 am

anyone have this addon? i can't find it anywhere.. Please help out..

OR

Can/has anyone done a modification for NP3.8 to generate a rss feed?

Come on you all.. help a guy out here...
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby LeandroTLZ » Mon Oct 04, 2004 9:43 am

This is reviving an old topic, but I just made such an addon. It generates very basic RSS, but that's just what I want; strips HTML off the newssubject and newstext, displays the last 10 updates (configurable) and cuts the actual newstext length to 100 characters (not cutting words in the middle).

http://www.futurama-madhouse.com.ar/~leandro/npa_rss.pl

I'm no pro with Perl, but it does the job. Suggestions and updates welcome.
[url=http://www.futurama-madhouse.com.ar]Image
Futurama Madhouse[/url]
LeandroTLZ
 
Posts: 2
Joined: Mon Oct 04, 2004 9:34 am

Postby PPNSteve » Mon Oct 04, 2004 2:10 pm

awesome.. thanks for the reply.. will let u know how it works out!

Edit: WOW, thanks for this. it's working out great! many, MANY thanks again for posting this.. (i also am no good at perl/cgi) this is a life saver.. and with a few minor edits.. it even valiadates!!

Mods:
line 16 change to:
Code: Select all
  print RSSFEED "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n <rss version=\"0.91\">\n  <channel>\n    <title>$RSS_Title</title>\n";

/Edit

thanks again!
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby LeandroTLZ » Wed Oct 06, 2004 9:21 am

PPNSteve wrote:and with a few minor edits.. it even valiadates!!


Gomen, the URL I pointed you to and the version I use in my site are different, that's why the one you downloaded didn't validate (I posted after my own RSS feed validated, made with the other version). Also, the version in my site includes the <pubDate> tags, so every item in the RSS feed has the date and time you posted it in NewsPro, which is lacking in the version you have; and lastly, I fixed the regular expressions that strips the HTML tags from the article So I recommend you get this "new" version instead (it's in the same URL, says v1.1 to avoid confusion). The "v1.0" you have is actually incomplete :P

If you want to post entire articles to the RSS feed instead of just the first 100 chars, delete the two lines:

Code: Select all
      $RSS_NewsText = substr($RSS_NewsText,0,100);
      $RSS_NewsText =~ s/\ [!-~]*$//;


and remove the three dots before </description>. The first line's meaning is obvious; the second one cuts the string at the last space (to avoid cutting a word in half at the end of the article "summary").
[url=http://www.futurama-madhouse.com.ar]Image
Futurama Madhouse[/url]
LeandroTLZ
 
Posts: 2
Joined: Mon Oct 04, 2004 9:34 am

Postby PPNSteve » Wed Oct 06, 2004 12:52 pm

Yeah i had to redo the regex cause it was locking up newspro on building.. but it's all good.

Thanks, like the post date idea, i've switched to the new version and it's also working well..

i thank you once again..
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby northward » Thu Sep 01, 2005 5:28 pm

This is exactly what I've been searching for. The link posted above to npa_rss.pl however is dead. Does anyone have this add-on available?

Thanks in advance!
northward
 
Posts: 5
Joined: Thu Sep 01, 2005 5:27 pm

Postby PPNSteve » Thu Sep 01, 2005 6:47 pm

Ok here is the file for others to use... We've made minor mods to improve it's performance and standards.

Code: Select all
push(@Addons_Loaded, 'RSS Addon');
push(@Addons_BuildNews_PreLoop, 'RSS_Open');
push(@Addons_BuildNews_1, 'RSS_Build');
push(@Addons_BuildNews_Post, 'RSS_Close');
$Addons_List{'RSS Addon v1.14'} = ['npa_rss4.pl', 'Publishes the main page news as an RSS feed. Made by <a href="mailto:leandro@futurama-madhouse.com.ar">Leandro</a>. Modified by <a href="http://johnslone.org" class="" target="_blank">JDS</a> for <a href="http://pokemonpalace.net" class="" target="_blank">PPN</a>.', ''];

#set the full path, title, links and details for the rss feed page we're to generate
$RSS_File = '/home/user/public_html/my_news.xml';
$RSS_Title = 'Site News';
$RSS_Link = 'http://your_domain.com/index.php';
$RSS_Desc = 'Your Daily News';
$RSS_Lang = 'en-US';
$RSS_MaxItems = 10;

#do not modify anything below
sub RSS_Open {
   open (RSSFEED,">$RSS_File");
   print RSSFEED "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n <rss version=\"2.00\">\n  <channel>\n    <title>$RSS_Title</title>\n";
   print RSSFEED "    <link>$RSS_Link</link>\n    <description>$RSS_Desc</description>\n";
   print RSSFEED "    <language>$RSS_Lang</language>\n";
   $RSS_ItemCount = 0;
}

sub RSS_Build {
   if ($RSS_ItemCount < $RSS_MaxItems) {
      $RSS_NewsText = $newssubject;
      while ($RSS_NewsText =~ /[\<\>]/) {
        $RSS_NewsText =~ s/\<[ -\;\?-\~\=]+\>//;
      }
      print RSSFEED "    <item>\n      <title>$RSS_NewsText</title>\n";
      print RSSFEED "      <link>$RSS_Link\#$newsid</link>\n      <description>";
      $RSS_NewsText = $newstext;

      $RSS_NewsText =~ s/(<\/?)(\w+)([^>]*>)/\3/g;
         $RSS_NewsText =~ s/>//g;
      $RSS_NewsText = substr($RSS_NewsText,0,100);
      $RSS_NewsText =~ s/\ [!-~]*$//;
      print RSSFEED $RSS_NewsText;
         
         $RSS_NewsText = $newsid;
      $RSS_NewsText =~ s/^([0-9]+).*$/$1/;
      $RSS_NewsText = gmtime($RSS_NewsText);
      $RSS_NewsText =~ s/^(...) (...) (..) (........) (....)$/$1, $3 $2 $5 $4/;
      print RSSFEED "...</description>\n<pubDate>$RSS_NewsText GMT</pubDate>\n    </item>\n";
      $RSS_ItemCount++;
   }
}

sub RSS_Close {
   print RSSFEED "  </channel>\n</rss>\n";
   close(RSSFEED);
}

1;


Remember to change the settings in
Code: Select all
#set the full path, title, links and details for the rss feed page we're to generate
$RSS_File = '/home/user/public_html/my_news.xml';
$RSS_Title = 'Site News';
$RSS_Link = 'http://your_domain.com/index.php';
$RSS_Desc = 'Your Daily News';
$RSS_Lang = 'en-US';
$RSS_MaxItems = 10;
to reflect your server paths and site info.
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby northward » Thu Sep 01, 2005 10:22 pm

Well, if anyone has stronger Perl skills than I do...
(Who am I kidding? All of you have stronger Perl skills than I do!)

I've been pulling my hair out for hours now. The problems I'm having seem to revolve around the fact that our site displays headlines to each story on its own separate page, whereas this script appears to be designed for those with all of the stories on one page and this generates an XML file with headlines linked to anchors on that page. For example, our story page URLs are generated by the DoHeadlineHTML sub in ndisplay.pl per this format:

<li><a href="http://www.FirstTracksOnline.com/news/stories/$hqid.shtm">$newssubject</a> - from $uservar2 <i>$uservar1</i> - $newsdate</ul>

I don't care much about $uservar2 or $uservar1, or even $newsdate for that matter. I'd just like the XML output of the links to follow the http://www.FirstTracksOnline.com/news/s ... $hqid.shtm format. Everything I've tried prints "$hqid" in the URL instead of the story ID number generated by NewsPro.

If anyone spots a quick fix to this, please throw me a bone.
northward
 
Posts: 5
Joined: Thu Sep 01, 2005 5:27 pm

Postby PPNSteve » Thu Sep 01, 2005 11:33 pm

hmmm..
Code: Select all
sub RSS_Build {
   if ($RSS_ItemCount < $RSS_MaxItems) {
      $RSS_NewsText = $newssubject;
      while ($RSS_NewsText =~ /[\<\>]/) {
        $RSS_NewsText =~ s/\<[ -\;\?-\~\=]+\>//;
      }
      print RSSFEED "    <item>\n      <title>$RSS_NewsText</title>\n";
      print RSSFEED "      <link>$RSS_Link\#$newsid</link>\n      <description>";
      $RSS_NewsText = $newstext;
--------------------------------------------------
change to:

sub RSS_Build {
   if ($RSS_ItemCount < $RSS_MaxItems) {
      $RSS_NewsText = $newssubject;
      while ($RSS_NewsText =~ /[\<\>]/) {
        $RSS_NewsText =~ s/\<[ -\;\?-\~\=]+\>//;
      }
      print RSSFEED "    <item>\n      <title>$RSS_NewsText</title>\n";
      print RSSFEED "      <link>$RSS_Link\$hqid.shtm</link>\n      <description>";
      $RSS_NewsText = $newstext;
where $RSS_Link = your URL path.. ( http://www.FirstTracksOnline.com/news/stories/ )

a guess anyway..
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby northward » Fri Sep 02, 2005 12:09 am

PPNSteve wrote:hmmm..
Code: Select all
sub RSS_Build {
   if ($RSS_ItemCount < $RSS_MaxItems) {
      $RSS_NewsText = $newssubject;
      while ($RSS_NewsText =~ /[\<\>]/) {
        $RSS_NewsText =~ s/\<[ -\;\?-\~\=]+\>//;
      }
      print RSSFEED "    <item>\n      <title>$RSS_NewsText</title>\n";
      print RSSFEED "      <link>$RSS_Link\#$newsid</link>\n      <description>";
      $RSS_NewsText = $newstext;
--------------------------------------------------
change to:

sub RSS_Build {
   if ($RSS_ItemCount < $RSS_MaxItems) {
      $RSS_NewsText = $newssubject;
      while ($RSS_NewsText =~ /[\<\>]/) {
        $RSS_NewsText =~ s/\<[ -\;\?-\~\=]+\>//;
      }
      print RSSFEED "    <item>\n      <title>$RSS_NewsText</title>\n";
      print RSSFEED "      <link>$RSS_Link\$hqid.shtm</link>\n      <description>";
      $RSS_NewsText = $newstext;
where $RSS_Link = your URL path.. ( http://www.FirstTracksOnline.com/news/stories/ )

a guess anyway..


Thanks. That's actually one of the permutations I've tried. This generates XML headlines like this one:

Code: Select all
- <item>
  <title>Ski Area Upgrades at Pats Peak</title>
  <link>http://www.FirstTracksOnline.com/news/stories/$hqid.shtm</link>
  <description>Southern New Hampshire's Pats Peak ski area, entering its 43rd consecutive ski and snowboard season...</description>
  <pubDate>Thu, 1 Sep 2005 13:25:36 GMT</pubDate>
  </item>


For some reason it's not translating the $hqid parameter from ndisplay.pl.
northward
 
Posts: 5
Joined: Thu Sep 01, 2005 5:27 pm

Postby PPNSteve » Fri Sep 02, 2005 12:22 am

hmm it's suppose to read the np vars..
dunno then.. guess you need a real perl pro to check it out..
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby abietto » Sat Oct 29, 2005 7:51 pm

Hi all,
I used this plugin with Newspro and you can find the relative xml rss feed here. I don't know if I've missed something, but the resulting rss file is missing some characters, or so it seems. Any link to emails or other websites are not shown correctly. The script, with my variables, can be found here.

I'll show you an example. A simple link like:
Code: Select all
<a href=http://www.abietto.net>abietto</a>

Should be visualized exactly that way, showing the code, in the final XML/RSS file. Instead, as you can see for yourself, clicking on the link above, it's been strangely processed like this:
Code: Select all
href=http://www.abietto.netabietto

Seems like the starting "<a" and all the others "<" or ">" are stripped away without being parsed.

Do you know how to change the plugin to visualize correct links in the RSS? Is it possible?

Oh, and by the way, there is another problem. Of course, any RSS news or item has a link to the original page, something like this:
Code: Select all
<link>http://www.abietto.net/#1129213279,98389,</link>

The point is: clicking on any links just sends you to the full homepage, not to the post it is actually linked. Why is it so?

Thanx for any replies!
abietto
 
Posts: 1
Joined: Sat Oct 29, 2005 7:43 pm
Location: Milan, Italy


Return to Coranto Development Archives -- 1.25.1 and Older

Who is online

Users browsing this forum: No registered users and 0 guests

cron