Jishi Samuel

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJishi Samuel
ToMe
SubjectUsing RSS parsing script for my homepage
Date6 April 2009 20:39
Hi Tarquin,

Thanks for the great site. The rss parsing script is something that I have been 
searching for for a long time to use in my site since [Brand] script at 
[URL] could not parse my atom files.

For my home page at [URL] I am using snippets from my blogs. 
and in order to simplify the order of the stories I am using the [brand] 
to create my reading list and then using the labels to get my desired order atom 
feeds.

eg: 
[URL]

I was trying to truncate the story but could not figure out which variable to 
truncate. I tried substr function on description and content to no avail.

I am trying to package the script into a single function which would take the 
following parameters:

function showFeed(url,no_stories,length,type)

url=url of atom/rss xml file
no_stories= number of stories
length=number of characters per story. (Used to show snippets)
type =  only story titles  (title)  (like that in your scroller)
        or full story      (full)

Also, an option to change the width and height of the image would be nice.
:)

Would you help me?

Regards,

Jishi Samuel
FromMe
ToJishi Samuel
SubjectRe: Using RSS parsing script for my homepage
Date9 April 2009 10:13
Jishi,

> I was trying to truncate the story but could not figure out which
> variable to truncate. I tried substr function on description and content
> to no avail.

http://www.howtocreate.co.uk/emails/GuillaumeLarocque.html

However, since both description and content can have markup inside them,
using a substring can easily break that markup. It's much better to just
use CSS to hide the content if it becomes too long. The following should
work (except in IE 6, which does not support max-height):

div.descr, div.conte {
  max-height: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
}

> I am trying to package the script into a single function which would take
> the following parameters:

This is all done in this section:

oFeedStr += '<div class="feeditem"><h3><a
href="'+y['links']['alternate']+'">';
if( displayEnclosures == 1 ) { oFeedStr += oEncl; }
oFeedStr += (y['title']?prepHTMLCode(y['title']):'Untitiled')+'<\/a><\/h3>';
if( !displayAtomLinks ) { oFeedStr += oAtomLinks; }
oFeedStr += y['description']?('<div
class="descr">'+y['description']+'<\/div>'):'';
oFeedStr += y['content']?('<div class="conte">'+y['content']+'<\/div>'):'';
if( displayAtomLinks ) { oFeedStr += oAtomLinks; }
if( displayEnclosures == 2 ) { oFeedStr += oEncl; }

Since the parsing function is invoked asynchronously, it's not possible
to directly pass it variables. They would need to be created as a global
variable (as with the existing options set near the top of the script),
and you could add more 'if' statements to show only the parts you want.

> no_stories= number of stories

http://www.howtocreate.co.uk/emails/AlIngham.html

> Also, an option to change the width and height of the image would be nice. :)

Use CSS to set height/width or max-height/max-width of img elements
inside div.feeditem elements.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.