RSS feed creation - Discussion and Solution

Post your requests for addons here, and discuss any addons in development here, as well.
Once an addon has completed development, it will be released in the "Addon Release" forum.

Moderator: Spunkmeyer

Postby shanemckiness » Tue Feb 21, 2006 4:28 am

Will that codes produce a date format like this code does:
Code: Select all
<PerlCode>
$pubDate = substr ($Weekday,0,3).", " . $TwoDigitDay . " " . substr ($Month_Name,0,3) ." " . $Year ." " . $TwoDigitHour . ":" . $Minute . ":" . $Second . " CST";
</PerlCode>
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>


-Shane
shanemckiness
 
Posts: 234
Joined: Fri May 21, 2004 5:14 pm

Postby Aaa » Fri Mar 03, 2006 2:23 pm

this has been fantastic help thanks guys... one thing though, if you apply punctuation in coranto news articles like " " or ' ', the feeds built by the profile/template wont work an error comes up saying "An invalid character was found in text content. Error processing resource". Does anyone know how to work around this so that the punctuation stays but the feed still builds?
Aaa
 
Posts: 13
Joined: Wed Feb 28, 2007 1:36 pm

Postby SrNupsen » Fri Mar 03, 2006 5:04 pm

Check out the Anne Rice addon - it allows you to replace text on the fly, so that you can (for example) replace those quotation marks with their respective codes.

SrNupsen
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Dale Ray » Sat Mar 04, 2006 4:20 am

The Search And Replace addon by Parahead should also take care of special characters.
Dale Ray
User avatar
Dale Ray
 
Posts: 1004
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby faithless » Sat Mar 04, 2006 7:23 am

We should probably make a distinction between the 'Anne Rice' and Search and Replace' addons.

They, although function similarly, 'Anne Rice' makes permenant replacements which are saved into newsdat.txt and converted back only when you edit the news item. This means, the replaced text can play nicely with other addons that query newsdat.txt for data.

With 'Search and Replace', the conversion only affects the output when you build news. The data stored in newsdat.txt is not modified at all.
faithless
 
Posts: 1335
Joined: Wed Oct 16, 2002 4:17 pm
Location: Infront of the Computer

Postby Parahead » Sat Mar 04, 2006 2:16 pm

faithless wrote:We should probably make a distinction between the 'Anne Rice' and Search and Replace' addons.

They, although function similarly, 'Anne Rice' makes permenant replacements which are saved into newsdat.txt and converted back only when you edit the news item. This means, the replaced text can play nicely with other addons that query newsdat.txt for data.

With 'Search and Replace', the conversion only affects the output when you build news. The data stored in newsdat.txt is not modified at all.
I agree fully that there is a difference between the two addons although the end result may look the same in most cases.

The reason I coded the S&R addon was because Anne Rice had problems with converting back the replacement when modifying the news in certain cases. S&R also contains slightly more "targeted" (and improved) replacement features then AR. I was also in need of replacing stuff to HTML layout and I did not want my current site layout saved in a bunch of newsitem in case the site layout was changed later on, so basically the "limitation" you point out in S&R that it does not alter the saved data is a feature I *wanted* to achive. S&R do play nicly with addons that uses the data during build news or through viewnews.cgi, but I agree that one should be aware of the fact that S&R may not deliver the replaced data to other addons that fetch data directly from newsdat.txt. There is also a speed gain in favor to the Anne Rice addon over S&R, since the replacement is only done during save/edit.

Next time I put out a new release of S&R I will include the above information so that people can choose the addon that best target their needs...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Aaa » Mon Mar 06, 2006 3:51 am

do you guys know how it can be done so that the line spaces are also coded in to the xml feeds? As it is now the profile creates the article to be all together?
Aaa
 
Posts: 13
Joined: Wed Feb 28, 2007 1:36 pm

Postby Parahead » Fri Mar 10, 2006 6:47 pm

aaa wrote:do you guys know how it can be done so that the line spaces are also coded in to the xml feeds? As it is now the profile creates the article to be all together?
If the text that this happens for is a multi-line text field, I think the reason this happens is that you have the "Convert Newlines?" option set to No in that fields settings page.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Aaa » Tue Mar 14, 2006 7:25 am

Parahead wrote:
aaa wrote:do you guys know how it can be done so that the line spaces are also coded in to the xml feeds? As it is now the profile creates the article to be all together?
If the text that this happens for is a multi-line text field, I think the reason this happens is that you have the "Convert Newlines?" option set to No in that fields settings page.


Just checked this and no it is set to 'yes'?
Aaa
 
Posts: 13
Joined: Wed Feb 28, 2007 1:36 pm

Postby Parahead » Wed Mar 15, 2006 6:49 pm

aaa wrote:Just checked this and no it is set to 'yes'?
OK... Could you then please elaborate what you mean by "line spaces" and "articles to be all together" (maybe with examples), just to make sure I understand what you mean correctly.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Musicvid » Sun Jun 18, 2006 11:41 pm

Here's my take on this:
    Use strftime for RFC822 dates because it's very fast, simple, and automatically gets a compliant timezone.
    Put all the variables in the style and pass them rather than hardcoding the template. This way, one template will serve many feeds.
    Put text between <![CDATA[]]> blocks to escape illegal characters like ' " & < > \
It's working nicely on 1.31.5 (did I forget to say THANKS! guys) and validates without complaint. Please stress-test it and post back. It screams on my server benchmark (.33 sec total build time on a 66 item feed). There is an alternative included if for some reason Posix is not on your server. I may try to make it backwards-compatible to 1.24 or ask for some advice to turn it into an addon if you find it useful.

Instructions: Fill in two variables near the top of the style. Upload rss.tmpl to your templates folder. In your profile, select the new style, create rss.xml in the HTML option and don't forget to turn anchors 'off'. That's it.

(Code lightly tweaked 7-01-06)
Here is the Style:
Code: Select all
<PerlCode>

   # Just run the channel stuff once
   my $i  = ++$countitems{$ProfileName};
   for ($i)
   {
   next if $i>1;

   ## Populate Channel Fields ##
   ######################################
   #  CHANGE TO MATCH YOUR INFORMATION  #
   ######################################

   # Your Organization or Feed Name
   my $orgname    = "Your Organization Name";

   # Optional Acronym or Abbreviation (can leave blank)
   my $orgabbr    = "";

   # Channel Image Must Be No More Than 144px In Width
   my $imageurl   = "http://yoursite.com/yourlogo.gif";

   ######################################
   #   ANY CHANGES BELOW ARE OPTIONAL   #
   ######################################

   if (!$orgabbr) {$orgabbr = $orgname;}
   my $SiteTitle  = $CConfig{'SiteTitle'};
   my $SiteLink   = $CConfig{'SiteLink'};

   # Gets the current time in RFC822 format
   use POSIX qw(strftime);
   # If Posix isn't on your server, comment it out and uncomment the line below.
   # use Date::Format;
   my @BuildDate = localtime(time);
   my $now_year = strftime("%Y", @BuildDate);
   my $BuildDate = strftime("%a, %d %b %Y %H:%M:%S %z", @BuildDate);
   # If a US timezone, could use %Z above instead

$newshtml .= "<title><![CDATA[<Field: orgabbr> News]]></title>\n";
$newshtml .= "<link><Field: SiteLink></link>\n";
$newshtml .= "<description><![CDATA[The Latest News from <Field: orgname>]]></description>\n";
$newshtml .= "<copyright><![CDATA[Copyright (c) <Field: now_year> <Field: orgname>. All rights reserved.]]></copyright>\n";
$newshtml .= "<language>en-us</language>\n";
$newshtml .= "<lastBuildDate><Field: BuildDate></lastBuildDate>\n";
$newshtml .= "<image>\n";
$newshtml .= "<title><![CDATA[<Field: orgabbr> Home Page]]></title>\n";
$newshtml .= "<link><Field: SiteLink></link>\n";
$newshtml .= "<url><Field: imageurl></url>\n";
$newshtml .= "</image>\n";
   }

   ## Populate Item Fields ##
   my @time_added = gmtime($newstime);
   my $pubDate    = strftime("%a, %d %b %Y %H:%M:%S GMT", @time_added);
   my $adminurl = $scripturl;
   $adminurl =~ s/\/coranto.cgi?/\//;
   # Template for item links (can leave blank)
   my $tmpl    = "viewnews";

## RSS NOTES
#  Channel Image Must Be <= 144px In Width
#  No HTML in <title> Fields
#  Keep Fields Containing ' " & < > \ between <![CDATA[]]> tags
#  Avoid using HTML entities such as &#183;
#  Don't paste Email content directly into Text fields. You'll get weird characters.
##
</PerlCode>

<item>
<title><![CDATA[<Field: Subject>]]></title>
<link><![CDATA[<Field: adminurl>viewnews.cgi?id=<Field: newsid>&style=&tmpl=<Field: tmpl>]]></link>
<description><![CDATA[<Snip 265: Field: Text>]]></description>
<pubDate><Field: pubDate></pubDate>
<guid isPermaLink="false"><Field: adminurl>viewnews.cgi?id=<Field: newsid></guid>
</item>

Here is the template (rss.tmpl):
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<Field: Content>
</channel>
</rss>

Example feed is up at http://ovationplayers.com/news/rss.xml
The reason I hadn't jumped into the fray earlier is because I was working on an RSS template for another script, which this template is based on.
(The images in some of the example feed descriptions are by way of a custom field "Image." A really easy addition to make.)
Here's the feed formatted the way it might look on a website:
http://ovationplayers.com/news/rsstest.php
Last edited by Musicvid on Sat Aug 12, 2006 4:35 am, edited 3 times in total.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby Musicvid » Thu Jul 06, 2006 6:35 pm

A brand-new user in another discussion wanted more detailed instructions for installing the style and template in the message above, so here they are (he says they work perfectly):
musicvid wrote:
...could you make a full instruction install for me to make sure



1) In Coranto 1.31.5 Beta, go to Administration->Edit News Styles->Create New Style.

2) Name the new Style "RSS Feed" without the quotes and create a STANDARD Style.

3) Click "Edit" RSS Feed and paste the Style Code I provided. Type in the name of your Organization or Feed, and the URL of your Channel Image, which can be no more than 144 pixels in width. Click "Save Changes."

4) Open the Notepad application on your computer, paste the Template code I provided, Save the file, then Rename the file to "rss.tmpl" without the quotes. Upload the rss.tmpl file to the "Templates" folder in your Coranto 1.31.5 installation on your server.

5) In Administration->Manage Profiles->Create New Profile, create a Profile named "RSS_Feed" without the quotes. Enable the RSS_Feed Profile.

6) Click "Edit General Settings" for the RSS_Feed Profile. Scroll down to "Categories" and select any Categories of news items you wish to include in your feed. Immediately below that, select "RSS Feed" as your News Style. Scroll down to "HTML Template" and select "rss.tmpl". Immediately below that, type in "rss.xml" without the quotes as your "HTML User File Name." Scroll down to "Anchor Tags?" and set them to "OFF." Do not make any other changes to the Profile settings. Click "Save Changes."

7) Go to Administration and click the "Build News" link. You should now have a valid RSS 2.0 file named "rss.xml" in your news files folder.

8) Post back if this does not answer all of your questions.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby Dale Ray » Thu Jul 06, 2006 6:44 pm

This thread is the one referred to by musicvid in the previous message.
Dale Ray
User avatar
Dale Ray
 
Posts: 1004
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Ultam » Tue Aug 01, 2006 12:21 am

Psykosys wrote:
shanemckiness wrote:Apparently some of my text was removed from my previous post. The real question was How can I pust a lastbuilddate into the profile portion to make it so that lastbuilddate = the date that the last news item was published?

Thanks,
Shane

You may be able to use a simple little bit of Perl, assuming that your profile is set to reverse-chronological order. At the top of your newsstyle, you could put:
Code: Select all
<PerlCode>
$lastdate;
if ($lastdate == null) {
$lastdate = $Date;
}
</PerlCode>

Then, in your template you could use <Field: lastdate> where you wanted the date to show.


But how to add "lastdate" in text file (as in newspro.cgi, in simple format: dd.mm)?
Ultam
 
Posts: 1
Joined: Tue Aug 01, 2006 12:18 am

Postby a51hh » Thu Aug 31, 2006 12:18 am

anything for the rest of us that don't use the new beta version of Coranto?
a51hh
 
Posts: 8
Joined: Sun Jan 29, 2006 3:24 am

PreviousNext

Return to Addon Development and Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron