Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Pages: [1] 2   Go Down
Print
Author Topic: rss feed calendar  (Read 1661 times)
0 Members and 1 Guest are viewing this topic.
walter
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: February 22, 2004, 02:22:00 PM »

hello overthere

finally there is also a rss template for the calendarscript
(I've cleaned up the full year template for this template and changed some code)
I don't know if rss is so popular and necessary, nevertheless here is the code:

file name = rss.xml
save it in tour template directory

to call the rss: http://foo.bar/cgi-bin/.../calendar.cgi?view=rss&calendar=yourcalendat&template=rss.xml

****************************
<%= "<rss version=\"0.92\">" %>
<%= "<channel>" %>
   <%= "<title> YOUR TEXT HERE - " %><% CALENDAR NAME %><%= "</title>" %>
   <%= "<description>" %><% CALENDAR DESCRIPTION %><%= "</description>" %>
   <%= "<link>" %><%=$CGI_URL%><%= "?calendar=" %><% CALENDAR KEY %><%= "</link>" %>
   <%= "<language>en</language>" %><% $STYLE = $in{style} | | "Grid"; $VIEW = $in{view}; if ($VIEW eq "rss") {$sd = $DATESTRING; substr ($sd, -2, 2) = "01"; &getEvents( { 'duration'=>'90d','startdate'=>$sd } ); }%><% if ($VIEW eq "rss") { %><% if ($STYLE eq "Grid") { %><%FOREACH GRID ROW%><%FOREACH GRID COLUMN%><%IF DISPLAY%><%FOREACH EVENT%><%$i++;%>
     <%= "<item>" %>
      <%= "<title>" %><% SCHEDULE FIELD(date) %><%= "/" %><% SCHEDULE FIELD(month) %><%= "/" %><% SCHEDULE FIELD(year) %><%= " (dmy) :: " %><%= EVENT FIELD(title) %><%= "</title>" %>
      <%= "<description>" %><%= EVENT FIELD(subject) %><%= "</description>" %>
      <%= "<link>" %><%=$CGI_URL%><%= "?month=" %><% SCHEDULE FIELD(month) %><%= "\&calendar=" %><% CALENDAR KEY %><%= "&view=Event" %><%= "&event_id=" %><%= SCHEDULE FIELD(event_id) %><%= "&datestring=" %><%= SCHEDULE FIELD(datestring) %><%= "</link>" %>
     <%= "</item>" %><%/FOREACH%><%/IF%><%/FOREACH%><%/FOREACH%><% } %><% } %>
<%= "</channel>" %>
<%= "</rss> " %>
****************************

I need some feedback...
I've test this template in Netscape 7.0, IE 6 and opera
in IE there is no output, but I think the source code is rss
it looks nice i think
has anyone a rss parser to test this template?
THX guys (and ladies also)  
Walter

Logged
jeepish
New Member
*

Karma: 0
Offline Offline

Posts: 0


« Reply #1 on: June 20, 2005, 03:56:00 PM »

I just tried using this, but am getting a:

code:

syntax error at (eval 1) line 7, near "| |"

And it highlights this line:

code:

print "\n";print "<language>en</language>";print "";$STYLE = $in{style} | | "Grid"; $VIEW = $in{view}; if ($VIEW eq "rss") {$sd = $DATESTRING; substr ($sd, -2, 2) = "01"; &getEvents( { 'duration'=>'90d','startdate'=>$sd } ); }print "";if ($VIEW eq "rss") {print "";if ($STYLE eq "Grid") {print "";foreach $ROW (0 .. $Grid->{rowcount}-1) {print "";foreach $COL (0 .. $Grid->{colcount}-1) { $DAY = $Grid->{grid}->[$ROW]->[$COL]; my ($EVENTS) = $Grid->{grid}->[$ROW]->[$COL]->{events};print "";if ($DAY->{'display'}) {print "";foreach $EVENT (@$EVENTS) {print "";$i++;

I'm using CS 3.21.

Anyone else get RSS feeds working?

I'm not a perl hacker, so please be gentle...

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #2 on: June 20, 2005, 04:25:00 PM »

** syntax error at (eval 1) line 7, near "| |"  **

 This forum software adds a space between "| |" characters which should not be there.
You will have to remove any space(s) between | | characters in the code posted above.

If you find it works Ok, maybe I'll make a full fledged template out of it
and add it to the Unofficial CalendarScript - Mods and Plugins site.

JFYI

Dan O.

------------------

Logged
jeepish
New Member
*

Karma: 0
Offline Offline

Posts: 0


« Reply #3 on: June 20, 2005, 06:10:00 PM »

Ah hah!

Yes, that helped.

Once I got that fixed, I found errors in the URLs created. In properly formed XML, ampersands have to be encoded in URLs, so here's the fixed code:

******************
<%= "<rss version=\"0.92\">" %>
<%= "<channel>" %>
<%= "<title> YOUR TEXT HERE - " %><% CALENDAR NAME %><%= "</title>" %>
<%= "<description>" %><% CALENDAR DESCRIPTION %><%= "</description>" %>
<%= "<link>" %><%=$CGI_URL%><%= "?calendar=" %><% CALENDAR KEY %><%= "</link>" %>
<%= "<language>en</language>" %><% $STYLE = $in{style} | | "Grid"; $VIEW = $in{view}; if ($VIEW eq "rss") {$sd = $DATESTRING; substr ($sd, -2, 2) = "01"; &getEvents( { 'duration'=>'90d','startdate'=>$sd } ); }%><% if ($VIEW eq "rss") { %><% if ($STYLE eq "Grid") { %><%FOREACH GRID ROW%><%FOREACH GRID COLUMN%><%IF DISPLAY%><%FOREACH EVENT%><%$i++;%>
<%= "<item>" %>
<%= "<title>" %><% SCHEDULE FIELD(date) %><%= "/" %><% SCHEDULE FIELD(month) %><%= "/" %><% SCHEDULE FIELD(year) %><%= " (dmy) :: " %><%= EVENT FIELD(title) %><%= "</title>" %>
<%= "<description>" %><%= EVENT FIELD(subject) %><%= "</description>" %>
<%= "<link>" %><%=$CGI_URL%><%= "?month=" %><% SCHEDULE FIELD(month) %><%= "&calendar=" %><% CALENDAR KEY %><%= "&view=Event" %><%= "&event_id=" %><%= SCHEDULE FIELD(event_id) %><%= "&datestring=" %><%= SCHEDULE FIELD(datestring) %><%= "</link>" %>
<%= "</item>" %><%/FOREACH%><%/IF%><%/FOREACH%><%/FOREACH%><% } %><% } %>
<%= "</channel>" %>
<%= "</rss> " %>
****************
Argh... this board...

Okay, the line for the link ("<%= "<link>" %><%=$CGI_URL%><%= "?month=" %><% SCHEDULE FIELD(month) %><%= "&calendar=" %>.... where it says "&calendar", that standalone & should be the & a m p ; (minus the spaces). This board seems to not like that. Do that for &calendar &view &event_id &datestring.

I've only tested this in Safari 2.0 and NetNewsWire 2.0 (both worked great). If others could take a whack at it, that'd be good.

(kids, don't forget to get rid of that extra space at the pipes!)

------------------

[This message has been edited by jeepish (edited June 20, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #4 on: July 15, 2005, 12:26:00 AM »

Walter sent me a copy of the template and I have added it to the Unofficial CalendarScript - Mods and Plugins site.

Thanks Walter.

Dan O.

------------------

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #5 on: October 16, 2005, 11:34:00 PM »

Hi Walter,
A couple of problems, although I am in total support of your effort:

1)  <%= "<description>" %><%= EVENT FIELD(description) %><%= "</description>" %> won't parse because the parser sees the second 'description' as an error. Most of us use the unique field id 'description' because it is defaulted into calendarscript and would be hard to change in all our custom templates. I tried a standard backslash escape character but no luck yet. Will keep you posted.
2) The feed won't validate because of the html tags fed from the default template. A new working template without them would need to be created and called from the rss.xml template, or coding to strip the tags in the template.
3) Although not required, an RFC-822 compliant <date> field in the channel would be nice.

I'll play with some of this in my spare time, but you may already have some ideas.

DanO, could an alias for EVENT FIELD(description) be coded to circumvent problem 1)?

[This message has been edited by musicvid (edited October 16, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #6 on: October 17, 2005, 12:58:00 AM »

** could an alias for EVENT FIELD(description) be coded to circumvent problem 1)? **

I'm afraid you will have to further explain the problem(s) as I am not at all familiar
with rss requirements and don't fully understand what you've described.

** won't parse **

Won't parse where? By CalendarScript or a RSS reader?

** an RFC-822 compliant <date> field in the channel would be nice **

In what format?

Dan O.

[This message has been edited by DanO (edited October 17, 2005).]

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #7 on: October 17, 2005, 10:08:00 PM »

**I'm afraid you will have to further explain the problem(s) as I am not at all familiar with rss requirements**

-- For some reason the second use of the word 'description' even within perl brackets as in <%= EVENT FIELD(description) %> crashes the RSS parsers (I have tried both RssReader and Firefox). This also answers your second question. I have tried adding the standard backslash '\' escape character at different points in the statement without success. I think the second use of the word 'description' is confusing the RSS parsers.

As evidence, if I use the statement <%= EVENT FIELD(location) %> which is a custom field in my Calenderscript installation, as in <%= "<description>" %><%= EVENT FIELD(location) %><%= "</description>" %> in the rss.xml facade that Walter created, the RSS parsers work correctly and that field shows up in the parser output without issue.

Hope this helps. The other problem, being the inclusion of html tags like <head></head> and body></body> which may or may not be problematic depending on the RSS parser being used, I think can easily be excluded by creating a "rss" template which does not use those tags. A proper validation of the feed at http://feedvalidator.org  is a prerequisite for getting your feed sydicated and displayed on the major services.

As to your third question, the example '16 Oct 2005 19:38:32 MDT' validates correctly as RFC-822 compliant at feedvalidator.org

Thanks in advance for any help you can provide,
Mark

------------------

[This message has been edited by musicvid (edited October 17, 2005).]

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #8 on: October 17, 2005, 10:50:00 PM »

From Walter:

"I don't know if rss is so popular and necessary, nevertheless here is the code:"

RSS is both "popular and necessary."
Otherwise, Google, The New York Times, Yahoo!, MSN, BBC, Reuters, Playbill, AP, and hundreds of other major media services wouldn't be using RSS as their primary means of electronic information deployment.

You're on the right track, Walter. Keep up the good work!

------------------

[This message has been edited by musicvid (edited October 17, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #9 on: October 18, 2005, 01:23:00 AM »

** For some reason the second use of the word 'description' even within perl brackets as in
<%= EVENT FIELD(description) %> crashes the RSS parsers **

An RSS parser shouldn't even see that tag as it will be replaced by the 'description' event field
when CalendarScript parses the template first.

You are calling it through CalendarScript rather than directly aren't you???

The order goes; CalendarScript parses the template, removes all ASP-like tags (eg. <% ... %> )
and replaces any event field tags (eg. <%= EVENT FIELD(description) %> ) with the actual
event field data (in that case the event description field). Only THEN does the RSS
parser get what code is left.

<%= EVENT FIELD(description) %> should be *completely* gone
from the output BEFORE the RSS parser even gets it.

Dan O.

[This message has been edited by DanO (edited October 18, 2005).]

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #10 on: October 18, 2005, 07:37:00 AM »

The feed address is being called by my RSS parsers as in the example Walter gave:
http://foo.bar/cgi-bin/.../calendar.cgi?view=rss&calendar=yourcalendat&template=rss.xml

I will dig into it further when time is available.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #11 on: October 18, 2005, 01:15:00 PM »

** The feed address is being called by my RSS parsers as in the example Walter gave: **

If you would supply a real address for it we might be able to look into what's going on.
Something isn't right if any of the <% ... %> tags are still present after being called.

JFYI

Dan O.


[This message has been edited by DanO (edited October 18, 2005).]

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #12 on: October 20, 2005, 11:07:00 AM »

Update:

I was wrong about the <%= EVENT FIELD(description) %> being the cause of the problem. It is illegal characters (for xml) that appear between the tags in the content. These include
'
"
&
<
>
\

They could be escaped or enclosed in [CDATA[ blocks to give a well-formed xml output. I am going to try the latter approach since it seems simpler. Changing them to html equivalents has been shown to cause problems with some versions of Firefox.

I also found that something like this <%= "<?xml version=\"1.0\"?>" %> should appear as a declaration line at the top of the template. An encoding declaration could also appear, but apparently is not required.

As to serving the feed as text/html which feedvalidator.org doesn't like, I found this line in calendar.pl
unless ($no_header) { print "Content-type: text/html\n\n"; }

If that could be appended to print application/rss+xml or text/xml when the View is rss, that should solve the problem.

I'm just scratching the surface, so I haven't tried incorporating any changes yet.

------------------

[This message has been edited by musicvid (edited October 20, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #13 on: October 20, 2005, 01:56:00 PM »

** I also found that something like this <%= "<?xml version=\"1.0\"?>" %> should appear as a declaration **

JFYI. Any text you want printed out verbatim, you don't need to enclose in
<%= ... %> tags. just put the actual code where it would be. Eg.

<?xml version="1.0"?>
<rss version="0.92">
<channel>
<title> YOUR TEXT HERE - <%= CALENDAR NAME %></title>
<description><%= CALENDAR DESCRIPTION %></description>

Just calendar variables and Perl programming code needs to be within the ASP-like tags.


** If that could be appended to print application/rss+xml **

AFAIK, that could only be done from within a plug-in, not just from a template.
Maybe if someone can come up with a working template, I might look into that
part of it... if no one else does in the mean time.

JFYI

Dan O.

------------------

Logged
musicvid
New Member
*

Karma: 1
Offline Offline

Posts: 8


WWW
« Reply #14 on: October 21, 2005, 10:02:00 AM »

Thanks for the clarifications.

** that could only be done from within a plug-in, not just from a template.**

I tried adding some lines to my calender.pl but I am a little syntax-stupid. In one case I got it serving as application/xml but killed text/html for other views.
In another attempt, I got it to do both but it just printed the content type in the xml output rather than serving it that way.

Will keep twiddling as time permits.

------------------

Logged
Pages: [1] 2   Go Up
Print
Jump to: