Improving validation for snews rss feeds (3)

A final (hopefully) third fix was necessary for snews rss_function. At my site http://www.keramik-werkhof.de I use links and images which use “relative” paths, e.g. <img src="uploads/images .. instead of <img src="http://www.domain.de/uploads/images … This is some the w3c validator does not accept in rss feeds. So how to make sure the full path is used in links and images inside the description of rss content. Well, I came across a function in drupal which fixes this, atleast for links. I had to modify the regex a tiny bit to recognize images aswell (added a dot in the ([A-Za-z0-9) section . So here we go:

find the rss_content function and above it, add the following new function:
function rss_relative_links($description) {
// replace all links starting with '/'
$regexp = "/\b(href|src)(\s*=\s*['\"])([\/][A-Za-z0-9.\/]*)(['\"])/";
$description = preg_replace($regexp, '$1$2'. _SITE. '$3$4', $description);
// replace all relative links not starting with '/'. Absolute links are not matched,
// since ':' is not in the capture pattern.
$regexp = "/\b(href|src)(\s*=\s*['\"])([^\/][A-Za-z0-9.\/]*)(['\"])/";
$description = preg_replace($regexp, '$1$2'. _SITE. '$3$4', $description);
return $description;
}

Then in the function rss_content find:
$link = _SITE.$categorySEF.$articleSEF.'/'.$comment_link;

and add a new line above it with the following:
$text = rss_relative_links($text);

March 22, 2010 at 18:07 Leave a comment

Improving validation for snews rss feeds (2)

So now, my snews cms site uses UTF-8 charset, cause the site is in German. Now and again I used quote tags in the headlines. The get converted to &quot; in the database, which is fine. However the html entity for quotes turns up in the snews rss feed an will break validation (snews 1.7, March 2010). The fix for this is quite simple … here we go:

in the rss_contents function (near to end) find:
<title><![CDATA['.strip($title).']]></title>

and replace it with:
<title><![CDATA['.strip(str_replace('&quot;','\"',$title)).']]></title>

March 22, 2010 at 16:31 Leave a comment

Improving validation for snews rss feeds (1)

While checking the validation for snews rss feeds, I came up against some problems and found some fixes, which may help others who have similar proplems. The first problems I encountered was the the w3c rss validator told me that in the link tag the rel=self was missing. This is easily fixed by adding the following lines to the rss_contents() in snews.php

find:
echo '
<?xml version="1.0" encoding="'.s('charset').'"?>
<rss version="2.0">
<channel>
<title><![CDATA['.s('website_title').']]></title>
<description><![CDATA['.$heading.']]></description>
<link>'._SITE.'</link>

and replace with:
if (substr($rss_item,-1) != '/') {
  $rss_item_link = $rss_item . '/';
} else {
  $rss_item_link = $rss_item;
}
echo '
<?xml version="1.0" encoding="'.s('charset').'"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"&gt;
<channel>
<title><![CDATA['.s('website_title').']]></title>
<description><![CDATA['.$heading.']]></description>
<link>'._SITE.'</link>
<atom:link href="'._SITE.$rss_item_link.'" rel="self" type="application/rss+xml" />

This will make the feed Atom compliant, which seems to be necessarry for the w3c Validator.

March 22, 2010 at 16:01 Leave a comment

Festival of World Cultures

festival1.jpgWent to visit this festival on Sunday in Dún Laoghaire, Dublin. Great event with some great music. Weather could have been a bit better, but on the whole it was ok, except for the traffic. Below a small video snipplet of one of the bands playing for free in one of the side roads. The girl has a great voice, which isn’t really done justice by the video clip. Don’t remember the name of the band playing, but they are playing a well known song from the Blues Brothers. I’m sure you’ll recognize it.

August 27, 2006 at 18:52 Leave a comment

Statistics for (w)rappers

Ever wondered what psychology students do in their free time between classes? Well here is the answer. Of course it’s only one answer which would be statistically irrelevant. Some psychology students at University of Oregon thought a rap video about their ordeals in learning stats would be interesting – it’s very funny if you can understand what their on about ;)

If you’re into stats for psychology have at Ed’s Statistics Home Page. He’s got some excellent stuff there (Answers to Questions about Statistics in Psychology).

August 25, 2006 at 00:44 Leave a comment

OU Icon for your Desktop

OU Logo, Copyright Open University 2006Here is a little icon I made for my WinXP Desktop. Just download the .ico file and place it in the folder where you keep your OU stuff. Then create a shortcut to that folder on your desktop or in your task bar or wherever you want. Right click on the shortcut and select “Properties”. Then click on the “Change Icon” button and select the ou.ico in the OU Folder. The folder icon should now change to the OU Icon. It has 3 sizes: 48×48, 32×32 and 16×16 Pixels and uses the alpha channel.

Download: OU Icon (Zip file ~8 kB)

August 23, 2006 at 21:37 4 comments

OU TMA Template

If you studying at the OU, you will perhaps know that TMAs (Tutor marked assignments) have certain requirements in regard to layout and text. Here a Word template which will make your TMAs look nicer (hopefully). I’ve had a lot of praise from Tutors for it, so if you like it, you may use it freely. You will probably need MS Word 2000 or 2003 for the template to work well. Have not tested it in other Word versions.

Download: OU TMA Template (tma_template.doc ~40 kB)

August 23, 2006 at 14:34 2 comments

Older Posts


November 2014
M T W T F S S
« Mar    
 12
3456789
10111213141516
17181920212223
24252627282930

Categories

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1 other follower


Follow

Get every new post delivered to your Inbox.